Lesson 1 of 6 Amazon EC2

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.

FamilyLettersTypical workloads
General purposeM, T, MacWeb servers, small databases
Compute optimisedCBatch, encoding, gaming servers
Memory optimisedR, X, z, High MemoryIn-memory databases and caches
Accelerated computingP, G, Inf, Trn, FML training and inference, graphics
Storage optimisedI, D, HHigh local I/O
HPC optimisedHpcTightly coupled simulations
Sort into groups

Which instance family?

Exam skills 3.2.3 · 4.2.5

Choose the EC2 family for each workload.

Log in to try this activity Interactive activities are free with an account.

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.

True or false

Instance features

Exam skills 3.2.3 · 4.2.6

Check the key features of EC2 instances.

Log in to try this activity Interactive activities are free with an account.

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.

Worked example

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.

WorkloadFamilyExample
General web serversGeneral purposem7g (Graviton) for price performance
Video transcoding and batch processingCompute optimisedc7i or c7g
In-memory database or large cacheMemory optimisedr7g, x2iedn
Machine learning trainingAccelerated computingp5 (GPUs), trn1 (Trainium)
NoSQL database needing very fast local disksStorage optimisedi4i
Low, spiky CPU use such as a small internal toolBurstablet4g

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.

Check yourself

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.