Reputation: 1331
In order to test my AutoScaling group, i wanted to simulate a huge CPU usage so that a new instances will be created (based on metrics that i configured in Cloudwatch : average CPU >= 60)
The EC2 instance is a simple t2.micro and i used the stress command : stress -c 1 -t 400s
I can see in top that the process has started and the CPU is used at 100% but the problem is that it's not constant. Sometimes it dopes to 10% sometimes it's up to 100%, and in cloudwatch monitoring the CPU average usage is under 20% even after 5minutes of stress !
I tried with other arguments (stress -c 2 or stress -c 4) it's the same thing. I also tried with this command : yes > /dev/null &
Cloudwatch always can't see a 100% CPU usage.
What's the problem ? Is there any protection made by Amazon to limit a huge load on the CPU ?
Thanks for your help.
Upvotes: 3
Views: 3949
Reputation: 14905
Tx instances are "burstable performance instances" meaning you can not get 100% CPU all the time. This is the tradeoff in exchange of low hourly price.
CPU is managed by resource credits. Your instance receives CPU credits every minute. Your instance will consume 1 CPU credit for 1 minute usage at 100%. This means when your instance is not fully utilised, it accumulates CPU credits that can be consumed later. When no more credit is available, your CPU will be throttled.
Number of CPU credits and baseline performance depends on the exact instance type.
Details are here : https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/burstable-credits-baseline-concepts.html
Bottom line : do not run CPU base stress test on Tx instance type. These instances type are designed for low/moderate baseline with occasional performance bursts.
Upvotes: 6
Reputation: 3036
According to AWS, t2.micro
is a burstable performance instance. The documentation states:
T2 instances are Burstable Performance Instances that provide a baseline level of CPU performance with the ability to burst above the baseline.
It may be possible you get allocated additional CPU once you reach 100% utilization. Also note these instances are virtual, therefore the vCPU utilization reported cannot always be relied on.
I would advise you to try with a general purpose M5
. With this instance, you should be able to produce the desired behaviour.
Upvotes: 1