'How to increase AWS EC2 instance CPU utilization to 100% to test autoscaling group creating new instances?
I need to test autoscaling group creating new instances when CPU utilization cross certain threshold for example 70%.
Is there any way to up the CPU utilization just to test?
Solution 1:[1]
If you are testing a web based application, I recommend you try Bees With Machine Guns.
Its a python script that will launch micro EC2 instances and send many web requests from these instances to your application. This will simulate a large surge in traffic for performance testing.
Note the caveat at the bottom of the page that says:
If you decide to use the Bees, please keep in mind the following important caveat: they are, more-or-less a distributed denial-of-service attack in a fancy package and, therefore, if you point them at any server you don’t own you will behaving unethically, have your Amazon Web Services account locked-out, and be liable in a court of law for any downtime you cause.
You have been warned.
Solution 2:[2]
You can use stress command in Linux:
stress --cpu 2 --timeout 60
cpu specifies the number of cores, timeout specifies the number of seconds this command will run.
For Windows: Install Windows Server 2003 Resource Toolkit. Then run this command in cmd:
consume -cpu-time -time 5
Solution 3:[3]
Another way to bring CPU utilization up on Posix systems is to use the stress command. Stress generates CPU, memory, I/O or disk workload depending on your configuration.
An example answer here shows how to use stress to bring the memory of an instance to 90%.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Taterhead |
Solution 2 | Mukarram Khalid |
Solution 3 | Taterhead |