• stress工具使用指南和结果分析(好好好测试通过)


    stress工具使用指南和结果分析

    0.1152019.05.13 09:17:35字数 547阅读 1,112
    
    #stress
    `stress' imposes certain types of compute stress on your system
    
    Usage: stress [OPTION [ARG]] ...
    #-? 显示帮助信息
     -?, --help         show this help statement
         --version      show version statement
    #-v 显示版本号
     -v, --verbose      be verbose
    #-q 不显示运行信息
     -q, --quiet        be quiet
    #-n 显示已完成的指令情况
     -n, --dry-run      show what would have been done
    #-t --timeout N 指定运行N秒后停止
    #--backoff N 等待N微妙后开始运行
     -t, --timeout N    timeout after N seconds
         --backoff N    wait factor of N microseconds before work starts
    #-c 产生n个进程 每个进程都反复不停的计算随机数的平方根
     -c, --cpu N        spawn N workers spinning on sqrt()
    #-i 产生n个进程 每个进程反复调用sync(),sync()用于将内存上的内容写到硬盘上
     -i, --io N         spawn N workers spinning on sync()
    #-m --vm n 产生n个进程,每个进程不断调用内存分配malloc和内存释放free函数
    #--vm-bytes B 指定malloc时内存的字节数 (默认256MB)
    #--vm-hang N 指定在free钱的秒数
     -m, --vm N         spawn N workers spinning on malloc()/free()
         --vm-bytes B   malloc B bytes per vm worker (default is 256MB)
         --vm-stride B  touch a byte every B bytes (default is 4096)
         --vm-hang N    sleep N secs before free (default none, 0 is inf)
         --vm-keep      redirty memory instead of freeing and reallocating
    #-d --hadd n 产生n个执行write和unlink函数的进程
    #-hadd-bytes B 指定写的字节数
    #--hadd-noclean 不unlink
     -d, --hdd N        spawn N workers spinning on write()/unlink()
         --hdd-bytes B  write B bytes per hdd worker (default is 1GB)
    
    Example: stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M --timeout 10s
    
    #时间单位可以为秒s,分m,小时h,天d,年y,文件大小单位可以为K,M,G
    Note: Numbers may be suffixed with s,m,h,d,y (time) or B,K,M,G (size).
    
    

    stress cpu 测试

    stress测试cpu,是在用户态将cpu 耗尽。

    [root@jiangyi01.sqa.zmf /home/ahao.mah/ALIOS_QA/tools/stress-1.0.4]
    #stress -c 1 -t 100
    stress: info: [17223] dispatching hogs: 1 cpu, 0 io, 0 vm, 0 hdd
    
     
    image.png

    stress io 测试

    使用stress测试IO,虽然可以创建任意数量的IO进程,但是,可以将 %sys 100%。因为,stress是通过循环执行sync(),使得内核态cpu 100%,但是,stress,没有把w_await svctm 的比例打的很高。

    [root@jiangyi01.sqa.zmf /home/ahao.mah/ALIOS_QA/tools/stress-1.0.4]
    #stress  --io 100 -t 100
    stress: info: [130998] dispatching hogs: 0 cpu, 100 io, 0 vm, 0 hdd
    
    [root@jiangyi01.sqa.zmf /home/ahao.mah/gotby/C/c4]
    #ps axu | grep stress |grep -v grep | wc -l
    101
    
     
    image.png
     
    image.png

    stress mem测试

    stress 测试内存的时候,--vm-bytes 1G --vm-hang 100 这里2个参数是关键!!!!
    --vm-bytes 表示malloc分配多少内存
    --vm-hang 表示malloc分配的内存多少时间后在free()释放掉
    --vm 指定进程数量

    下面例子,就是说,10个进程,同时去malloc分配内存,并且保持100s后再释放内存

    [root@jiangyi01.sqa.zmf /home/ahao.mah/ALIOS_QA/tools/stress-1.0.4]
    #stress --vm 10 --vm-bytes 1G --vm-hang 100 --timeout 100s
    stress: info: [32286] dispatching hogs: 0 cpu, 0 io, 10 vm, 0 hdd
    
    [root@jiangyi01.sqa.zmf /home/ahao.mah/ALIOS_QA/tools/stress-1.0.4]
    #echo "63709272/1024/1024" |bc
    60
    
     
    image.png
     
    image.png
    [root@jiangyi01.sqa.zmf /home/ahao.mah/ALIOS_QA/tools/stress-1.0.4]
    #stress --vm 30 --vm-bytes 1G --vm-hang 50 --timeout 50s
    stress: info: [44047] dispatching hogs: 0 cpu, 0 io, 30 vm, 0 hdd
    
     
    image.png
     
    image.png

    stress 磁盘IO测试

    注意: 我是在/data 目录,这个目录挂载的是raid,总大小:17T

    -d forks
    --hdd forks 产生多个执行write()函数的进程
    --hdd-bytes bytes 指定写的Bytes数,默认是1GB
    --hdd-noclean 不要将写入随机ASCII数据的文件Unlink
    eg:stress -d 1 --hdd-bytes 3G

    解释:-d 1:一个写进程。写入固定大小通过mkstemp()函数写入当前目录;你也可以指定向磁盘中写入固定大小的文件
    这个文件通过调用mkstemp()产生并保存在当前目录下,默认是文件产生后就被执行unlink(清除)操作,
    但是你可以使用“--hdd-bytes”选项将产生的文件全部保存在当前目录下,这会将你的磁盘空间逐步耗尽。
    0

    当只有一个进程在写:

    [root@jiangyi01.sqa.zmf /data]
    #stress --hdd 1 --hdd-bytes 1024G
    stress: info: [130229] dispatching hogs: 0 cpu, 0 io, 0 vm, 1 hdd
    
     
    image.png

    测试,提高进程数量为5:

    [root@jiangyi01.sqa.zmf /data]
    #stress --hdd 5 --hdd-bytes 1024G
    stress: info: [26847] dispatching hogs: 0 cpu, 0 io, 0 vm, 5 hdd
    
     
    image.png
    [root@jiangyi01.sqa.zmf /data]
    #stress --hdd 10 --hdd-bytes 1024G
    stress: info: [31912] dispatching hogs: 0 cpu, 0 io, 0 vm, 10 hdd
    
    [root@jiangyi01.sqa.zmf /home/ahao.mah]
    #ps axu | grep stress | grep -v grep
    root      31912  0.0  0.0   7264   652 pts/0    S+   13:13   0:00 stress --hdd 10 --hdd-bytes 1024G
    root      31913 13.9  0.0   8164  1120 pts/0    D+   13:13   0:06 stress --hdd 10 --hdd-bytes 1024G
    root      31914 14.5  0.0   8164  1120 pts/0    D+   13:13   0:07 stress --hdd 10 --hdd-bytes 1024G
    root      31915 14.5  0.0   8164  1120 pts/0    D+   13:13   0:07 stress --hdd 10 --hdd-bytes 1024G
    root      31916 14.1  0.0   8164  1120 pts/0    D+   13:13   0:07 stress --hdd 10 --hdd-bytes 1024G
    root      31917 13.9  0.0   8164  1120 pts/0    D+   13:13   0:06 stress --hdd 10 --hdd-bytes 1024G
    root      31918 14.0  0.0   8164  1120 pts/0    D+   13:13   0:07 stress --hdd 10 --hdd-bytes 1024G
    root      31919 13.8  0.0   8164  1120 pts/0    D+   13:13   0:06 stress --hdd 10 --hdd-bytes 1024G
    root      31920 13.9  0.0   8164  1120 pts/0    D+   13:13   0:06 stress --hdd 10 --hdd-bytes 1024G
    root      31921 13.9  0.0   8164  1120 pts/0    D+   13:13   0:06 stress --hdd 10 --hdd-bytes 1024G
    root      31922 14.0  0.0   8164  1120 pts/0    D+   13:13   0:07 stress --hdd 10 --hdd-bytes 1024G
    
    
     
    image.png

    结论:

    可见,--hdd 进程数量,并不是一个干扰因素,这个stress对写磁盘的速度并没有一个控制,直接用最大的压力测试出瓶颈,当瓶颈到达了,进程多几个也是没有什么用,这个估计也是stress的不足之处。
    w_await 和svctm 基本一致,说明等待时间和服务时间基本相等。

     
  • 相关阅读:
    TreeView中找鼠标指向的节点
    自己写的一个分页控件源代码
    [JWF]只显示当前用户的WorkItem方法
    [JWF]安装Workflow Server后的中文界面补丁
    [JWF]JWF中调用WebService方法
    [JWF]配置Adobe Form Server Application
    [导入](HOWTO)将一个Xml中的节点复制到别一个Xml的节点上
    [JWF]Form Common button 执行生命周期
    [JWF]Special Buttons 执行生命周期
    [JWF]Participant Interface访问ActiveDirectory
  • 原文地址:https://www.cnblogs.com/xuanbjut/p/12649889.html
Copyright © 2020-2023  润新知