Choosing EC2 Instance Types and Families
This lesson explains how choosing an EC2 instance type means matching CPU, memory, storage and networking to the workload.
Learning outcomes
After completing this lesson, you will be able to:
- Interpret an instance type name.
- Choose an instance family for a workload.
- Explain burstable instances and other key features.
- Explain how Compute Optimizer supports right-sizing.
Reading an instance name
m7g.xlarge = family m (general purpose), generation 7, option g (Graviton), size xlarge. A d option means local NVMe instance store.
Families
EC2 instance types are grouped into families, each with a different balance of CPU, memory, storage and networking. An instance type name such as m7g.xlarge gives the family (m), the generation (7), optional attributes, here g for a Graviton processor, and the size.
General purpose instances (M, and T, which are burstable and accumulate CPU credits while idle) balance resources and suit web servers and small databases. Compute optimised instances (C) have more CPU per gigabyte of memory, for batch processing, media encoding and game servers. Memory optimised instances (R, X, z and High Memory) have large amounts of memory for in-memory databases and caches. Accelerated computing instances (P, G, Inf, Trn and F) add GPUs or custom chips for machine learning and graphics. Storage optimised instances (I, D and H) have fast local storage for workloads with heavy local I/O, and HPC optimised instances (Hpc) suit tightly coupled simulations. The following table summarises the families.
| Family | Letters | Typical workloads |
|---|---|---|
| General purpose | M, T, Mac | Web servers, small databases |
| Compute optimised | C | Batch, encoding, gaming servers |
| Memory optimised | R, X, z, High Memory | In-memory databases and caches |
| Accelerated computing | P, G, Inf, Trn, F | ML training and inference, graphics |
| Storage optimised | I, D, H | High local I/O |
| HPC optimised | Hpc | Tightly coupled simulations |
Which instance family?
Key features
Several features of EC2 instances affect performance and cost. Burstable T instances earn CPU credits while running below a baseline and spend them during bursts, which suits workloads with low average CPU and occasional peaks; in unlimited mode they can burst indefinitely at extra cost. Graviton instances, based on Arm processors designed by AWS, typically give the best price performance for workloads that support Arm.
Current instances are EBS-optimised by default and use the Elastic Network Adapter, and their network and EBS bandwidth grows with instance size; the Elastic Fabric Adapter (EFA) adds low-latency networking for high-performance computing and machine learning. The Nitro System offloads networking, storage and security functions to dedicated hardware, which enables bare metal instances, EBS Multi-Attach and Nitro Enclaves, isolated environments for processing highly sensitive data.
Instance features
Right-sizing
Start from measured CPU, memory and network. Compute Optimizer recommends types from CloudWatch metrics (memory needs the CloudWatch agent). Newer generations usually give better performance at the same or lower price.
Matching instances to workloads
Each EC2 instance family is designed for a particular type of workload. The following table identifies the family suited to several workloads, with an example instance type.
| Workload | Family | Example |
|---|---|---|
| General web servers | General purpose | m7g (Graviton) for price performance |
| Video transcoding and batch processing | Compute optimised | c7i or c7g |
| In-memory database or large cache | Memory optimised | r7g, x2iedn |
| Machine learning training | Accelerated computing | p5 (GPUs), trn1 (Trainium) |
| NoSQL database needing very fast local disks | Storage optimised | i4i |
| Low, spiky CPU use such as a small internal tool | Burstable | t4g |
After launch, Compute Optimizer recommends whether instances are over- or under-sized based on actual use, and moving supported workloads to Graviton often lowers cost.
Which instance family suits an in-memory database?
Show answer
Memory optimised instances, such as the R and X families, which have a high ratio of memory to vCPU.
Exam Tips
Remember for the exam
- Memory-intensive applications, such as in-memory databases and caches, suit the R or X family.
- Compute-heavy work, such as batch processing, encoding and gaming servers, suits the C family.
- GPUs for ML training or graphics come from the P or G family.
- For the best price performance on compatible workloads, use Graviton.
- To right-size instances from usage, use Compute Optimizer, with the agent installed for memory data.
- For an isolated environment to process highly sensitive data on an instance, use Nitro Enclaves.