Master stress‑ng: Install, Configure, and Run Comprehensive Linux Stress Tests
This guide walks you through installing stress‑ng on CentOS 7 (via yum or source), compiling it, verifying the installation, explains its command‑line syntax and common options, and provides ready‑to‑use examples for CPU, memory, I/O, and disk stress testing with monitoring tips.
What is stress‑ng?
stress‑ng is a powerful Linux stress‑testing utility that can generate load on various system resources such as CPU, memory, disk I/O, network, processes, and file systems. It offers many configurable stressors, making it suitable for performance benchmarking and reliability testing.
Installation
Two installation methods are supported on CentOS 7:
1. yum installation (not the latest version)
yum install -y epel-release.noarch && yum -y update
yum -y install stress stress-ng2. Build from source (recommended for the newest version)
Download the latest source package, extract it, compile, and install:
wget https://fossies.org/linux/privat/stress-ng-0.16.03.tar.gz
tar -xzf stress-ng-0.16.03.tar.gz
cd stress-ng-0.16.03
make && make installAfter compilation, verify the installation: stress-ng -V Typical output:
stress-ng, version 0.16.03 (gcc 4.8.5, x86_64 Linux 3.10.0-957.el7.x86_64)Command syntax and common options
The basic syntax is: stress-ng [OPTION [ARG]] Key options include: -h, --help: display help --version: show version -t, --timeout seconds : stop after the given time -c, --cpu n : launch n CPU workers (e.g., --cpu 4) -i, --io n : launch n I/O workers -m, --vm n : launch n memory workers -d, --hdd n : launch n workers that perform write/unlink operations --cpu-method method : choose a specific CPU stress method (e.g., matrixprod) --vm-bytes size : amount of memory each VM worker allocates (default 256M) --cpu-load percent : set target CPU load percentage --hdd-bytes size : size of each write operation --class name : run a predefined class of tests
Practical stress‑testing scenarios
1. CPU load test
Run four CPU workers using the matrix multiplication method for 600 seconds:
stress-ng --cpu 4 --cpu-method matrixprod --timeout 600sMonitor the impact with top before and during the test (screenshots omitted for brevity).
2. Memory load test
Allocate 512 MiB per worker with four workers, keep the allocation for 600 seconds: stress-ng --vm 4 --vm-bytes 512M --timeout 600s Check memory usage with free and top before and during the test.
3. I/O load test
Generate four I/O workers for 600 seconds: stress-ng --io 4 --timeout 600s Observe system load via top or a Prometheus dashboard.
4. Disk write test
Use one write worker that writes 1000 MiB blocks with four I/O workers for 600 seconds:
stress-ng --io 4 --hdd 1 --hdd-bytes 1000M --timeout 600s5. Combined CPU and I/O test
Run four CPU workers and two I/O workers for 600 seconds:
stress-ng --cpu 4 -i 2 --timeout 600s6. Adjustable CPU load
Run four CPU workers targeting a 60 % load for 600 seconds:
stress-ng --cpu 4 --cpu-load 60 --timeout 600sConclusion
stress‑ng provides a rich set of options for generating realistic load on Linux systems. By installing it (preferably from source for the latest features) and using the examples above, you can quickly create reproducible stress‑testing scenarios for CPU, memory, I/O, and disk subsystems, and verify system behavior with standard monitoring tools.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
