开源性能测试工具 - Apache ab 介绍
版权声明:本文可以被转载,但是在未经本人许可前,不得用于任何商业用途或其他以盈利为目的的用途。本人保留对本文的一切权利。如需转载,请在转载是保留此版权声明,并保证本文的完整性。也请转贴者理解创作的辛劳,尊重作者的劳动成果。
作者:陈雷邮箱:jackeichan@gmail.com
Blog:http://jackei.cnblogs.com
?
引子
?
按照原定计划,今天开始研究本来想顺便把文档翻译一下,不过后来想了想,看懂是一回事,全部翻译出来又是另外一回事了,工作量太大,而且这也不是我一开始要研究开源工具通常都是为了某个特定的目的而开发出来的,所以如果想找到一个开源的性能测试工具去与LoadRunner另外,如果8月份和9月份的空闲时间足够多,我想我会写一个系列文章来讲述在实际的开发和测试过程中引入开源性能测试工具的情况。如果有朋友感兴趣,希望大家可以一起研究和讨论。
简介
ab的全称是ApacheBench,是通过下面的一个简单的例子和注释,相信大家可以更容易理解这个工具的使用。
一个简单的例子
/*在这个例子的一开始,我执行了这样一个命令C:\Program Files\Apache Software Foundation\Apache2.2\bin>ab -n 10 -c 10 http
://www.google.com/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 1997-2005 The Apache Software Foundation, http://www.apache.org/
?
Benchmarking www.google.com (be patient).....done
?
?
Server Software:???????Server Hostname:???????Server Port:????????????
Document Path:?????????Document Length:????????
Concurrency Level:?????/*整个测试持续的时间*/
Time taken for tests:??/*完成的请求数量*/
Complete requests:?????/*失败的请求数量*/
Failed requests:???????Write errors:??????????Non-2xx responses:?????Keep-Alive requests:???/*整个场景中的网络传输量*/
Total transferred:?????/*整个场景中的HTML内容传输量*/
HTML transferred:??????/*大家最关心的指标之一,相当于Requests per second:???/*大家最关心的指标之二,相当于Time per request:??????/*这个还不知道是什么意思,有知道的朋友请留言,谢谢Time per request:??????/*平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题*/
Transfer rate:?????????/*网络上消耗的时间的分解,各项数据的具体算法还不是很清楚*/
Connection Times (ms)
?????????????Connect:??????Processing:???Waiting:??????Total:?????????
/*下面的内容为整个场景中所有请求的响应情况。在场景中每个请求都有一个响应时间,其中Percentage of the requests served within a certain time (ms)
?????????100%???
更多信息
ab下面是?
-ASupply BASIC Authentication credentials to the server. The username and password are separated by a single
-cNumber of multiple requests to perform at a time. Default is one request at a time.
-CAdd a
-d
Do not display the "percentage served within XX [ms] table". (legacy support).
-eWrite a Comma separated value (CSV) file which contains for each percentage (from 1% to 100%) the time (in milliseconds) it took to serve that percentage of the requests. This is usually more useful than the 'gnuplot' file; as the results are already 'binned'.
-gWrite all measured values out as a 'gnuplot' or TSV (Tab separate values) file. This file can easily be imported into packages like Gnuplot, IDL, Mathematica, Igor or even Excel. The labels are on the first line of the file.
-h
Display usage information.
-HAppend extra headers to the request. The argument is typically in the form of a valid header line, containing a colon-separated field-value pair (i.e.,
-i
Do-k
Enable the HTTP KeepAlive feature,-nNumber of requests to perform for the benchmarking session. The default is to just perform a single request which usually leads to non-representative benchmarking results.
-pFile containing data to POST.
-PSupply BASIC Authentication credentials to a proxy en-route. The username and password are separated by a single
-q
When processing more than 150 requests,-s
When compiled in (ab -h
-S
Do not display the median and standard deviation values, nor display the warning/error messages when the average and median are more than one or two times the standard deviation apart. And default to the min/avg/max values. (legacy support).
-tMaximum number of seconds to spend for benchmarking. This implies a
-TContent-type header to use for POST data.
-vSet verbosity level -
-V
Display version number and exit.
-w
Print out results in HTML tables. Default table is two columns wide, with a white background.
-xString to use as attributes for
-XUse a proxy server for the requests.
-yString to use as attributes for
-zString to use as attributes for?
相关链接
ababhttp://httpd.apache.org/docs/2.0/programs/ab.html