How to produce high CPU load, memory, I/O or stress test Linux server

Overview

There are times when you have to stress test your linux/unix box to see how the proxy, database, memcache or other applications running on top would perform under stress or resource crunch. Enter stress which is a deliberately simple workload generator for POSIX systems. It imposes a configurable amount of CPU, memory, I/O, and disk stress on the system. It is written in C, and is free software licensed under the GPLv2.

How to produce high CPU load, memory, I/O or stress test Linux server

Install some prerequisites
On CentOS/RHEL

# yum install gcc gcc-c++ autoconf automake
On Debian, Ubuntu

$ sudo su -
# apt-get update
# apt-get install build-essential
Download the latest tarball and run configure, make, make install

# wget http://weather.ou.edu/~apw/projects/stress/stress-1.0.4.tar.gz
# tar zxvf stress-1.0.4.tar.gz
# cd stress-1.0.4
# ./configure
# make
# make install
The binary gets installed under /usr/local/bin
To start stress run stress followed by the -c flag for load stress, -m for memory stress, -i for io and -d for HDD. For example to stress cpu execute

# stress -c 5
Execution of the command above will hog all available cpu power and create a load five times a single core would happily handle.
stress01 300x176 How to produce high CPU load, memory, I/O or stress test Linux server
Similarly to stress some memory you can execute

# stress -m 512M
To know about all available flags execute

# stress --help