Testing Auto Scaling groups

The next step is to test the Auto Scaling group; it should add an instance when the CPU utilization is greater than 60% for 5 minutes and remove an EC2 instance if the CPU utilization falls to less than 30% for 20 minutes. The easiest way to test this is to load the CPU for more than 5 minutes and check if an EC2 instance is added. As we have configured the launch configuration to assign a public IP address to an instance, the public IP address of the instance is available from Instances in the EC2 dashboard navigation pane.

Log in to the instance via ssh:

ssh -i ~/.ssh/AWSBook2EdKeyPair.pem [email protected]

To tax the CPU, use bc, which is precision calculator language to compute a value that will take a lot of time. For example, computing 2 to the power of 10 billion here, will push the CPU to 100%:

echo 2^1234567890 | bc

Now, we have set the stage for the auto scaling group to add a new instance whenever the average load is higher than 60% for more than 5 minutes. There are multiples ways to verify that an instance has been added when the scale out alarm is breached.

As we have set a notification with the scale out alarm, an email will be sent to the configured email address with all the alarm details.

A new EC2 instance is added to the Instances view in the EC2 dashboard.

The Auto Scaling Group view in the EC2 dashboard has a tab for Scaling History which displays all the scaling events.

In the same way, we can verify the scale in by the Auto Scaling group, that is, the removal of an EC2 instance when the average CPU utilization of the EC2 instances falls below 30% for a period of 20 minutes. This can be achieved by ending the bc task. The average CPU utilization of the instances will fall below 30% and the scaling in alarm will be breached after a period of 20 minutes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.163.28