ab是apache自带的网站压力测试工具。
使用起来非常的简单和方便。
不仅仅是可以apache服务器进行网站访问压力测试,还可以对其他类型的服务器进行压力测试。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
Usage: ab.exe [options] [http://]hostname[:port]/path 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) |
举例:
ab.exe -c5000 -n50000 -k http://192.168.1.101/
结果返回,为了方便,省略部分中间请求文字显示,同时为了方便讲解,在请求回来的地方予以注释说明:
8核/4G内存 虚拟机 Nginx 静态文档 压测结果
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
This is ApacheBench, Version 2.3 <$Revision: 1874286 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 192.168.1.101 (be patient) Completed 5000 requests ......(中间过程省略,5000一个一个的数) Finished 50000 requests Server Software: nginx/1.18.0 //服务器软件版本 Server Hostname: 192.168.1.101 //服务器主机 Server Port: 80 //服务器端口 Document Path: / //文档路径 Document Length: 13 bytes //单个文档大小 Concurrency Level: 5000 //并发数量 Time taken for tests: 5.310 seconds //测试完成时间 Complete requests: 50000 //完成请求数量 Failed requests: 0 //失败请求数量 Keep-Alive requests: 50000 //保持长链接请求数量 Total transferred: 13150000 bytes //总的请求字节数 HTML transferred: 650000 bytes //返回请求字节数 Requests per second: 9416.54 [#/sec] (mean) //每秒处理请求数量 Time per request: 530.980 [ms] (mean) //平均响应时间 Time per request: 0.106 [ms] (mean, across all concurrent requests) //平均请求处理时间 Transfer rate: 2418.51 [Kbytes/sec] received //每秒网络传输的数据量 Connection Times (ms) //消耗时间分析 min mean[+/-sd] median max Connect: 0 0 0.3 0 19 Processing: 53 385 373.4 246 2306 Waiting: 1 384 373.3 246 2305 Total: 53 385 373.5 246 2306 Percentage of the requests served within a certain time (ms) //请求处理分布百分比 50% 246 66% 312 75% 417 80% 447 90% 737 95% 1242 98% 1801 99% 2042 100% 2306 (longest request) //50%的用户响应时间小于246ms //66%的用户响应时间小于312ms |
关键参数:
|
1 |
<strong>Requests per second</strong> |