给你的Linux系统上点stress
原创文章,转载请注明: 转载自系统技术非业余研究
本文链接地址: 给你的Linux系统上点stress
《debug hacks》 这本书介绍了非常多的调试手段和工具, 其中提到了stress这个简单的压力测试工具,在我们的日常工作中很有用。利用它可以给我们的系统施加CPU,内存,IO和磁盘的压力,在模拟极端场景给应用系统造成的压力方面很有帮助。
主页见这里:http://weather.ou.edu/~apw/projects/stress/
这里还有一篇介绍如何使用的博客。
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方面的折磨。
因为简单所以稳定。参考例子:
$ 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 10s
由于stress支持posix平台,简单的下载,编译和安装就好了, 很顺利!
按照文档默认的运行参数,让系统来点体验:
$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!
祝大家玩得开心!
Post Footer automatically generated by wp-posturl plugin for wordpress.
Recent Comments