@@ -5,39 +5,118 @@ Apache服务器的性能测试工具
55
66## 补充说明
77
8- ** ab命令** 是Apache的Web服务器的性能测试工具,它可以测试安装Web服务器每秒种处理的HTTP请求 。
8+ ** ab命令** 是一个测试你 Apache http 服务器的工具,你可以通过这个工具,指定一个单位时间内向 apache 发出的请求数量来看看你的 Apache 和机器配合的性能如何 。
99
1010### 语法
1111
12- ```
13- ab(选项)(参数)
12+ ``` shell
13+ ab [ -A auth-username:password ] [ -c concurrency ] [ -C cookie-name= value
14+ ] [ -d ] [ -e csv-file ] [ -g gnuplot-file ] [ -h ] [ -H custom-header ] [
15+ -i ] [ -k ] [ -n requests ] [ -p POST-file ] [ -P proxy-auth-user‐
16+ name:password ] [ -q ] [ -s ] [ -S ] [ -t timelimit ] [ -T content-type ]
17+ [ -v verbosity] [ -V ] [ -w ] [ -x < table> -attributes ] [ -X proxy[:port]
18+ ] [ -y < tr> -attributes ] [ -z < td> -attributes ] [http://]host‐
19+ name[:port]/path
1420```
1521
1622### 选项
1723
1824``` shell
19- -A:指定连接服务器的基本的认证凭据;
20- -c:指定一次向服务器发出请求数;
21- -C:添加cookie;
22- -g:将测试结果输出为“gnuolot”文件;
23- -h:显示帮助信息;
24- -H:为请求追加一个额外的头;
25- -i:使用“head”请求方式;
26- -k:激活HTTP中的“keepAlive”特性;
27- -n:指定测试会话使用的请求数;
28- -p:指定包含数据的文件;
29- -q:不显示进度百分比;
30- -T:使用POST数据时,设置内容类型头;
31- -v:设置详细模式等级;
32- -w:以HTML表格方式打印结果;
33- -x:以表格方式输出时,设置表格的属性;
34- -X:使用指定的代理服务器发送请求;
35- -y:以表格方式输出时,设置表格属性。
25+ -A auth-username:password
26+ # 支持基本的验证证书,用户名和密码之间使用"冒号" :
27+ # 分隔开,ab将以明文方式传送过去.不管服务器是不是需要
28+ # ,也就是说你的服务器需要支持401认证.
29+
30+ -c concurrency
31+ # 同时向服务器端发送的请求数目,默认状态下是一次 只执行一个http请求.
32+
33+ -C cookie-name=value
34+ # Add a Cookie: line to the request. The argument is typically in the
35+ # form of a name=value pair. This field is repeatable.
36+
37+ -d # Do not display the "percentage served within XX [ms] table".
38+ # (legacy support).
39+
40+ -e csv-file
41+ # Write a Comma separated value (CSV) file which contains for each
42+ # percentage (from 1% to 100%) the time (in milli seconds) it took to
43+ # serve that percentage of the requests. This is usually more useful
44+ # than the 'gnuplot' file; as the results are already 'binned'.
45+
46+ -g gnuplot-file
47+ # Write all measured values out as a 'gnuplot' or TSV (Tab separate
48+ # values) file. This file can easily be imported into packages like
49+ # Gnuplot, IDL, Mathematica, Igor or even Excell. The labels are on
50+ # the first line of the file.
51+ -h # 显示使用说明
52+ -H custom-header
53+ # 向请求包追加附加的标题字串.此参数应该是有效的标题 行(header
54+ # line)形式,通常使用冒号":"来分隔有效配对 (valid pair)例如 'Accept-
55+ # Encoding: zip/zop;8 bit';
56+
57+ -i # 使用一个 http 头(HEAD) 来替换 GET方法.不可以掺入POST 方法
58+
59+ -k # 允许http KeepAlive ;也就是说执行多个请求在一个 http
60+ # 会话当中,默认是不允许的也就是no KeepAlive啦;)
61+
62+ -n requests
63+ # 执行一次测试会话的时候所发出的请求数目,默认是执行一个单一的请求
64+ # 当然了这样的测试结果也就没什么意义了
65+
66+ -p POST-file
67+ # 测试程序也就是ab,将向Apache server发送带有HTTP POST 的请求.
68+
69+ -P proxy-auth-username:password
70+ # 当需要通过代理测试一台 HTTP 服务器的时候而你的代理
71+ # 又需要用户名密码验证,这时你可以使用这个选项,同样
72+ # 用户名与密码之间使用冒号":"分隔开,ab将之以明文的方式
73+ # 发送出去,当然,前提是你的代理是处于407认证状态的
74+
75+ -q # When processing more than 150 requests, ab outputs a progress count
76+ # on stderr every 10% or 100 requests or so. The -q flag will sup‐
77+ # press these messages.
78+
79+ -s # When compiled in (ab -h will show you) use the SSL protected https
80+ # rather than the http protocol. This feature is experimental and
81+ # very rudimentary. You probably do not want to use it.
82+
83+ -S # Do not display the median and standard deviation values, nor dis‐
84+ # play the warning/error messages when the average and median are
85+ # more than one or two times the standard deviation apart. And de‐
86+ # fault to the min/avg/max values. (legacy support).
87+
88+ -t timelimit
89+ # 设置测试的时间的长短,使用这个选项ab将自动设置
90+ # 测试请求会话数目为50000,然后以你设置的时间为
91+ # 固定周期.默认状态下是没有时限的,也就是直到完成
92+ # 你所设置的请求数目为止.
93+
94+ -T content-type
95+ # 内容类型标头,使用在POST数据的时候.
96+
97+ -v verbosity
98+ # 设置冗余级别,4级打印出每个请求标头的详细信息,
99+ # 3级打印出回应代码(例如,404,200),2级打印出警告 信息和指示消息
100+
101+ -V # 显示版本号并且退出
102+ -w # 打印输出结果到HTML表中. 默认的表是两列n行白底黑框
103+
104+ -x < table> -attributes
105+ # 使用字串来描述表的属性,该属性字串应该插入到<table 这里 >
106+
107+ -X proxy[:port]
108+ # Use a proxy server for the requests.
109+
110+ -y < tr> -attributes
111+ # 用于生成html表格每行的属性名 (<tr>)
112+
113+ -z < td> -attributes
114+ # 用于生成html表格每列的属性名 (<td>)
36115```
37116
38117### 参数
39118
40119主机:被测试主机。
41120
42121
43- <!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
122+ <!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
0 commit comments