压力测试apache-ab-使用方法

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

参数简明 -n 发送请求的数量 -c 表示一次发送多少个(实际上就是把-n分批发送), 如:ab -n 1000 -c 64 http://center.xxxxxx.cn/

1
2
tianyi:~ john$ 
tianyi:~ john$ ab -n 10 -c 10 http://center.xxxxxx.cn/
参数说明
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking center.xxxxxx.cn (be patient).....done


Server Software:
Server Hostname:        center.xxxxxx.cn
Server Port:            80

Document Path:          /
Document Length:        89 bytes      #页面长度

Concurrency Level:      10            #并发数 
Time taken for tests:   0.150 seconds #注:测试共使用了多少时间
Complete requests:      10            #注:请求完成的数量
Failed requests:        0             #注:请求失败的数量
Write errors:           0
Non-2xx responses:      10
Total transferred:      3202 bytes    #注:请求产生的流量
HTML transferred:       890 bytes     #注:html传输流量
Requests per second:    66.52 [#/sec] (mean)  #注:每秒事务数
Time per request:       150.330 [ms] (mean)   #注:平均响应时间

Time per request:       15.033 [ms] (mean, across all concurrent requests)  #注:每个请求响的平均时间,也就是服务器吞吐量的倒数


Transfer rate:          20.80 [Kbytes/sec] received                         #注:传输效率

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       42   51   6.0     53      59
Processing:    87   94   4.7     94     101
Waiting:       86   93   5.0     94     101
Total:        139  145   3.5    146     149

Percentage of the requests served within a certain time (ms)
  50%    146  #注:50%的请求响应小于146
  66%    147  #注:60%的请求响应小于147
  75%    148  #注:60%的请求响应小于148
  80%    149
  90%    149
  95%    149
  98%    149
  99%    149
 100%    149 (longest request)
原文地址:http://dlj.bz/AZdabu

Comments