您的位置:首页 > 运维架构 > Apache

ab ApacheBench web测试工具

2016-06-13 21:15 573 查看
http://www.ibm.com/developerworks/cn/linux/l-cn-ulimit/

ApacheBench参数说明

格式:ab[options][http://]hostname[:port]/path
参数说明:
-nrequestsNumberofrequeststoperform
//在测试会话中所执行的请求个数(本次测试总共要访问页面的次数)。默认时,仅执行一个请求。
-cconcurrencyNumberofmultiplerequeststomake
//一次产生的请求个数(并发数)。默认是一次一个。
-ttimelimitSecondstomax.waitforresponses
//测试所进行的最大秒数。其内部隐含值是-n50000。它可以使对服务器的测试限制在一个固定的总时间以内。默认时,没有时间限制。
-ppostfileFilecontainingdatatoPOST
//包含了需要POST的数据的文件,文件格式如“p1=1&p2=2”.使用方法是-p111.txt。(配合-T)
-Tcontent-typeContent-typeheaderforPOSTing
//POST数据所使用的Content-type头信息,如-T“application/x-www-form-urlencoded”。(配合-p)
-vverbosityHowmuchtroubleshootinginfotoprint
//设置显示信息的详细程度–4或更大值会显示头信息,3或更大值可以显示响应代码(404,200等),2或更大值可以显示警告和其他信息。-V显示版本号并退出。
-wPrintoutresultsinHTMLtables
//以HTML表的格式输出结果。默认时,它是白色背景的两列宽度的一张表。
-iUseHEADinsteadofGET
//执行HEAD请求,而不是GET。
-xattributesStringtoinsertastableattributes
-yattributesStringtoinsertastrattributes
-zattributesStringtoinsertastdorthattributes
-CattributeAddcookie,eg.-C“c1=1234,c2=2,c3=3”(repeatable)
//-Ccookie-name=value对请求附加一个Cookie:行。其典型形式是name=value的一个参数对。此参数可以重复,用逗号分割。
提示:可以借助session实现原理传递JSESSIONID参数,实现保持会话的功能,如
-C”c1=1234,c2=2,c3=3,JSESSIONID=FF056CD16DA9D71CB131C1D56F0319F8″。
-HattributeAddArbitraryheaderline,eg.‘Accept-Encoding:gzip’Insertedafterallnormalheaderlines.(repeatable)
-AattributeAddBasicWWWAuthentication,theattributes
areacolonseparatedusernameandpassword.
-PattributeAddBasicProxyAuthentication,theattributes
areacolonseparatedusernameandpassword.
//-Pproxy-auth-username:password对一个中转代理提供BASIC认证信任。用户名和密码由一个:隔开,并以base64编码形式发送。无论服务器是否需要(即,是否发送了401认证需求代码),此字符串都会被发送。
-Xproxy:portProxyserverandportnumbertouse
-VPrintversionnumberandexit
-kUseHTTPKeepAlivefeature
-dDonotshowpercentilesservedtable.
-SDonotshowconfidenceestimatorsandwarnings.
-gfilenameOutputcollecteddatatognuplotformatfile.
-efilenameOutputCSVfilewithpercentagesserved
-hDisplayusageinformation(thismessage)
//-attributes设置属性的字符串.缺陷程序中有各种静态声明的固定长度的缓冲区。另外,对命令行参数、服务器的响应头和其他外部输入的解析也很简单,这可能会有不良后果。它没有完整地实现HTTP/1.x;仅接受某些’预想’的响应格式。strstr(3)的频繁使用可能会带来性能问题,即你可能是在测试ab而不是服务器的性能。

参数很多,一般我们用-c和-n参数就可以了。例如:

ab-c5000-n600http://192.163.1.26/

[root@localhostyum.repos.d]#ab-c5000-n600http://192.163.1.26/index.htmlab:Cannotuseconcurrencylevelgreaterthantotalnumberofrequests




                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: