How to quickly stress test CPU on Amazon Linux

Download and install the stress test tool

sudo amazon-linux-extras install epel -y
sudo yum install stress -y

Launch the stress test in background (for 800 seconds in that example)

sudo stress --cpu 8 --timeout 800 &

Check the stress test processes with the top command

top

Result for the top command

Manually stop the stress test (if needed)

sudo killall stress

Check the EC2 CPU metric in Clouwatch
(protip, enable detailed monitoring)

Cloudwatch metrics for the CPU

Why does my CPU stress test stop after a few minutes ?

→ Probably because your a using a “t” based instance (such as t2, t3).
https://stackoverflow.com/questions/61920470/aws-cloudwatch-cpu-utilization-doesnt-match-actual-usage

Thank you

--

--

This is my personal blog where I post (in my spare time) computer science “cheatsheets”. I mainly do it for myself but it may benefit others.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Greg

This is my personal blog where I post (in my spare time) computer science “cheatsheets”. I mainly do it for myself but it may benefit others.