stress-testingworkloadstress

Using stress-ng to mimic workload


I am want to use stress-ng to mimic workload. The end goal is to be able to load the system with different percentages of different tasks. For example 50% CPU, 25% IO etc.

So I started with this command...

sudo stress-ng -v --taskset 1 --sched fifo --sched-prio 80 --perf --all 2 --ioport 1 --ioport-ops 1000000 --matrix 1  -t 60s
stress-ng: debug: [2077] 2 processors online, 2 processors configured
stress-ng: debug: [2077] sched: setting scheduler class 'fifo', priority 80
stress-ng: info:  [2077] dispatching hogs: 1 ioport, 1 matrix
stress-ng: debug: [2077] cache allocate: default cache size: 4096K
stress-ng: debug: [2077] starting stressors
stress-ng: debug: [2077] 2 stressors spawned
stress-ng: debug: [2078] stress-ng-ioport: started [2078] (instance 0)
stress-ng: debug: [2079] stress-ng-matrix: started [2079] (instance 0)

But when I monitored process 2078 and 2079, I noticed that only process 2078 was loading the CPU. Image 1

When I swapped the order of the 2 stressors...

sudo stress-ng -v --taskset 1 --sched fifo --sched-prio 80 --perf --all 2 --matrix 1 --ioport 1 --ioport-ops 1000000   -t 60s
stress-ng: debug: [2084] 2 processors online, 2 processors configured
stress-ng: debug: [2084] sched: setting scheduler class 'fifo', priority 80
stress-ng: info:  [2084] dispatching hogs: 1 matrix, 1 ioport
stress-ng: debug: [2084] cache allocate: default cache size: 4096K
stress-ng: debug: [2084] starting stressors
stress-ng: debug: [2084] 2 stressors spawned
stress-ng: debug: [2085] stress-ng-matrix: started [2085] (instance 0)
stress-ng: debug: [2086] stress-ng-ioport: started [2086] (instance 0)
stress-ng: debug: [2085] stress-ng-matrix using method 'all' (x by y)

Only process 2085 was loading the CPU. Image 2

This suggests the 2 stressors do not run in parallel.

How can I get stressors to run in parallel, moreover, to proportion the 2 tasks?

Are there better opensource tools to mimic workload?

Thanks!


Solution

  • The stress-ng stressors are designed to max out the resources, so specifying 25% I/O is not easy to do as one has to estimate what 100% I/O is and then scale down appropriately. Since I/O rates can vary over time (because it is ultimately down to may hardware specific variables) one needs to have a 2nd order differential feed back loop to make it work well, which is out of the scope of what stress-ng is able to do.

    One other way to look at the issue is to scale things with the number of CPUs. Suppose you have 4 CPUs on your system, then 2 CPUS for CPU work = 50%, 1 CPU for I/O = 25%, so run:

    stress-ng --cpu 2 --iomix 1
    

    or on an 8 CPU system you could to something else like:

    stress-ng --matrix 4 --hdd 2