How to stress test CPU/Memory/FS in Linux (using stress/stress-ng)

Hardware (CPU/memory/fs) stress testing is intended to make a machine work hard and trip hardware issues such as thermal overruns as well as operating system bugs that only occur when a system is being thrashed hard. Its not intended to do benchmarking.

  • stress@man is a tool to impose load on and stress test systems.
## install
$ sudo apt-get install stress | sudo yum install stress (EPEL)

## using
stress [OPTION [ARG]] ...
'-n,--dry-run' show what would have been done
'-t,--timeout N' timeout after N seconds

'-c,--cpu N' spawn N workers spinning on sqrt()

'-m,--vm N' spawn N workers spinning on malloc()/free()
'--vm-bytes B' malloc B bytes per vm worker (default is 256MB)

'-i,--io N' spawn N workers spinning on sync()
'-d, --hdd N' spawn N workers spinning on write()/unlink()
'--hdd-bytes B' write B bytes per hdd worker (default is 1GB)

## examples
# stress using cpu-bound task
$ stress -c 2
# stress using 2 cpu-bound processes, 1 io-bound procss and 1 memmory allocator process
$ stress -c 2 -i 1 -m 1 --vm-bytes 128M -t 10s

$ top,uptime,tload

from stress@cyberciti

  • stress-ng updated version of stress tool that includes CPU compute, Cache thrashing, Drive stress, I/O syncs, VM stress, Socket stressing, Context switching, Process creation and termination
## install
# note: ubuntu repo is too old, compile from source instead
$ wget ; tar zxf stress-ng*.tar.gz ; cd stress-ng* ; make

## usage
stress-ng [OPTION [ARG]] ...
'-metrics-brief' enable metrics and only show non-zero results
'--random N' start N random workers
'--sequential N' run all stressors one by one, invoking N of them

'-c,--cpu N' start N workers spinning on sqrt(rand())
'--cpu-method m' specify stress cpu method m, default is 'all'
'--cpu-ops N' stop when N cpu bogo operations completed

## examples (run as root to avoid stressors being killed)
# run for 60s with 4 cpu-bound, 2 io stressors and 1 vm stressor using 1G of vm
$ stress-ng --cpu 4 --io 2 --vm 1 --vm-bytes 1G --timeout 60s --metrics-brief
# run for 5m strssing all CPUs using fft
$ stress-ng --cpu 0 --cpu-method fft -t 5m --times
# runs 4 simultaneous instances of all stressors sequencially, each for 6 mins
$ stress-ng --sequential 4 --timeout 6m --metrics
# run 2 fft cpu stressors, and after 5000 ops
$ stress-ng --cpu 2 --cpu-method fft --cpu-ops 5000 --metrics−brief
# stress all cpus using all methods for 2h
$ stress−ng --cpu 0 --cpu-method all -t 2h
# run 128 stressors randomly chosen
$ stress-ng --random 128
# run all stressors one by one for 5mins, one stressor instance for each cpu
$ stress-ng --sequential 0 -t 5m
# run all io stressors one by one for 1m each, w/ instances 8 concurrently
$ stress-ng --sequential 8 --class io -t 1m --times

from stress@cyberciti


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s