zoukankan      html  css  js  c++  java
  • apache 的ab 工具

    ab是apache 进行http服务器压力测试的一个工具。用来衡量apache 服务器的执行效率,能够检测出apache每秒能够处理的请求数。

    一个使用的例子如下(windows下)

    ab -n 100 -c 10 http://www.baidu.com/

    上面这个命令能够检测百度服务器的承压情况,其中-n 100表示总共发起100个连接请求,而-c 10表示同时维持10个并发。测试结果如下和字段的含义解释如下(飘黄是解释):

    This is ApacheBench, Version 2.3 <$Revision: 1554214 $>
    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Licensed to The Apache Software Foundation, http://www.apache.org/
    
    Benchmarking www.baidu.com (be patient).....done

    Server Software: BWS/1.1 ## 服务器的软件名称, 如果是apache,则会显示是apache,这个字段选自http的response头部的header 字段 Server Hostname: www.baidu.com ## 请求的域名 Server Port: 80      ## 请求的端口 Document Path: /        ## 本次请求的文档路径 Document Length: 86001 bytes  ## 请求的response的文档大小 Concurrency Level: 10     ## 并发度,对应了命令中的 -c 10 Time taken for tests: 6.901 seconds  ## 测试花费的时间 Complete requests: 100        ## 完成的请求个数 Failed requests: 95        ## 失败的请求个数 (Connect: 0, Receive: 0, Length: 95, Exceptions: 0) Total transferred: 8696312 bytes  ## 从服务器接收的byte个数,包含http头 HTML transferred: 8610757 bytes  ## 从服务器接收的html文档的总个数 Requests per second: 14.49 [#/sec] (mean) ##每秒处理的请求书14.49 = 100 / 6.901 Time per request: 690.140 [ms] (mean) ##单一请求的处理时间(客户端感知的时间) Time per request: 69.014 [ms] (mean, across all concurrent requests) ##每个请求的处理时间(加上并发), 侧重于看服务器端的处理能力 Transfer rate: 1230.55 [Kbytes/sec] received ##传输速率

    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        1   64 421.1      4    3000
    Processing:    11  615 1164.2     62    3146
    Waiting:        3  253 765.6     27    3062
    Total:         12  679 1214.4     63    3151    ##最快的请求响应时间是12ms, 最长的是3151ms
    
    Percentage of the requests served within a certain time (ms)  ## 给定时间内得到响应的请求数(百分比)
      50%     63   ## 63ms内50%的请求得到了响应
      66%    142
      75%    164
      80%   3033
      90%   3107
      95%   3133
      98%   3141
      99%   3151
     100%   3151 (longest request)

    ab工具虽然是apache用来给自己做测试用,也可以用来测试其他版本的服务器。功能上ab比较完整,支持多个参数,捡几个常用的介绍一下。

    -k 启用 KeepAlive, 一个会话里发起多个请求。
    -i  发起HEAD请求,而不是GET请求

    其他的参数用到的时候在解释吧。

    我在测试自己写的简单服务器时会发现出一个错误:

    Benchmarking 127.0.0.1 (be patient)...apr_socket_recv: 远程主机强迫关闭了一个现有的连接。 (730054)

    查了一下资料, 需要加上-k的参数来解决。

  • 相关阅读:
    itextpdf 和 pdfbox 测试用例
    Java base64 编码、解码
    常用字体
    DIY 单片机 入门
    太难了。
    Java 之 native:JNI 本地方法测试实现
    Java 之 String 引用传递
    Java class 文件 方法的指令含义
    Spring学习文章链接
    数据结构_树_图_总结
  • 原文地址:https://www.cnblogs.com/kwliu/p/4211851.html
Copyright © 2011-2022 走看看