Github repo: https://github.com/presidenten/express-stress
Set CPU and Memory stress levels with HTTP GET Requests
Start the server
docker run -d --rm --name stress -p 3000:3000 --cpus=1 --memory=256M presidenten/express-stress
/cpu/:load?
- Addload
% load to cpu,default: 10
/memory/:load?
- Addload
MB load to memory,default: 32
/clear-load
- Clear all load
Test with two terminal windows.
In the first terminal:
docker stats stress
In the second terminal:
# Stress CPU
# Add default value of 10% cpu load
curl localhost:3000/cpu
# Add 20% cpu load
curl localhost:3000/cpu/20
# Stress Memory
# Add default value of 32MB memory load (and 30% cpu)
curl localhost:3000/memory
# Add 128MB cpu load (and 30% cpu)
curl localhost:3000/memory/128
# Note that memory allocation is a bit slow
Adding memory also eats some cpu. msync
was selected as memory method since it requires the least amount of CPU. It increases memory usage slowly though, which can both be good or bad depending on what you want.
Also fixed size in MB
was selected instead of %
since stress-ng
seemed to look at max memory on the docker host instead of the available memory on the container in my tests.
PORT
- Which port to usedefault: 3000
MAX_CPU
- What cpu percentage is maxdefault: 90
MAX_MEMORY
- What is max memory in MBdefault: 8192
BASE_MEMORY
- How much memory in MB is the application already usingdefault: 11
MEMORY_OFFSET
- Offset memory allocation by this amountdefault: 4
MSYNC_CPU
- How much cpu does each msync process hogdefault: 30