A placement group is a configuration for the EC2 instances, and this configuration are for the tightly-coupled instances, to archive the maximum throuthput and latency.
We have three types of placement groups, depending of what we need to achieve.
- Cluster – packs instances close together inside an Availability Zone. This strategy enables workloads to achieve the low-latency network performance necessary for tightly-coupled node-to-node communication that is typical of HPC (High performance computing) applications.
- Partition – spreads your instances across logical partitions such that groups of instances in one partition do not share the underlying hardware with groups of instances in different partitions. This strategy is typically used by large distributed and replicated workloads, such as Hadoop, Cassandra, and Kafka.
- Spread – strictly places a small group of instances across distinct underlying hardware to reduce correlated failures.
- An AWS Account
We going to test the placement groups and test the latency first we going to create the placement groups.
- In the AWS Managed Console to go EC2
2. Go to Placement Groups
3. Click on Create placement group
Give it a name, and select the Cluster placement strategy and click on Create group
Repeat this two times and create a Spread placement group
And Partition placement group with 2 partitions
Ok, now we have the three placement groups
4. First lets test creating two instances without any placement group, go to instances
5. Click on Launch instances
6. Select the Amazon Linux 2 AMI 64-bits
7. Select the t2.micro and click on Next: Configure Instance Details
8. Select 2 instances, and select a single subnet, use Auto-assign Public IP and click on Review and launch
9.In the next page, review the information, Click on Launch
10. In the next window, create a new key pair, give it a name and download it, then Launch the instance.
11. Go to View Instances and you will see two instances running
12. Click on each Instance ID, to get the public and private IP
The first have 22.214.171.124 as public IP and as private IP have 172.31.7.193
The second instance have 126.96.36.199 as Public IP and 172.31.3.107 as private IP.
13. Go to back to instances and check the securyt group, you can find it here.
Go to Security Groups and click on the Security group
Click on Edit inbound rules and "Edit inbound rules"
Add rule and add "Custom ICMP - IPv4", Procol "Echo Request", Source Custom, and add 0.0.0.0/0 if you have the CIDR block is better, but for testing 0.0.0.0/0 for now is ok.
Save the rule
13. Lets connect to the first instance with a SSH client and the key pair
14. Make a ping to the second instance
ping -c10 172.31.3.107 PING 172.31.3.107 (172.31.3.107) 56(84) bytes of data. 64 bytes from 172.31.3.107: icmp_seq=1 ttl=255 time=0.605 ms 64 bytes from 172.31.3.107: icmp_seq=2 ttl=255 time=0.460 ms 64 bytes from 172.31.3.107: icmp_seq=3 ttl=255 time=0.394 ms 64 bytes from 172.31.3.107: icmp_seq=4 ttl=255 time=0.394 ms 64 bytes from 172.31.3.107: icmp_seq=5 ttl=255 time=0.478 ms 64 bytes from 172.31.3.107: icmp_seq=6 ttl=255 time=0.484 ms 64 bytes from 172.31.3.107: icmp_seq=7 ttl=255 time=0.513 ms 64 bytes from 172.31.3.107: icmp_seq=8 ttl=255 time=0.396 ms 64 bytes from 172.31.3.107: icmp_seq=9 ttl=255 time=0.390 ms 64 bytes from 172.31.3.107: icmp_seq=10 ttl=255 time=0.419 ms --- 172.31.3.107 ping statistics --- 10 packets transmitted, 10 received, 0% packet loss, time 9198ms rtt min/avg/max/mdev = 0.390/0.453/0.605/0.068 ms
Ok so this, now go to instances select the two instances and click on Instance State and click on Terminate instance
Now let's try to launch two more instances with the three different placement groups.
15. Fist with the Cluster, Click on Launch instances
16. Select the Amazon Linux 2 AMI 64 - bits
17. Select the t2.xlarge and then click on Next
18. On instance details we going to use the same configuration, 2 instances, add the placement group and select the cluster placement group we create earlier.
19. Click next until you have go to the step 6, and select the same Security group with the Echo Request
20. Go to Review and Launch, and after review the configutation, click on Launch
21. In the next window select the same key pair, and click on the check box and launch
22. On EC2 click on the instances ID to get the public IP and private IP
I have 188.8.131.52 as Public IP and 172.31.9.15 as private ip in the first one
And 184.108.40.206 as Public IP and 172.31.0.72 for the second one
23. Connect to the first instance with the key pair.
ssh -i placement-group.pem email@example.com The authenticity of host '220.127.116.11 (18.104.22.168)' can't be established. ECDSA key fingerprint is SHA256:Ue5H+2JhhU3XlauOZFn9gU+ZSJitoaa4aefCt2jGEzo. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '22.214.171.124' (ECDSA) to the list of known hosts. __| __|_ ) _| ( / Amazon Linux 2 AMI ___|\___|___| https://aws.amazon.com/amazon-linux-2/
24. and make a ping to the second instance to the private IP address.
ping -c10 172.31.0.72 PING 172.31.0.72 (172.31.0.72) 56(84) bytes of data. 64 bytes from 172.31.0.72: icmp_seq=1 ttl=255 time=0.557 ms 64 bytes from 172.31.0.72: icmp_seq=2 ttl=255 time=0.450 ms 64 bytes from 172.31.0.72: icmp_seq=3 ttl=255 time=0.324 ms 64 bytes from 172.31.0.72: icmp_seq=4 ttl=255 time=0.366 ms 64 bytes from 172.31.0.72: icmp_seq=5 ttl=255 time=0.389 ms 64 bytes from 172.31.0.72: icmp_seq=6 ttl=255 time=0.800 ms 64 bytes from 172.31.0.72: icmp_seq=7 ttl=255 time=0.342 ms 64 bytes from 172.31.0.72: icmp_seq=8 ttl=255 time=0.386 ms 64 bytes from 172.31.0.72: icmp_seq=9 ttl=255 time=0.355 ms 64 bytes from 172.31.0.72: icmp_seq=10 ttl=255 time=0.344 ms --- 172.31.0.72 ping statistics --- 10 packets transmitted, 10 received, 0% packet loss, time 9222ms rtt min/avg/max/mdev = 0.324/0.431/0.800/0.139 ms
it was a little better than not using the placement groups this, you can test the other placement groups and check for throughput.
With this we conclude the lab, in the next post we going to go deeper into the services of AWS.
- Go to instances and select the running instances and click on instance state and select Terminate instances
2. Go to security groups and click on Actions and select Delete Security group.
3. Go to Placement Groups and select each group and click on Actions and click on Delete