轉自:https://blog.csdn.net/sunvince/article/details/7187768工具
from: http://blog.yufeng.info/archives/2023url
這本書介紹了很是多的調試手段和工具, 其中提到了stress這個簡單的工具,在咱們的平常工做中頗有用。利用它能夠給咱們的系統施加CPU,內存,IO和磁盤的壓力,在模擬極端場景給應用系統形成的壓力方面頗有幫助。spa
主頁見這裏:http://weather.ou.edu/~apw/projects/stress/.net
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.調試
這個stress實現很是的簡單,全部的功能在一個.c文件裏面實現, 系統運行的時候會fork多個子進程,分別進行CPU,內存,IO方面的折磨。
由於簡單因此穩定。參考例子:code
$ stress –cpu 2 –io 1 –vm 1 –vm-bytes 128M –timeout 10s –verbose
stress: info: [9372] dispatching hogs: 2 cpu, 1 io, 1 vm, 0 hdd
stress: dbug: [9372] (243) using backoff sleep of 12000us
stress: dbug: [9372] (262) setting timeout to 10s
stress: dbug: [9372] (285) –> hogcpu worker 9373 forked
stress: dbug: [9372] (305) –> hogio worker 9374 forked
stress: dbug: [9372] (325) –> hogvm worker 9375 forked
stress: dbug: [9372] (243) using backoff sleep of 3000us
stress: dbug: [9372] (262) setting timeout to 10s
stress: dbug: [9372] (285) –> hogcpu worker 9376 forked
stress: dbug: [9375] (466) hogvm worker malloced 134217728 bytes
stress: dbug: [9372] (382) <-- worker 9374 signalled normally
stress: dbug: [9372] (382) <-- worker 9373 signalled normally
stress: dbug: [9372] (382) <-- worker 9375 signalled normally
stress: dbug: [9372] (382) <-- worker 9376 signalled normally
stress: info: [9372] successful run completed in 10sorm
因爲stress支持posix平臺,簡單的下載,編譯和安裝就行了, 很順利!
按照文檔默認的運行參數,讓系統來點體驗:blog
$stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M --timeout 10d |
stress: info: [23176] dispatching hogs: 8 cpu, 4 io, 2 vm, 0 hdd |
具體使用能夠參考man stress!