Many people designing and building solutions on AWS have trouble choosing the right EC2 placement strategy that best fits their specific needs or use cases. In this article, we are going to explore what placement groups are all about, the different types of placement groups that AWS offers to its users, choosing the right placement group for your use case, and some placement group limitations and rules. Let's begin!
When you launch a new EC2 instance, the EC2 service attempts to place the instance in such a way that all of your instances are spread out across underlying hardware to minimize correlated failures. Sometimes for performance or compliance reasons, you might want to control how these instances are placed on AWS' infrastructure. To achieve this control, you have to employ one of AWS' placement strategies to create a placement group. A placement group is a logical grouping of instances within an Availability Zone that helps you to influence the placement of individual EC2 instances to meet specific requirements for performance, latency, or compliance. To create a placement group, there are three placement strategies you can make use of. The strategies are, Cluster, Spread and Partition. Now let's look at the different types of placement groups we can create using these strategies.
A cluster placement group is a logical grouping of instances within a single Availability Zone. They are designed to offer a 10Gbps bandwidth between instances in the placement group making it a good fit for applications that require extremely low latency and high network throughput communication between instances. When you create a cluster placement group, AWS tries to place the instances as close together as possible within the same rack or network switch. This proximity helps to reduce network latency and enables faster communication between the instances. The following image shows instances that are placed into a cluster placement group.
With Cluster Placement Groups, if the rack fails, all instances fail at the same time. This makes Cluster Placement Groups not suitable for critical applications. Some common use cases for cluster placement groups are High-Performance Computing (HPC), Big Data Processing, Real-Time Analytics, Database Clustering, High-Performance Web Applications, and Content Delivery Networks (CDNs). Some rules and limitations that apply to cluster placement groups are.
- A cluster placement group can’t span multiple Availability Zones.
- Not all instance types are supported in cluster placement groups. You should refer to the AWS documentation to determine the supported instance types for cluster placement groups.
- Each placement group must have a unique name within your AWS account and the corresponding Availability Zone.
- Cluster placement groups do not provide capacity reservations. You still need to ensure that sufficient capacity is available in the chosen Availability Zone to accommodate your instances.
A spread placement group is a logical grouping of instances that allows you to place instances on distinct hardware to reduce the risk of simultaneous failures that might occur when instances share the same equipment. When you launch instances in a spread placement group, AWS ensures that the instances are placed on distinct underlying hardware appliances. This helps to provide high availability and fault tolerance for your applications. This type of placement group is recommended for applications that have a small number of critical instances that should be kept separate from each other. Spread 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. 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.
Some typical use cases for spread placement groups are High Availability Architecture, Disaster Recovery, Batch Processing, Data Processing Clusters, and Critical Applications. Spread Placement groups have the following rules and limitations.
- Spread placement groups are not supported for Dedicated Instances.
- Host-level spread placement groups are only supported for placement groups on AWS Outposts. There are no restrictions on the number of running instances with host-level spread placement groups.
- A rack spread placement group supports a maximum of seven running instances per Availability Zone. For example, in a Region with three Availability Zones, you can run a total of 21 instances in the group, with seven instances in each Availability Zone. If you try to start an eighth instance in the same Availability Zone and the same spread placement group, the instance will not launch. If you need more than seven instances in an Availability Zone, AWS recommends that you use multiple spread placement groups. Using multiple spread placement groups does not provide guarantees about the spread of instances between groups, but it does help ensure the spread for each group, thus limiting the impact from certain classes of failures. -Data transfer between instances in a spread placement group and instances outside the group may incur additional data transfer charges.
They reduce the likelihood of correlated hardware failures for your application by launching instances in different partitions. When using partition placement groups, Amazon EC2 divides each group into logical segments called partitions. Amazon EC2 ensures that each partition within a placement group has its own set of racks. Each rack has its own network and power source. No two partitions within a placement group share the same racks, allowing you to isolate the impact of a hardware failure within your application. 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 has 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.
Partition placement groups can have partitions in multiple Availability Zones in the same Region. They 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. Partition placement groups can be used to deploy large distributed and replicated workloads, such as HDFS, HBase, and Cassandra, across distinct racks. Below are some partition placement group-specific rules and limitations.
- Partition placement group names must be unique within a region and must follow a specific naming convention. The name must be a combination of upper and lower case letters, numbers, and hyphens, and must start with a letter and be no longer than 255 characters.
- A partition placement group supports a maximum of seven partitions per Availability Zone. The number of instances that you can launch in a partition placement group is limited only by your account limits.
- A partition placement group’s capacity cannot be reserved using capacity reservations. A partition placement group’s capacity is not reserved by capacity reservations.
- A partition placement group with Dedicated Instances can have a maximum of two partitions.
- When instances are launched into a partition placement group, Amazon EC2 tries to evenly distribute the instances across all partitions. Amazon EC2 doesn’t guarantee an even distribution of instances across all partitions.
Now that we have talked about the various placement groups in detail and have also seen the rules and limitations that exist on them, let’s go on to look at general placement group rules and limitations i.e. the rules and limitations that you need to be aware of before using any placement group.
- You can create a maximum of 500 placement groups per account in each Region.
- You can’t merge placement groups.
- An instance cannot be launched in more than one placement group at a time.
- You cannot launch Dedicated Hosts in placement groups.
- The name that you specify for a placement group must be unique within your AWS account for the Region.
Placement groups are a valuable tool for building high-performance solutions on AWS. By leveraging the power of proximity and control over the placement of instances, placement groups enable you to optimize network latency and enhance inter-instance communication. Whether you need to create tightly-coupled clusters, distribute instances across distinct hardware, or achieve better performance for latency-sensitive workloads, placement groups provide the flexibility and control necessary to meet your specific requirements. By harnessing the capabilities of placement groups, you can unlock the full potential of your EC2 instances and build more performant solutions that deliver superb operational efficiency and reliability.