patterndockerMinor
Stress testing for docker container
Viewed 0 times
containerdockerstresstestingfor
Problem
I want my container to die under high pressure to check monitoring and alerting as well as compose autorestarts. What is best way to simulate heavy load within docker container. I've tried so far
for memory pressure (hoping OOM kill for host machine which has 4Gb of ram) and
Is there some tool to achieve that for docker or preferred approach I should use?
root@docker-vm:/# stress --vm 10 --vm-bytes 2048M --vm-hang 20
stress: info: [238] dispatching hogs: 0 cpu, 0 io, 10 vm, 0 hdd
stress: FAIL: [238] (415) <-- worker 243 got signal 9
stress: WARN: [238] (417) now reaping child worker processes
stress: FAIL: [238] (451) failed run completed in 101sfor memory pressure (hoping OOM kill for host machine which has 4Gb of ram) and
stress --cpu 100 which is obviously not really harmful.Is there some tool to achieve that for docker or preferred approach I should use?
Solution
Just a quick follow-up on pumba. Installation (for Ubuntu):
It uses stress-ng under the hood, so same commands apply. Examples:
-
-
In this particular example we create 10 workers spinning on malloc()/free() allocating
Default stressor as in first example is
$ curl -SL https://github.com/alexei-led/pumba/releases/download/0.7.2/pumba_linux_amd64 -O
$ sudo mv pumba_linux_amd64 /usr/bin/pumba
$ sudo chmod +x /usr/bin/pumba
$ pumba --versionIt uses stress-ng under the hood, so same commands apply. Examples:
-
$ pumba stress -d 1m container_name-d 1m - duration of a stress test (1 minute)container_name - your target container (from docker ps output)-
$ pumba stress -d 30s --stressors "--vm 10 --vm-bytes 512M --vm-hang 20" container_name-d 30 - duration 30 seconds-stressors - parameters passed to stress-ng appIn this particular example we create 10 workers spinning on malloc()/free() allocating
512MB each and sleep 20 seconds before freeing the memory.Default stressor as in first example is
--cpu 4 --timeout 60sCode Snippets
$ curl -SL https://github.com/alexei-led/pumba/releases/download/0.7.2/pumba_linux_amd64 -O
$ sudo mv pumba_linux_amd64 /usr/bin/pumba
$ sudo chmod +x /usr/bin/pumba
$ pumba --version$ pumba stress -d 1m container_name$ pumba stress -d 30s --stressors "--vm 10 --vm-bytes 512M --vm-hang 20" container_nameContext
StackExchange DevOps Q#11668, answer score: 7
Revisions (0)
No revisions yet.