Sub topic 4
Instance types and families
An instance type fixes the hardware an EC2 instance gets: vCPUs, memory, network bandwidth, storage options and processor architecture. This chapter assumes you have read the earlier chapters on AMIs and Regions and Availability Zones, and that you can run the AWS CLI with working credentials.
Reading an instance type name
Every name has the same parts. Take m7g.xlarge:
| Part | Example | Meaning |
|---|---|---|
| Family | `m` | The workload profile (general purpose) |
| Generation | `7` | Hardware generation. Higher is usually newer and better value |
| Attributes | `g` | Optional letters for processor or features |
| Size | `xlarge` | Amount of resources within the family |
Common attribute letters:
g: AWS Graviton (Arm) processor.a: AMD processor.i: Intel processor.d: local NVMe instance store volumes.n: enhanced networking.e: extra memory or storage.
A name such as c6id.large stacks several letters: Intel, with local disks.
Families and their memory-to-CPU ratios
Families differ mainly in how much memory each vCPU gets. A vCPU is one hardware thread presented to the operating system.
| Category | Example families | Typical use | Memory per vCPU (example) |
|---|---|---|---|
| General purpose | M, T, Mac | Web servers, small databases, mixed workloads | 4 GiB (`m7g`) |
| Compute optimized | C | Batch processing, encoding, game servers | 2 GiB (`c7g`) |
| Memory optimized | R, X, z1d | In-memory caches, large databases, analytics | 8 GiB (`r7g`) |
| Storage optimized | I, D, H | High I/O local storage, data warehouses | Varies, with large local disks |
| Accelerated computing | P, G, Inf, Trn, F | GPU training, graphics, inference, FPGAs | Varies |
Within a family, sizes scale predictably. Going from large to xlarge to 2xlarge roughly doubles vCPUs, memory and hourly price at each step. Scaling up one size therefore costs about the same as running two of the smaller size, so you choose between a bigger instance and more instances on availability and design, not on price per unit.
Querying types with the CLI
The console list is long. describe-instance-types returns the same data and can be filtered.
aws ec2 describe-instance-types \
--instance-types t3.micro c7g.large m7g.large r7g.large \
--query 'InstanceTypes[].[InstanceType,VCpuInfo.DefaultVCpus,MemoryInfo.SizeInMiB,ProcessorInfo.SupportedArchitectures[0]]' \
--output tableTo search, filter on attributes. This finds current-generation Arm types with 4 vCPUs and 16 GiB:
aws ec2 describe-instance-types \
--filters \
Name=current-generation,Values=true \
Name=processor-info.supported-architecture,Values=arm64 \
Name=vcpu-info.default-vcpus,Values=4 \
Name=memory-info.size-in-mib,Values=16384 \
--query 'InstanceTypes[].InstanceType' \
--output textNot every type is offered in every Availability Zone. Check before you pick a subnet:
aws ec2 describe-instance-type-offerings \
--location-type availability-zone \
--filters Name=instance-type,Values=m7g.large \
--region us-east-1 \
--query 'InstanceTypeOfferings[].Location' \
--output textArchitecture must match the AMI
Types with a g (Graviton) run arm64. Intel and AMD types run x86_64. An AMI is built for one architecture, and run-instances fails if it does not match the type. The public SSM parameters for Amazon Linux 2023 are separate for each:
aws ssm get-parameter \
--name /aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-arm64 \
--query Parameter.Value --output textUse the x86_64 parameter from the launch chapter with Intel and AMD types. Graviton types are often cheaper per unit of work, but software must have arm64 builds. Check your container images and compiled binaries before you switch.
Burstable instances
T-family types (t3, t3a, t4g) are for workloads that are usually idle with occasional peaks. Each type has a baseline CPU level. A t3.micro has 2 vCPUs and a baseline of 10% per vCPU. Below the baseline it earns CPU credits, and above it spends them. One credit is one vCPU at 100% for one minute.
Two modes control what happens when the credits run out:
- Standard: the CPU is throttled to the baseline. Latency rises, but the cost does not.
- Unlimited: the instance keeps bursting and you pay for surplus credits. T3 and later default to this mode.
You can choose the mode at launch by adding an option to run-instances:
--credit-specification CpuCredits=standardWatch the CPUCreditBalance CloudWatch metric. A balance that keeps falling means the workload does not fit a burstable type. A fixed-performance family such as m is then both cheaper and more predictable.
Resizing an existing instance
For EBS-backed instances you can change the type in place:
- Stop the instance.
- Change the type.
- Start it again.
aws ec2 stop-instances --instance-ids i-0123456789abcdef0
aws ec2 wait instance-stopped --instance-ids i-0123456789abcdef0
aws ec2 modify-instance-attribute \
--instance-id i-0123456789abcdef0 \
--instance-type '{"Value": "t3.small"}'
aws ec2 start-instances --instance-ids i-0123456789abcdef0Common errors and gotchas
- Architecture change: you cannot resize from
x86_64toarm64on the same instance. Launch a new instance from an AMI built for the target architecture. - Driver support: current-generation types run on the Nitro system and need the ENA network driver and NVMe support in the AMI. Old or custom AMIs may fail to boot or lose networking.
- Public IP changes: a stop and start moves the instance to new hardware, and an automatically assigned public IPv4 address changes. Use an Elastic IP if you need a stable address.
- Instance store is lost: local disks on
dtypes and storage families are wiped when you stop the instance. Data on EBS volumes stays. InsufficientInstanceCapacity: AWS has no spare capacity of that type in that Availability Zone right now. Retry later, use another AZ, or choose a different size or type.- Unsupported in this AZ: the type is not offered in the subnet's AZ. Use
describe-instance-type-offerings. VcpuLimitExceeded: On-Demand quotas are counted in vCPUs per family group, such as Standard (A, C, D, H, I, M, R, T, Z). Request a quota increase in Service Quotas.- Network bandwidth: figures marked "up to" are burst limits. Sustained throughput is lower on small sizes. Network and EBS bandwidth grow with size, so a small instance can be limited by its network or EBS bandwidth even when CPU is idle.
Exercise
An application needs 8 vCPUs and 64 GiB of memory, and it runs on arm64. Which family category and size would you check first, and which CLI command confirms the exact type exists in your Availability Zone?
Show answer
The memory-to-vCPU ratio is 8 GiB per vCPU, which matches memory optimized (R family), so check an Arm type such as r7g.2xlarge (8 vCPUs, 64 GiB). Confirm its specs with describe-instance-types and its presence in the AZ with describe-instance-type-offerings using --location-type availability-zone and a filter on instance-type.
Exercise
Your t3.micro web server is slow every afternoon. CPUCreditBalance is near zero and the instance is in standard credit mode. What are two ways to fix it, and what does each cost?
Show answer
Switch to unlimited credit mode, which keeps full CPU but bills for surplus credits. Or stop the instance and resize it to a larger type, such as t3.small or an m-family type, which raises the baseline or removes throttling at a higher hourly price. If the load is steady, a fixed-performance type is usually cheaper than paying for surplus credits.