stress test linux server

How to Stress Test Linux Server

Often system administrators need to test the load bearing capabilities of their system to understand its performance limits. There are several tools for this purpose. In this article, we will learn how to stress test Linux server using stress and stress-ng utilities.

How to Stress Test Linux Server

We will use stress and stress-ng for this purpose.

  1. stress – stress is a simple workload generator for Linux. It allows you to exert configurable amount of CPU, memory, disk and I/O stress on the system.
  2. stress-ng is another tool that allows you to run 60+ types of stress tests.

Here is the command to install stress package in Linux.

# RHEL/Fedora/CentOS/SUSE
# sudo yum install stress

# Ubuntu/Debian
$ apt-get install stress 

Here is the syntax for stress command.

# stress [OPTION]

Here are couple of simple commands.

## Stress using CPU-bound task
$ stress -c 4
## Stress using IO-bound task 
$ stress -i 2

Here is another sample command, where we check system uptime before and after running stress command, to see the difference.

# uptime
# stress -c 2 -i 1 -m 1 --vm-bytes 128M -t 10s
# uptime

In the above command,

  • -c 2 : Spawn two workers spinning on sqrt()
  • -i 1 : Spawn one worker spinning on sync()
  • -m 1 : Spawn one worker spinning on malloc()/free()
  • –vm-bytes 128M : Malloc 128MB per vm worker (default is 256MB)
  • -t 10s : Timeout after ten seconds
  • -v : Be verbose

You can also use stress-ng command for this purpose. Here is the command to install it on your system

$ cd /tmp
$ wget

$ tar xvf stress-ng-0.09.34.tar.xz

$ cd stress-ng-0.09.34
$ make

Once you have installed stress-ng command, here is the syntax to run it, with a couple of examples.

# stress-ng [options]

Here is a sample command to exercise the CPU by sequentially working through all the different CPU stress methods:

# uptime
# stress-ng --cpu 4 --timeout 60s --metrics-brief
# uptime

Similarly, you can run the following command to make workers write, read and remove temporary files.

$ stress-ng --disk 2 --timeout 60s --metrics-brief

You can refer to man documentation pages to get information about all available options about stress and stress-ng commands.

In this article, we have learnt how to stress test Linux server using stress and stress-ng tools. This is useful for system administrators to check if their Linux systems can withstand user loads.

Also read:

Schedule Cron Job Every 1 Hour
How to Send Message to Logged User in Linux
How to Delete User Accounts With Home Directory in Linux
How to Update or Change System Locale in Linux
Linux Grep Binary Files for Strings

Leave a Reply

Your email address will not be published.