How to Test CPU and Memory Load with Stress & Stress-ng
In this article, I’ll install Stress on Linux machine and test CPU and memory load with Stress. Let’s get started:
Table of Contents
Install Stress
Run this command to install Stress-ng (updated version of Stress):
# CentOS/RHEL 8
sudo dnf install stress-ng -y
# CentOS/REHL 7/Amazon Linux
sudo yum install stress-ng -y
# Debian/Ubuntu
sudo apt install stress-ng -y
Run this command to install Stress on your machine:
# CentOS/RHEL 8
sudo dnf install stress -y
# CentOS/REHL 7/Amazon Linux
sudo yum install stress -y
# Debian/Ubuntu
sudo apt install stress -y
Now run this command to see all available options:
stress-ng --help
# stress
stress --help
Run Stress
Stress using CPU-bound task:
stress-ng --cpu 4 -t 30s
# with stress
stress --cpu 4 -t 30s
#or
stress -c 4 -t 30s
Stress using IO-bound task:
stress-ng -i 4 -t 60s
# with stress
stress -i 4 -t 60s
We can run all of these tests in parallel by running the command below:
stress-ng --cpu 2 --all -t 120s
Give load using two CPU-bound processes, one I/O-bound process, and one memory allocator:
stress-ng -c 2 -i 1 -m 1 --vm-bytes 128M -t 20s
Watch Load Average
We can see the avegare load using these commands:
uptime
# or
watch uptime
# or
top
htop is another awesome tool to monitor loads:
# install htop
sudo yum install htop -y # CentOS/RHEL
sudo apt install htop -y # Debian/Ubuntu
# then run
htop
Note
If you run stress for a long time, you should reboot the system before making it live.
sudo reboot
That’s all. Thank you. ?
Comment
Preview may take a few seconds to load.
Markdown Basics
Below you will find some common used markdown syntax. For a deeper dive in Markdown check out this Cheat Sheet
Bold & Italic
Italics *asterisks*
Bold **double asterisks**
Code
Inline Code
`backtick`Code Block```
Three back ticks and then enter your code blocks here.
```
Headers
# This is a Heading 1
## This is a Heading 2
### This is a Heading 3
Quotes
> type a greater than sign and start typing your quote.
Links
You can add links by adding text inside of [] and the link inside of (), like so:
Lists
To add a numbered list you can simply start with a number and a ., like so:
1. The first item in my list
For an unordered list, you can add a dash -, like so:
- The start of my list
Images
You can add images by selecting the image icon, which will upload and add an image to the editor, or you can manually add the image by adding an exclamation !, followed by the alt text inside of [], and the image URL inside of (), like so:
Dividers
To add a divider you can add three dashes or three asterisks:
--- or ***

Comments (0)