ab - Apache HTTP服务器基准测试工具

1.简介#

HTTP服务器基准测试工具

2.摘要#

1
2
3
4
5
6
ab [ -A auth-username:password ] [ -c concurrency ] [ -C cookie-name=value ] [ -d ]
[ -e csv-file ] [ -g gnuplot-file ] [ -h ] [ -H custom-header ] [ -i ] [ -k ]
[ -n requests ] [ -p POST-file ] [ -P proxy-auth-username:password ] [ -q ]
[ -s ] [ -S ] [ -t timelimit ] [ -T content-type ] [ -v verbosity] [ -V ]
[ -w ] [ -x <table>-attributes ] [ -X proxy[:port] ] [ -y <tr>-attributes ]
[ -z <td>-attributes ] [http://]hostname[:port]/path

3.选项#

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
48
49
50
51
-A auth-username:password
Http Basic认证
-c concurrency
并发数,默认1
-C cookie-name=value
添加一个Cookie,示例 -C 'XSESSIONID=aaaa;key2=bbbb'
-d
不要显示"Percentage of the requests served within a certain time (ms)"这个表格(遗留支持)
-e csv-file
输入csv文件
-g gnuplot-file
输出gnuplot文件
-h
显示帮助信息
-H custom-header
添加头部,示例 -H "Accept-Encoding: zip/zop;8bit"
-i
发送HEAD请求
-k
开启http KeepAlive特性,默认关闭
-n requests
请求数,默认1
-p POST-file
指定数据文件并发送POST请求
-P proxy-auth-username:password
代理
-q
不显示执行百分比信息
-s
https相关,该特性为实验性,一般不会用到
-S
不显示中位数和标准偏差值,还有不显示其他的一些值。默认仅显示最小值/平均值/最大值(遗留支持)
-t timelimit
基准测试的最大时间(秒)
-T content-type
为POST数据指定Content-Type头部
-v verbosity
设置详情级别,详细程度从4到2递减
-V
显示版本号
-w
打印输出结果为HTML表格(源码)
-x <table>-attributes
String to use as attributes for <table>. Attributes are inserted <table here >.
设置<table>属性,示例 -x bgcolor=blue => <table bgcolor=blue>
-X proxy[:port]
为请求设置一个代理服务器
-y <tr>-attributes
设置<tr>属性
-z <td>-attributes
设置<td>属性

不同版本参数不完全相同,具体见版本的帮助文档 ab -h

4.示例#

1
# ab -n 100 -c 10 'https://publib.boulder.ibm.com/httpserv/manual70/programs/ab.html'
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
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking publib.boulder.ibm.com (be patient).....done


Server Software:
Server Hostname: publib.boulder.ibm.com
Server Port: 443
SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES128-GCM-SHA256,4096,128

Document Path: /httpserv/manual70/programs/ab.html
Document Length: 10193 bytes

Concurrency Level: 10
Time taken for tests: 17.458 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 1045400 bytes
HTML transferred: 1019300 bytes
Requests per second: 5.73 [#/sec] (mean)
Time per request: 1745.789 [ms] (mean)
Time per request: 174.579 [ms] (mean, across all concurrent requests)
Transfer rate: 58.48 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 695 951 198.0 925 1629
Processing: 454 582 57.3 596 693
Waiting: 228 293 30.9 298 368
Total: 1152 1533 233.7 1526 2267

Percentage of the requests served within a certain time (ms)
50% 1526
66% 1558
75% 1594
80% 1614
90% 1652
95% 2222
98% 2267
99% 2267
100% 2267 (longest request)

5.资料#