ab网站压力测试命令
我们知道压力测试的软件确实很多,诸如微软的WAST,惠普的LoadRunner以及等等其他的,但这些软件学习起来还是需要花费些时间,在选择上实在头痛,后来在郭欣的那本《构建高性能WEB站点》上看到了他介绍的这款Apache自带的压力测试工具ab,十分喜爱,于是今天终于有机会体验下ab对网站的压力测试。
studiogang@studiogang:~$ab-V ThisisApacheBench,Version2.3<$Revision:655654$> Copyright1996AdamTwiss,ZeusTechnologyLtd,http://www.zeustech.net/ LicensedtoTheApacheSoftwareFoundation,http://www.apache.org/
studiogang@studiogang:~$ab-v ab:optionrequiresanargument--v ab:wrongnumberofarguments Usage:ab[options][http[s]://]hostname[:port]/path Optionsare: -nrequestsNumberofrequeststoperform -cconcurrencyNumberofmultiplerequeststomake -ttimelimitSecondstomax.waitforresponses -bwindowsizeSizeofTCPsend/receivebuffer,inbytes -ppostfileFilecontainingdatatoPOST.Rememberalsotoset-T -uputfileFilecontainingdatatoPUT.Rememberalsotoset-T -Tcontent-typeContent-typeheaderforPOSTing,eg. 'application/x-www-form-urlencoded' Defaultis'text/plain' -vverbosityHowmuchtroubleshootinginfotoprint -wPrintoutresultsinHTMLtables -iUseHEADinsteadofGET -xattributesStringtoinsertastableattributes -yattributesStringtoinsertastrattributes -zattributesStringtoinsertastdorthattributes -CattributeAddcookie,eg.'Apache=1234.(repeatable) -HattributeAddArbitraryheaderline,eg.'Accept-Encoding:gzip' Insertedafterallnormalheaderlines.(repeatable) -AattributeAddBasicWWWAuthentication,theattributes areacolonseparatedusernameandpassword. -PattributeAddBasicProxyAuthentication,theattributes areacolonseparatedusernameandpassword. -Xproxy:portProxyserverandportnumbertouse -VPrintversionnumberandexit -kUseHTTPKeepAlivefeature -dDonotshowpercentilesservedtable. -SDonotshowconfidenceestimatorsandwarnings. -gfilenameOutputcollecteddatatognuplotformatfile. -efilenameOutputCSVfilewithpercentagesserved -rDon'texitonsocketreceiveerrors. -hDisplayusageinformation(thismessage) -ZciphersuiteSpecifySSL/TLSciphersuite(Seeopensslciphers) -fprotocolSpecifySSL/TLSprotocol(SSL2,SSL3,TLS1,orALL)
studiogang@studiogang:~$ab-n1000-c10http://www.51cto.com/index.php ThisisApacheBench,Version2.3<$Revision:655654$> Copyright1996AdamTwiss,ZeusTechnologyLtd,http://www.zeustech.net/ LicensedtoTheApacheSoftwareFoundation,http://www.apache.org/ Benchmarkingwww.51cto.com(bepatient) Completed100requests Completed200requests Completed300requests Completed400requests Completed500requests Completed600requests Completed700requests Completed800requests Completed900requests Completed1000requests Finished1000requests /*WEB服务器用的是nginx*/ ServerSoftware:nginx ServerHostname:www.51cto.com ServerPort:80 DocumentPath:/index.php DocumentLength:154bytes ConcurrencyLevel:10 Timetakenfortests:74.373seconds Completerequests:1000 Failedrequests:0 Writeerrors:0 Non-2xxresponses:1000 Totaltransferred:330000bytes HTMLtransferred:154000bytes /*大家最关心的指标之一,指的是吞吐率 相当于LR中的每秒事务数,后面括号中的mean表示这是一个平均值*/ Requestspersecond:13.45[#/sec](mean) /*大家最关心的指标之二,指的是用户平均请求等待时间 相当于LR中的平均事务响应时间,后面括号中的mean表示这是一个平均值*/ Timeperrequest:743.726[ms](mean) /*大家最关心的指标之三,指的是服务器平均请求处理时间 Timeperrequest:74.373[ms](mean,acrossallconcurrentrequests) Transferrate:4.33[Kbytes/sec]received ConnectionTimes(ms) minmean[+/-sd]medianmax Connect:129163245.31453154 Processing:1295761510.814711756 Waiting:1295671502.014711756 Total:2617391543.729411888 Percentageoftherequestsservedwithinacertaintime(ms) 50%294 66%297 75%304 80%308 90%1290 95%3452 98%7582 99%7962 100%11888(longestrequest)
Requestspersecond:190.95[#/sec](mean) Timeperrequest:523.694[ms](mean) Timeperrequest:5.237[ms](mean,acrossallconcurrentrequests)
Requestspersecond:186.00[#/sec](mean) Timeperrequest:1149.433[ms](mean) Timeperrequest:5.747[ms](mean,acrossallconcurrentrequests)
Requestspersecond:180.99[#/sec](mean) Timeperrequest:2631.662[ms](mean) Timeperrequest:5.263[ms](mean,acrossallconcurrentrequests)