Home AWS How to Test AWS Auto Scaling Policies using Stress

How to Test AWS Auto Scaling Policies using Stress

by admin

After creating a new auto scaling group recently, I was looking for an easy way to test the auto scaling policies I’d associated with the group. This is just quick post to cover what I did as a quick way to test auto scaling policies. I configured my group to scale up when it breached a 50% usage threshold, then scale down again once usage dropped below that value. One way to test it was working as desired is to use the Stress tool, which can be installed on Linux instances. Note that I was using the micro instances available in the free tier to ensure not to incur any unnecessary costs, whilst testing. Stress can be installed on Linux instances by running:

# yum install stress -y

Once installed, CPU load can be generated using Stress by running:

[root@ip]# stress --cpu 1 --timeout 300
stress: info: [2919] dispatching hogs: 1 cpu, 0 io, 0 vm, 0 hdd

The command above will generate a thread to max out a single CPU core (which is all I need as I was using t2.micro instances), for 300 seconds. Checking Top showed the instance was now running at 100%:

aws-autoscaling

I had configured the alarm/scaling policy to add an additional instance if average CPU was higher than 50% for 5 minutes. After a short while, the alarm triggered and a new instance was provisioned:

aws-auto-scaling

After the 300 hundred seconds were up the Stress process finished it’s run, and CPU usage dropped back to normal levels, leading to Auto Scaling terminating an instance in the group:

aws-auto-scale

All working as expected!

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More