Public Repository

Last pushed: 2 years ago
Short Description
Alpine image with Stress
Full Description

Tags & Dockerfile

What is Stress?

stress 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.

Usage

Stress can be used to test our server resources or more specifically the resources we give to our containers.

$ docker run --rm jfusterm/stress --help
`stress' imposes certain types of compute stress on your system

Usage: stress [OPTION [ARG]] ...
 -?, --help         show this help statement
     --version      show version statement
 -v, --verbose      be verbose
 -q, --quiet        be quiet
 -n, --dry-run      show what would have been done
 -t, --timeout N    timeout after N seconds
     --backoff N    wait factor of N microseconds before work starts
 -c, --cpu N        spawn N workers spinning on sqrt()
 -i, --io N         spawn N workers spinning on sync()
 -m, --vm N         spawn N workers spinning on malloc()/free()
     --vm-bytes B   malloc B bytes per vm worker (default is 256MB)
     --vm-stride B  touch a byte every B bytes (default is 4096)
     --vm-hang N    sleep N secs before free (default none, 0 is inf)
     --vm-keep      redirty memory instead of freeing and reallocating
 -d, --hdd N        spawn N workers spinning on write()/unlink()
     --hdd-bytes B  write B bytes per hdd worker (default is 1GB)

Example: stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M --timeout 10s

Note: Numbers may be suffixed with s,m,h,d,y (time) or B,K,M,G (size).

Test the server resources

You can start a container that will consume 100% of your server CPU.

$ docker run -d --name cpu100 jfusterm/stress --cpu 100

Testing memory limits on containers

  • Testing the memory limit of 128M using 127M with stress.
$ docker run -it --rm -m 128m --memory-swap 128m jfusterm/stress --vm 1 --vm-bytes 127m -t 5s

stress: info: [1] dispatching hogs: 0 cpu, 0 io, 1 vm, 0 hdd
stress: info: [1] successful run completed in 5s
  • Testing the memory limit of 128M using 129M with stress.
$ docker run -it --rm -m 128m --memory-swap 128m jfusterm/stress --vm 1 --vm-bytes 129m -t 5s

stress: info: [1] dispatching hogs: 0 cpu, 0 io, 1 vm, 0 hdd
stress: FAIL: [1] (415) <-- worker 6 got signal 9
stress: WARN: [1] (417) now reaping child worker processes
stress: FAIL: [1] (421) kill error: No such process
stress: FAIL: [1] (451) failed run completed in 0s

Testing CPU limits on containers

Setting 3 different containers with different CPU shares and the same 50% CPU usage by stress. Each of them will have a maximum CPU utilization, just one reaching the 50% usage.

$ docker run -d --name cpu2048 --cpu-shares 2048 jfusterm/stress --cpu 50
$ docker run -d --name cpu1024 --cpu-shares 1024 jfusterm/stress --cpu 50
$ docker run -d --name cpu512 --cpu-shares 512 jfusterm/stress --cpu 50
$ docker stats $(docker inspect -f {{.Name}} $(docker ps -q))

CONTAINER           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O               BLOCK I/O
/cpu1024            28.19%              1.483 MB / 2.089 GB   0.07%               1.296 kB / 648 B      718.3 kB / 0 B
/cpu2048            50.28%              1.483 MB / 2.089 GB   0.07%               1.944 kB / 648 B      718.3 kB / 0 B
/cpu512             14.00%              1.479 MB / 2.089 GB   0.07%               718 B / 648 B         718.3 kB / 0 B
Docker Pull Command
Owner
jfusterm

Comments (0)