Placement groups
Controlling where EC2 places instances with cluster, spread, partition and precision time placement groups.
What it is
Normally EC2 decides which physical hardware instances run on. A placement group lets the customer influence that, when the placement matters for speed or for resilience. The group is created with a strategy, then launch instances into it.
- Cluster: pack instances close together in one AZ, for the fastest network between them.
- Spread: put each instance on separate hardware, so one hardware failure hits only one instance.
- Partition: split instances into groups (partitions) on separate racks, for large distributed systems.
- Precision time: place instances on hardware with very accurate clocks.
Placement groups are free: only the instances are billed.
The three main strategies
Cluster
All instances sit close together in a single AZ, on the same high-bandwidth part of the network.
- Pros: the lowest latency and highest throughput between instances: up to 10 Gbps per flow with enhanced networking, against 5 Gbps outside a cluster group.
- Cons: if the AZ (or that part of it) fails, all instances fail together.
- Use cases: a big data job that must finish fast, HPC, any app needing very low latency between its nodes.
- Tips: launch all instances in one request, with the same instance type, to avoid insufficient capacity errors. Burstable (T) types aren't supported.
Spread
Each instance runs on distinct hardware (its own rack, with its own network and power).
- Pros: can span multiple AZs; the lowest risk of instances failing at the same time.
- Cons: at most 7 running instances per AZ per group. A Region with three AZs allows 21.
- Use cases: a small number of critical instances that must stay isolated from each other, such as the primary and standby of an app, or a few domain controllers.
Partition
The group is divided into partitions, and each partition has its own set of racks. No two partitions share racks.
- Up to 7 partitions per AZ; can span multiple AZs in the Region.
- Hundreds of instances: the number is limited only by the account's limits.
- A rack failure can affect many instances, but only within one partition.
- Instances can read which partition they're in from instance metadata, so topology-aware software can keep copies of data in different partitions.
- Use cases: large distributed and replicated systems: HDFS, HBase, Cassandra, Kafka.
Precision time
Places instances on hardware with direct access to high-precision time sources.
- Instances get the enhanced Amazon Time Sync Service, more accurate than standard NTP.
- On Linux they also get a PTP hardware clock and hardware packet timestamping, for microsecond-level clock sync.
- Use cases: distributed databases that order transactions by time, financial trade timestamping, event ordering.
- A cluster placement group can name a precision time group as its parent, giving both low latency and accurate clocks.
Updated since the slides
The precision time strategy is new and appears only in the latest version of the slides. Cluster, spread and partition are the three the exam has always tested.
How they compare
- Need speed between instances? Cluster.
- Need a few instances that never fail together? Spread.
- Need hundreds of instances, with failures contained to a slice? Partition.
Exam tips
- "Low latency, high throughput between instances", "HPC", "tightly coupled" → cluster placement group.
- "Critical instances must not share hardware", "maximise availability of a small number of instances" → spread.
- "Hadoop / HDFS / Cassandra / Kafka", "large distributed workload aware of racks" → partition.
- Limits: spread = 7 instances per AZ per group; partition = 7 partitions per AZ; cluster = one AZ.
Common traps
- "Cluster placement group for high availability." It's the opposite: everything is in one place.
- "A spread group with 20 instances in one AZ." The maximum is 7 per AZ; use several groups.
- "A cluster group across AZs." A cluster group is always in a single AZ.
Hands-on lab: create placement groups
Goal: create one of each main placement group and launch an instance into the spread group.
Costs money
Placement groups are free. The one t3.micro launched into the spread group costs about $0.02 an hour with its public IP.
Create three groups
In the EC2 console (us-east-1), open Network & Security → Placement Groups → Create placement group three times:
saa-clusterwith strategy Cluster;saa-spreadwith strategy Spread, spread level Rack;saa-partitionwith strategy Partition and 3 partitions.
Launch into the spread group
Launch instances: name saa-pg, Amazon Linux 2023, t3.micro, key pair saa-lab-key, an existing security group. In Advanced details → Placement group, choose saa-spread. Launch.
Check the placement
Select the instance and open the Details tab: Placement group shows saa-spread. (A t3.micro can't go into saa-cluster: burstable types aren't supported in cluster groups, so that launch would fail.)
Expected result: three placement groups and an instance running in the spread group.
Clean up: terminate saa-pg, wait until it's terminated, then delete the three placement groups (a group can't be deleted while it holds instances).