What are EC2 placement groups and what are the three strategies?
A placement group controls how instances sit on physical hardware. Cluster packs them close for low latency, spread puts each on separate hardware to limit correlated failure, and partition groups them in racks that do not share hardware.
Explain it simply
Imagine seating a cricket team on a bus. Sitting everyone in the front rows (cluster) lets them talk quickly but one problem in that area affects all. Scattering them across the bus (spread) means one bad seat hurts only one player. Partition is a few small clusters, each separate from the others.
Example
Cluster : instances in one AZ, same rack area
use: HPC, tightly coupled jobs needing low latency and high throughput
risk: a hardware fault can hit several instances
Spread : each instance on distinct hardware
use: a few critical instances (limit of 7 running per AZ per group)
Partition : instances split into partitions (racks); partitions do not share hardware
use: large distributed systems such as Hadoop, Cassandra, KafkaYou choose a strategy when creating the group and then launch instances into it. Cluster groups work best when you launch all instances together with one instance type, otherwise capacity errors are more likely. Placement groups are free, but they do not help for ordinary web apps that are already spread across Availability Zones.
What to say in the interview
"Cluster gives low latency in one AZ, spread isolates a handful of critical instances on separate hardware, and partition spreads big distributed systems across independent racks. For normal web workloads I rely on multiple AZs behind a load balancer instead."
Common mistakes
- Using cluster placement for a service that needs high availability.