ab is a tool for benchmarking your Apache Hypertext Transfer Protocol (HTTP) server. It is designed to give you an impression of how your current Apache installation performs. This especially shows you how many requests per second your Apache installation is capable of serving.
2、官网
2.1、文档地址
http://httpd.apache.org/docs/2.4/programs/ab.html
2.2、如何找到文档
2.3、下载安装
3、用法
3.1、测试GET请求
D:\Apache24\bin>ab -n 200 -c 100 http://www.baidu.com/
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Server Software: BWS/1.1 Server Hostname: www.baidu.com Server Port: 80
Document Path: / Document Length: 114870 bytes
Concurrency Level: 100 Time taken for tests: 3.065 seconds Complete requests: 200 Failed requests: 192 (Connect: 0, Receive: 0, Length: 192, Exceptions: 0) Total transferred: 23169728 bytes HTML transferred: 22986269 bytes Requests per second: 65.25 [#/sec] (mean) Time per request: 1532.640 [ms] (mean) Time per request: 15.326 [ms] (mean, across all concurrent requests) Transfer rate: 7381.61 [Kbytes/sec] received
Connection Times (ms) min mean[+/-sd] median max Connect: 1 14 8.4 12 67 Processing: 39 1183 540.3 1400 2163 Waiting: 6 613 422.4 595 1368 Total: 47 1198 539.8 1414 2168
Percentage of the requests served within a certain time (ms) 50% 1414 66% 1514 75% 1565 80% 1603 90% 1773 95% 1865 98% 2062 99% 2074 100% 2168 (longest request)
D:\Apache24\bin>
D:\Apache24\bin>ab -n 100 -c 50 http://localhost:8080/coupon/getByMechantId.json?merchantId=10002
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient).....done
Server Software: Server Hostname: localhost Server Port: 8080
Concurrency Level: 50 Time taken for tests: 0.361 seconds Complete requests: 100 Failed requests: 0 Total transferred: 117500 bytes HTML transferred: 103100 bytes Requests per second: 276.97 [#/sec] (mean) Time per request: 180.527 [ms] (mean) Time per request: 3.611 [ms] (mean, across all concurrent requests) Transfer rate: 317.81 [Kbytes/sec] received
Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.4 0 1 Processing: 18 90 44.7 87 178 Waiting: 18 87 45.0 83 177 Total: 18 90 44.8 87 178
Percentage of the requests served within a certain time (ms) 50% 87 66% 94 75% 144 80% 146 90% 152 95% 154 98% 178 99% 178 100% 178 (longest request)
D:\Apache24\bin>
3.2、测试POST请求
D:\Apache24\bin>ab -n 1000 -c 200 -p D:\data.json -T application/json http://localhost:8080/coupon/save.json
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: Server Hostname: localhost Server Port: 8080
Concurrency Level: 200 Time taken for tests: 3.306 seconds Complete requests: 1000 Failed requests: 0 Total transferred: 191000 bytes Total body sent: 433000 HTML transferred: 49000 bytes Requests per second: 302.52 [#/sec] (mean) Time per request: 661.121 [ms] (mean) Time per request: 3.306 [ms] (mean, across all concurrent requests) Transfer rate: 56.43 [Kbytes/sec] received 127.92 kb/s sent 184.35 kb/s total
Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.5 0 5 Processing: 18 589 432.2 603 2459 Waiting: 18 588 432.3 602 2459 Total: 19 589 432.2 603 2459
Percentage of the requests served within a certain time (ms) 50% 603 66% 662 75% 713 80% 742 90% 1210 95% 1270 98% 1805 99% 1848 100% 2459 (longest request)