轻量级压力测试Apache-ApacheBench(ab)

Apache 附带的一个小工具 , 专门用于 HTTP Server 的 benchmark testing , 可以同时模拟多个并发请求。

windows使用ab

apache安装成功后,在apache目录下的bin目录下可以看到ab.exe,要使用apache命令,要先将bin路径添加到系统的path环境变量中。cmd启动命令行
先来一个小例子:在命令行输入ab -n 10 -c 10 http://www.baidu.com/
1. 表示访问这个页面10次,每次并发访问数为10
2. 参数 –c concurrency 表示执行的总次数,如 –c 10000表示总共执行10000次,
3. 参数 –n requests 表示同时连接数
结果

C:\Users\Administrator>ab -n 10 -c 10 http://www.baidu.com/
This is ApacheBench, Version 2.3 <$Revision: 1663405 $>
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
Server Hostname:        www.baidu.com
Server Port:            80

Document Path:          /
Document Length:        96269 bytes
//并发数
Concurrency Level:      10
//整个请求持续的时间 
Time taken for tests:   0.437 seconds
//完成的请求数量 
Complete requests:      10
//失败的请求数量 
Failed requests:        9
   (Connect: 0, Receive: 0, Length: 9, Exceptions: 0)
//整个场景中的网络传输量 
Total transferred:      972707 bytes
//整个场景中的 HTML 内容传输量
HTML transferred:       962367 bytes
// 重要指标,相当于 LR 中的 每秒事务数 ,后面括号中的 mean 表示这是一个平均值
Requests per second:    22.88 [#/sec] (mean)
//相当于 LR 中的 平均事务响应时间
Time per request:       437.025 [ms] (mean)

Time per request:       43.703 [ms] (mean, across all concurrent requests)
// 平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题
Transfer rate:          2173.58 [Kbytes/sec] received
//网络上消耗的时间的分解
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       31   36   3.4     38      39
Processing:    79  206  99.3    208     365
Waiting:       37  161 101.2    174     320
Total:        115  242 100.8    239     403
//下面的内容为整个场景中所有请求的响应情况。
Percentage of the requests served within a certain time (ms)
  50%    239 //50%的响应时间小于239毫秒
  66%    289
  75%    326
  80%    367
  90%    403
  95%    403
  98%    403
  99%    403//1%的响应时间大于403毫秒
 100%    403 (longest request)

参数说明:http://httpd.apache.org/docs/2.2/programs/ab.html
参数
参数 –c concurrency 表示执行的总次数,如 –c 10000表示总共执行10000次,
参数 –n requests 表示同时连接数,如-n 1000表示每次请求的并发数为1000

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值