Understanding Placement Groups: Optimize Your EC2 Instance Deployment

Omolara Adeboye - Jan 4 - - Dev Community

Placement groups help you to organise your instances. They help to control where your instances are placed in a group of physical servers within an Availability zone in the AWS cloud. There are three types of placement groups:

  • Cluster

  • Partition

  • Spread

Cluster

In the cluster arrangement, instances are packed close together in an Availability zone. This has the advantage of reducing latency because the instances are placed on the same hardware rack in the same AZ. It is recommended for applications that require low latency and high network throughput. The disadvantage of this arrangement is that if an hardware failure occurs, all the instances may be affected as a result of reduced hardware fault tolerance for instances within the group. One common error with launching instances in a cluster is insufficient capacity error. The solution to this is to stop and start all of the instances in the placement group and retry the launch. It is recommended to use a single launch request to launch the number of instances that you need in the placement group. A single launch request means launching the instances in a single API call (launch at once). Also, using the same instance type for all the instances will help to prevent this error.

To create a cluster placement group from the AWS CLI use the following command:

aws ec2 create-placement-group --group-name  --strategy cluster

Partition

In partition placement group, groups of instances are placed in different logical isolations called partitions. Each partition has its own hardware. Instances within a partition share the same hardware but they do not share hardware with groups of instances in another partition. This allows for isolation and minimises hardware failure within your application. It is beneficial for launching large distributed workloads and replicated workloads e.g HDFS, HBase and Cassandra. Partitions can be created accross multiple AZs in the same region.

To create a partition placement group named Phoenix-APP with six partitions from the AWS CLI use the following command:

aws ec2 create-placement-group --group-name Phoenix-APP --strategy partition --partition-count 6

Spread

In spread placement group, EC2 instances are placed accross distinct underlying hardware partitions to reduce the risk of failure by providing isolation. It is especially beneficial for critical applications. Instances can be placed accross racks or hosts. Racks can span accross multiple AZs in the same region. Hosts are applicable to AWS Outpost. In racks, a maximum of 7 instances per availability zone is permitted.

To create a cluster placement group from the AWS CLI use the following command:

aws ec2 create-placement-group --group-name  --strategy spread

Reference:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/placement-groups.html?icmpid=docs_ec2

. .