Sub topic 5
Choosing an instance family and size
This chapter assumes you can read CloudWatch utilization data, which the earlier chapters covered. It also assumes you know what an instance type is and how to run the AWS CLI. The goal is to pick the family and size that fit a workload's profile, using the data you already collected.
How instance type names work
An instance type name has four parts. Take m7g.xlarge:
mis the family. It tells you the CPU-to-memory balance.7is the generation. Newer generations usually give better price-performance.gis an attribute. Here it means a Graviton processor.xlargeis the size. Each step up roughly doubles vCPUs and memory.
Other common attribute letters are a for AMD, i for Intel, d for local NVMe storage, n for enhanced networking, and e for extra memory or storage.
Match the family to the bottleneck
Your utilization data shows which resource limits the workload. Choose the family built around that resource.
| Family | Focus | Memory per vCPU | Typical workloads |
|---|---|---|---|
| M (general purpose) | Balanced | about 4 GiB | Web apps, app servers, small databases |
| C (compute optimized) | CPU | about 2 GiB | Batch jobs, encoding, game servers, high-traffic web tiers |
| R (memory optimized) | Memory | about 8 GiB | In-memory caches, analytics, large databases |
| T (burstable) | Baseline plus credits | varies | Dev/test, low-traffic sites with occasional spikes |
| I (storage optimized) | Local disk I/O | varies | NoSQL stores, data warehouses |
Use the ratio to read your data. A workload at 15% CPU and 80% memory is paying for CPU it never uses, so it belongs on R, not M. A workload at 70% CPU and 25% memory fits C better than M.
Be careful with burstable instances
T-family instances earn CPU credits while below their baseline and spend them when busy. They suit workloads that are idle most of the time. They fit poorly when CPU stays high, because the instance either throttles or, in unlimited mode, charges for surplus credits. Check CPUCreditBalance in CloudWatch before you move a workload onto or off a T type.
Choose the size
Pick the smallest size that keeps the workload within its headroom target at peak. A common starting point is peak CPU (p95 or p99) below roughly 60 to 70%, though your own latency requirements decide the number.
Check more than CPU:
- Memory. CloudWatch does not report memory by default. Install the CloudWatch agent to collect it.
- Network and EBS bandwidth. Small sizes have lower baseline limits. A smaller instance can pass the CPU check and still throttle on network or disk.
- Instance limits. Some sizes cap the number of ENIs and attached volumes.
Moving down one size halves the capacity and the price. Move one step at a time and re-measure.
Compare candidates with the CLI
You can compare vCPU, memory, and network specs before you decide. This command lists the candidates side by side:
aws ec2 describe-instance-types \
--instance-types m7i.xlarge m7g.xlarge c7g.xlarge r7g.xlarge \
--query 'InstanceTypes[].[InstanceType,VCpuInfo.DefaultVCpus,MemoryInfo.SizeInMiB,NetworkInfo.NetworkPerformance]' \
--output tableTo see which current-generation types run on Arm64, which includes the Graviton families, run this:
aws ec2 describe-instance-types \
--filters Name=processor-info.supported-architecture,Values=arm64 Name=current-generation,Values=true \
--query 'InstanceTypes[].InstanceType' \
--output textPrices vary by Region, so check the pricing page or the Pricing API for the Region you use. Do not assume a price ratio from another Region.
A worked example
A service runs on m6i.2xlarge (8 vCPUs, 32 GiB). Two weeks of data show:
- CPU: average 12%, p99 28%
- Memory: p99 41%, about 13 GiB used
- Network: well below the limit
Memory use of 13 GiB means a 16 GiB instance would hold it with little headroom, and 32 GiB is excessive. CPU use is low as well. A reasonable candidate is m6i.xlarge (4 vCPUs, 16 GiB), which would put peak CPU near 56% and memory near 82%. Memory headroom is thin, so test r-family or a size with more memory only if the load test shows pressure. The same candidate on a newer generation or on Graviton, covered in later chapters, can lower the price further.
Common errors
- Choosing by vCPU count alone and ignoring the memory ratio.
- Staying on an old generation. A newer generation at the same size often costs the same or less and performs better.
- Downsizing a T instance without checking credit balance.
- Skipping the network and EBS limits for the new size.
Exercise
A database server shows 20% average CPU, 35% peak CPU, and 85% peak memory use on an m6i.2xlarge. Which family would you test next, and why?
Show answer
Test an R-family instance, such as r6i.xlarge or a newer generation. Memory is the limiting resource, and CPU is low. R types give about 8 GiB per vCPU, so you can halve the vCPUs and keep or increase memory. Confirm with a load test.
Exercise
Why can a smaller instance pass your CPU headroom check and still perform worse?
Show answer
Network bandwidth, EBS bandwidth, and memory also scale with size. A smaller instance can throttle on those limits even when CPU is low.