zoukankan      html  css  js  c++  java
  • 压测工具ab的简单使用

    apache benchmark(ab)是一种常见的压测工具,不仅可以对apache进行压测,也可以对nginx,tomcat,IIS等进行压测

    安装

    如果安装了apache,那么ab已经自带了,不需要再额外安装,如果没有安装apache,可以通过以下方式安装

    # ubuntu
    sudo apt-get install apache2-util
    
    # centos
    yum -y install httpd-tools
    

    压测

    在压测前,需要关注几个选项,通过ab --help查看

    -n  requests       要执行的请求次数
    -c  concurrency    并发数量
    -s  timeout        响应时间
    

    #### 执行

    执行以下代码进行压测

    ab -n 1000 -c 100 -s 1 http://127.0.0.1:1080/index
    # 一共1000个请求,并发100,超时时间为1s,后面为测试的url
    

    测试结果
    apr_pollset_poll: The timeout specified has expired (70007)
    Total of 997 requests completed
    

    显示有997个请求完成了,而且报错了,说明有请求超过1s,所以把超时时间去掉重新测试

    ab -n 1000 -c 100 http://127.0.0.1:1080/index
    

    结果
    Server Software:        nginx/x.x.x
    Server Hostname:        www.my.com
    Server Port:            80
    
    Document Path:          /
    Document Length:        2368 bytes
    
    Concurrency Level:      100
    Time taken for tests:   30.914 seconds
    Complete requests:      1000
    Failed requests:        0
    Write errors:           0
    Total transferred:      2527000 bytes
    HTML transferred:       2368000 bytes
    Requests per second:    32.35 [#/sec] (mean)
    Time per request:       3091.393 [ms] (mean)
    Time per request:       30.914 [ms] (mean, across all concurrent requests)
    Transfer rate:          79.83 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0  174 381.6      0    2006
    Processing:     1 2391 6166.6    205   25853
    Waiting:        1 2080 5941.6    205   25853
    Total:          2 2565 6143.6    406   26609
    
    Percentage of the requests served within a certain time (ms)
      50%    406
      66%   1004
      75%   1413
      80%   1616
      90%   6448
      95%  25760
      98%  25824
      99%  25855
     100%  26609 (longest request)
    

    这里我们需要关注以下几个数据

    1)Failed requests:失败的请求

    2)Requests per second:也就是常说的QPS, 每秒查询率,这是一个平均值

    3)Time per request:完成一个请求所花费的时间

    4)Transfer rate: 网络传输速度。 对于大文件的请求测试,这个值很容易成为系统瓶颈所在 要确定该值是不是瓶颈,需要了解客户端和被测服务器之间的网络情况,包括网络带宽和网卡速度等信息。

  • 相关阅读:
    easy ui 表单ajax和from两种提交数据方法
    easy ui 下拉级联效果 ,下拉框绑定数据select控件
    easy ui 下拉框绑定数据select控件
    easy ui 异步上传文件,跨域
    easy ui 菜单和按钮(Menu and Button)
    HTTP 错误 404.3
    EXTJS4.2 后台管理菜单栏
    HTML 背景图片自适应
    easy ui 表单元素input控件后面加说明(红色)
    EXTJS 4.2 添加滚动条
  • 原文地址:https://www.cnblogs.com/zzliu/p/11924151.html
Copyright © 2011-2022 走看看