
参数说明
ab.exe是一个性能检测工具,是apache server中的一个小组件,使用简单,方便。
执行程序ab.exe位于apache项目bin目录下,使用cmd命令执行
Options are: -n requests Number of requests to perform -c concurrency Number of multiple requests to make at a time -t timelimit Seconds to max. to spend on benchmarking This implies -n 50000 -s timeout Seconds to max. wait for each response Default is 30 seconds -b windowsize Size of TCP send/receive buffer, in bytes -B address Address to bind to when making outgoing connections -p postfile File containing data to POST. Remember also to set -T -u putfile File containing data to PUT. Remember also to set -T -T content-type Content-type header to use for POST/PUT data, eg. 'application/x-www-form-urlencoded' Default is 'text/plain' -v verbosity How much troubleshooting info to print -w Print out results in HTML tables -i Use HEAD instead of GET -x attributes String to insert as table attributes -y attributes String to insert as tr attributes -z attributes String to insert as td or th attributes -C attribute Add cookie, eg. 'Apache=1234'. (repeatable) -H attribute Add Arbitrary header line, eg. 'Accept-Encoding: gzip' Inserted after all normal header lines. (repeatable) -A attribute Add Basic WWW Authentication, the attributes are a colon separated username and password. -P attribute Add Basic Proxy Authentication, the attributes are a colon separated username and password. -X proxy:port Proxyserver and port number to use -V Print version number and exit -k Use HTTP KeepAlive feature -d Do not show percentiles served table. -S Do not show confidence estimators and warnings. -q Do not show progress when doing more than 150 requests -l Accept variable document length (use this for dynamic pages) -g filename Output collected data to gnuplot format file. -e filename Output CSV file with percentages served -r Don't exit on socket receive errors. -m method Method name -h Display usage information (this message) -n 请求的总数,默认是1次。 -c 并发数,同一时间请求数。 -p 如果后面接的是文件,表示POST请求,文件中包含请求数据,根据数据格式,设置-T参数。 -T 设置请求头中的Content-type(针对POST/PUT),比如:application/x-www-form-urlencoded。默认是text/plain。 -w 将测试结果打印到HTML表格中。
命令示例
ab -c 10 -n 500 -p postdata.json -T application/json 192.168.1.80:8080/v1/js-executor/js
ab -c 1 -n 500 /
ab -c 10 -n 500 /
ab -c 20 -n 500 /
ab -c 20 -n 500 http://kanbook.net/ //不支持https
执行结果
Server Software: nginx Server Hostname: me.weiguo.blog Server Port: 80 Document Path: / Document Length: 14814 bytes Concurrency Level: 100 Time taken for tests: 0.655 seconds /*整个测试持续的时间*/ Complete requests: 100 /*完成的请求数量*/ Failed requests: 0 Total transferred: 1515700 bytes /*整个场景中的网络传输量*/ HTML transferred: 1481400 bytes /*整个场景中的HTML内容传输量*/ Requests per second: 152.76 [#/sec] (mean) /*每秒请求数,后面括号中的 mean 表示这是一个平均值*/ Time per request: 654.628 [ms] (mean) /*每次请求的响应时间 ,后面括号中的 mean 表示这是一个平均值*/ Time per request: 6.546 [ms] (mean, across all concurrent requests) /*平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题*/ Transfer rate: 2261.09 [Kbytes/sec] received /*网络上消耗的时间的分解,各项数据的具体算法还不是很清楚*/ Connection Times (ms) min mean[+/-sd] median max Connect: 3 6 1.6 7 9 Processing: 9 325 188.3 325 641 Waiting: 8 323 188.3 323 639 Total: 16 331 188.2 333 645 /*下面的内容为整个场景中所有请求的响应情况。在场景中每个请求都有一个响应时间,其中 50% 的用户响应时间小于 333 毫秒,60 % 的用户响应时间小于 439 毫秒,最大的响应时间小于 645 毫秒*/ Percentage of the requests served within a certain time (ms) 50% 333 66% 439 75% 499 80% 536 90% 592 95% 620 98% 641 99% 645 100% 645 (longest request)