EC2 Placement Groups

Amazon EC2 (Elastic Compute Cloud) placement groups are a way of influencing how EC2 instances are physically placed with respect to one another. When you launch instances into a placement group, Amazon tries to keep them close together, within the bounds of the specified placement strategy, to achieve specific performance or availability goals.

There are three types of placement groups:

  1. Cluster Placement Groups:

    • Use Case: Suitable for applications that need low network latency, high network throughput, or both, such as high-performance computing (HPC).

    • Behavior: Instances are placed in a single Availability Zone. They are placed close together in the underlying hardware to achieve low latency and high throughput.

    • Consideration: If the required capacity isn't available within a cluster, AWS won't launch the instances. Also, the recommended instance types are Compute Optimized, GPU, Memory Optimized, and Storage Optimized.

  2. Spread Placement Groups:

    Spread level placement groups provide access to distinct hardware, and are therefore suitable for mixing instance types or launching instances over time.

    If you start or launch an instance in a spread placement group and there is insufficient unique hardware to fulfill the request, the request fails. Amazon EC2 makes more distinct hardware available over time, so you can try your request again later. Placement groups can spread instances across racks or hosts. You can use host level spread placement groups only with AWS Outposts.

    • Use Case: Suitable for applications that need to maintain a specific number of fault-tolerant instances. Common for critical applications where each instance should be isolated from failures of other instances.

    • Behavior: AWS distributes the instances across distinct underlying hardware to reduce correlated failures. Each placement group supports a certain number of instances per Availability Zone.

    • Consideration: Suitable for a small number of critical instances. Not designed for achieving network performance benefits like Cluster Placement Groups.

Rack spread level placement groups

The following image shows seven instances in a single Availability Zone that are placed into a spread placement group. The seven instances are placed on seven different racks, each rack has its own network and power source.


    A spread placement group.

A rack spread placement group can span multiple Availability Zones in the same Region. For rack spread level placement groups, you can have a maximum of seven running instances per Availability Zone per group.

Host level spread placement groups

Host spread level placement groups are only available with AWS Outposts. For host spread level placement groups, there are no restrictions for running instances per Outposts. For more information, see Placement groups on AWS Outposts.

  1. Partition Placement Groups:

    The following image is a simple visual representation of a partition placement group in a single Availability Zone. It shows instances that are placed into a partition placement group with three partitions—Partition 1, Partition 2, and Partition 3. Each partition comprises multiple instances. The instances in a partition do not share racks with the instances in the other partitions, allowing you to contain the impact of a single hardware failure to only the associated partition.

    • Use Case: Suitable for distributed and replicated workloads, like Hadoop, Cassandra, and Kafka.

    • Behavior: AWS divides each group into logical segments called partitions. Each partition has its own set of racks, and each rack has its own network and power source. So, instances in one partition do not share the same racks as instances in different partitions, providing fault tolerance.

    • Consideration: You can launch multiple EC2 instances in a single partition. This allows you to have the network performance benefits of cluster placement groups and the fault tolerance of spread placement groups.

    • A partition placement group can have partitions in multiple Availability Zones in the same Region. A partition placement group can have a maximum of seven partitions per Availability Zone. The number of instances that can be launched into a partition placement group is limited only by the limits of your account.

General Points to Note:

  • An EC2 instance can be launched into one placement group at a time.

  • AWS recommends homogenous instances within placement groups. This means using the same instance type for all instances within a placement group.

  • Placement groups are free; you just pay for whatever EC2 instances you launch within them.

  • Moving an existing EC2 instance into a placement group requires you to stop the instance and then start it again.

  • Placement group names must be unique within your AWS account.

In summary, EC2 placement groups are all about controlling the placement of instances for either performance, fault tolerance, or both. The type of placement group you choose depends on your specific application and infrastructure needs.

To create a placement group using the console

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. In the navigation pane, choose Placement Groups, Create placement group.

  3. Specify a name for the group.

  4. Choose the placement strategy for the group. If you choose Partition, choose the number of partitions within the group.

    Choose the placement strategy for the group.

    • If you choose Spread, choose the spread level.

      • Rack - no restrictions

      • Host - only for Outposts

  5. To tag the placement group, choose Add tag, and then enter a key and value. Choose Add tag for each tag that you want to add.

  6. Choose Create group.

To launch instances into a placement group using the console

💡
You can launch an instance into a placement group if the placement group rules and limitations are met
To launch instances into a placement group using the console
  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. From the EC2 console dashboard, in the Launch instance box, choose Launch instance, and then choose Launch instance from the options that appear.

    Complete the form as directed, taking care to do the following:

    • Under Instance type, select an instance type that can be launched into a placement group.

    • In the Summary box, under Number of instances, enter the total number of instances that you need in this placement group, because you might not be able to add instances to the placement group later.

    • Under Advanced details, for Placement group name, you can choose to add the instances to a new or existing placement group. If you choose a placement group with a partition strategy, for Target partition, choose the partition in which to launch the instances.

References

  1. Placement groups