EC2 instance types, AMIs, storage & placement groups
Choose an instance family and placement for a workload.
By Invicly Tech, , in AWS Solutions Architect – Associate. About 12 minutes to read.
In short
EC2 provides virtual servers in families tuned for general, compute, memory, storage or accelerated workloads. AMIs capture the OS and software you launch from, and placement groups control how instances are spread across hardware. Choosing the right family and size is a frequent exam scenario.
Explained simply
EC2 (Elastic Compute Cloud) rents you virtual servers, called instances, by the second. You pick how much CPU, memory, storage and network the server has by choosing an instance type, and you pick what software it starts with by choosing an AMI (Amazon Machine Image).
Instance types come in families built for different jobs. General purpose types balance everything. Compute optimized types have more CPU for each GB of memory. Memory optimized types have lots of RAM for databases and caches. Storage optimized types have very fast local disks. Accelerated types add GPUs or AI chips.
An AMI is a template: an operating system plus whatever you installed, frozen into an image. Build your app server once, save it as an AMI, and every new instance boots ready to work in a minute or two, instead of installing everything from scratch.
Storage and placement matter too. Most instances keep their disks on EBS, network drives that survive a reboot or stop. Some also have instance store, very fast disks inside the host that are wiped when the instance stops. Placement groups decide whether instances sit close together for speed or far apart for safety.
Press Play on a diagram to walk through it one step at a time.
- General purpose
- M, T (burstable)
- Web and app servers
- Compute optimized
- C family
- Batch, HPC, gaming
- Memory optimized
- R, X families
- In-memory DBs, caches
- Storage optimized
- I, D families
- High local IOPS, NoSQL
- Accelerated computing
- P, G, Trn, Inf
- ML training, graphics
- Packed in one AZ
- Lowest latency, high throughput
- HPC and tightly coupled jobs
- Shared hardware failure risk
- Each instance on distinct racks
- Max 7 instances per AZ
- Critical small groups
- Can span AZs
- Partitions on separate racks
- Up to 7 per AZ
- Hadoop, Cassandra, Kafka
- Hundreds of instances
- 1Pending
Booting; billing starts when running.
- 2Running
Billed per second (Linux, 60 s minimum).
- 3Stopping
Instance store data is lost.
- 4Stopped
No compute charge; EBS still billed.
- 5Start again
Often on a new host, new public IP.
- Back to step 1
In depth
Reading an instance type name
A name like m7gd.2xlarge packs in a lot. The first letter is the family: m general purpose, c compute, r memory, i storage, p and g GPU, and so on. The number is the generation; newer generations usually give better price-performance, so prefer them. Letters after the number are attributes: g means AWS Graviton (Arm) processors, i Intel, a AMD, d local NVMe instance store, n extra network bandwidth, e extra memory or storage, and z high CPU frequency.
After the dot comes the size. Each step up roughly doubles vCPUs and memory: an m7g.large has 2 vCPUs and 8 GiB, xlarge has 4 and 16, 2xlarge has 8 and 32. Metal sizes give you the whole physical server.
Graviton instances are often about 20 percent cheaper than comparable x86 instances. Most Linux software, containers and managed runtimes work on Arm without changes.
- 1m
Family: general purpose.
- 27
Generation: seventh.
- 3g
Processor: AWS Graviton (Arm).
- 4d
Extra: local NVMe instance store.
- 52xlarge
Size: 8 vCPUs and 32 GiB memory.
Burstable T instances and CPU credits
T instances, such as t3.micro or t4g.small, are cheap because they expect low average CPU use. Each size has a baseline, for example 10 percent per vCPU for a t3.micro. Running below the baseline earns CPU credits; running above it spends them. That suits web servers, dev boxes and small databases that are idle most of the time and busy in short bursts.
In standard mode, an instance that runs out of credits is held to its baseline, which can feel like the server froze. In unlimited mode, the default for T3 and T4g, it keeps bursting, and you pay a small charge if average usage over 24 hours stays above the baseline.
The rule of thumb: if CPU is regularly high, a T instance in unlimited mode ends up costing more than an M instance. Watch the CPUCreditBalance and CPUSurplusCreditsCharged metrics in CloudWatch.
AMIs: build, copy, share
An AMI is a set of EBS snapshots (one per volume) plus a block device mapping and launch permissions. create-image reboots the instance by default so the file system is consistent; --no-reboot avoids downtime but risks an inconsistent image.
AMIs are Regional. To launch in another Region, copy the AMI there with copy-image. To share, add launch permissions for specific account IDs, or for an organization or OU ARN. Sharing an encrypted AMI also requires sharing its customer managed KMS key; AMIs encrypted with the AWS managed EBS key cannot be shared.
Mature teams use a golden AMI pipeline: start from a current base image, install and harden software, run tests, then distribute to Regions and accounts. EC2 Image Builder automates this on a schedule. Deprecate old AMIs so nobody launches outdated, unpatched images, and turn on deregistration protection for important ones.
- 1Base image
Latest Amazon Linux or Ubuntu AMI.
- 2Build
Install agents, app runtime and patches.
- 3Harden and test
CIS settings, scans, smoke tests.
- 4Distribute
Copy to Regions, share with accounts.
- 5Use
Launch templates point at the new AMI.
EBS versus instance store
EBS volumes are network-attached block storage. They live in one AZ, persist independently of the instance, can be detached and reattached, and are backed up with incremental snapshots stored in S3. gp3 is the default general purpose type, with a baseline of 3,000 IOPS and 125 MiB/s whatever its size, and you can buy more performance separately. io2 Block Express serves the most demanding databases, while st1 and sc1 are cheap hard disk types for large sequential data.
Instance store is NVMe storage physically attached to the host. It is very fast and included in the instance price, but its data is lost when the instance stops, hibernates or terminates, or when the host fails. A reboot keeps it.
Use instance store for caches, scratch space and data that is replicated elsewhere, such as Cassandra or Kafka nodes. Note that the root EBS volume is deleted on termination by default, while extra volumes are kept.
- Network-attached, one AZ
- Survives stop and terminate (if kept)
- Snapshots to S3
- Billed per GB and performance
- Physically attached NVMe
- Lost on stop, terminate or host failure
- No snapshots
- Included in instance price
Placement groups and fast networking
A cluster placement group packs instances close together in one AZ. Within it, a single network flow can reach up to 10 Gbps instead of 5 Gbps, with the lowest latency. Use the same instance type and launch all instances in one request, or you may hit insufficient capacity errors. For tightly coupled HPC jobs, add the Elastic Fabric Adapter (EFA), which lets MPI traffic bypass the operating system.
A spread placement group puts each instance on distinct hardware racks, up to seven running instances per AZ per group. It suits a handful of critical instances, such as primary and standby nodes.
A partition placement group divides instances into up to seven partitions per AZ, each on its own racks, with many instances per partition. Instances can read their partition number from instance metadata, so systems like HDFS, Kafka and Cassandra can place replicas in different partitions.
- Cluster: one AZ, lowest latency, shared failure risk
- Spread: max 7 running instances per AZ per group
- Partition: up to 7 partitions per AZ, many instances each
- A stopped instance can be moved into a group
Learn it in 4 short steps
About 1h each. Track them with a timer in your plan.
- 1Compare instance families and sizes~1h
- 2Build and share a custom AMI~1h
- 3Choose EBS-backed or instance store storage~1h
- 4Pick cluster, spread or partition placement groups~1h
Key points
- Graviton (g suffix) instances usually give better price-performance for supported workloads.
- AMIs are Regional; copy an AMI to launch it in another Region.
- Instance store is fast but ephemeral; data is lost on stop or hardware failure.
- Hibernate saves RAM to an encrypted EBS root volume for fast resume.
Key terms
Tap a card to flip it. 0/5 known
Examples
aws ec2 run-instances \
--image-id ami-0abcdef1234567890 \
--instance-type t3.micro \
--subnet-id subnet-0pub1 \
--security-group-ids sg-0web \
--iam-instance-profile Name=web-role \
--user-data file://bootstrap.sh \
--tag-specifications "ResourceType=instance,Tags=[{Key=Name,Value=web}]"Launch a tagged instance with a role and boot script.
Picking families for four workloads
Step 1, a company website with low average CPU: t4g.medium, burstable and cheap. Step 2, nightly video encoding that can be restarted: compute optimized c7g or c7i, bought as Spot to save money. Step 3, a self-managed in-memory cache needing 400 GB of RAM: memory optimized r7g.16xlarge (512 GiB). Step 4, a Cassandra cluster with heavy local I/O: storage optimized i4i instances with NVMe instance store, in a partition placement group, with replication factor 3 so losing a node or a rack loses no data. In each case, read the requirement (CPU, memory, disk, or cost) and map it to the family letter first, then size it.
Building and sharing a golden AMI
Step 1: create an AMI from a configured instance and wait until it is available. Step 2: copy it to eu-west-1, because AMIs are Regional. Step 3: share both copies with the production account. Step 4: update the production launch template to the new AMI IDs. If the volumes are encrypted with a customer managed key, also allow the production account to use that key, or launches there will fail.
AMI=$(aws ec2 create-image --instance-id i-0abc1234 \
--name "web-2026-11-10" --query ImageId --output text)
aws ec2 wait image-available --image-ids $AMI
EU_AMI=$(aws ec2 copy-image --source-image-id $AMI \
--source-region us-east-1 --region eu-west-1 \
--name "web-2026-11-10" --query ImageId --output text)
aws ec2 modify-image-attribute --image-id $AMI \
--launch-permission "Add=[{UserId=222233334444}]"Quick reference
- Type name: family + generation + attributes . size, e.g. c7gn.xlarge
- g = Graviton, a = AMD, i = Intel, d = local NVMe, n = more network, e = more memory
- Each size step roughly doubles vCPUs and memory
- T instances: baseline plus credits; unlimited mode charges for sustained bursting
- AMIs are Regional: copy-image to use one in another Region
- gp3 baseline: 3,000 IOPS and 125 MiB/s at any size
- Instance store survives reboot but not stop, hibernate, terminate or host failure
- Spread placement group: at most 7 running instances per AZ
Common mistakes
- Using a cluster placement group for high availability; it is one AZ.
- Running a database on instance store without replication.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Compare vCPUs and memory for m7g.large, c7g.large and r7g.large with one CLI command.
- Exercise 2medium
Create a partition placement group with 3 partitions and launch two instances into partition 1.
- Exercise 3hard
On an instance, read its role credentials path using IMDSv2, then require IMDSv2 on that instance so the older, token-less method stops working.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- What is the difference between stopping and terminating an instance?
- Stopping shuts it down but keeps its EBS volumes, so you can start it again later. Terminating deletes the instance, and by default its root volume too.
- Should I use Graviton instances?
- Usually yes for new Linux workloads. They often give better price-performance, but check that every binary and library you use has an Arm64 build.
- Why did my instance get a new public IP after a restart?
- Auto-assigned public IPv4 addresses are released on stop. Use an Elastic IP, or better, a load balancer or DNS name, if the address must stay the same.
- What is hibernation?
- Hibernate saves the instance's RAM to its encrypted EBS root volume and restores it on start, so long-running processes resume where they left off.