使用Stress-ng模拟工作量

时间:2019-11-15 18:48:41

标签: stress-testing workload stress

我想使用Stress-ng来模拟工作量。最终目标是能够为系统加载不同百分比的不同任务。例如50%的CPU,25%的IO等。

所以我从这个命令开始...

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)

但是当我监视进程2078和2079时,我注意到只有进程2078正在加载CPU。 Image 1

当我交换2个压力源的顺序时...

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)

只有进程2085正在加载CPU。 Image 2

这表明2个压力源不是并行运行的。

此外,如何使压力源并行运行,以按比例分配这两个任务?

是否有更好的开源工具来模拟工作量?

谢谢!

1 个答案:

答案 0 :(得分:0)

压力ng压力源旨在最大程度地利用资源,因此指定25%I / O并不容易,因为必须估算100%I / O是什么,然后适当缩小。由于I / O速率会随时间变化(因为最终会降低到特定于硬件的变量),因此需要有一个二阶差分反馈环路才能使其正常工作,这超出了压力范围。能够做到。

解决问题的另一种方法是根据CPU的数量来扩展规模。假设您的系统上有4个CPU,那么2个CPUS用于CPU工作= 50%,1个CPU用于I / O = 25%,因此运行:

stress-ng --cpu 2 --iomix 1

或在8 CPU系统上,您可以执行其他操作,例如:

stress-ng --matrix 4 --hdd 2