ab测试是业界比较流行和简单易用的一种压力测试工具包,本文将简要介绍其核心使用的方法
ab是Apache HTTP server benchmarking tool的缩写,可以用以测试HTTP请求的服务器性能。其是通过命令行的不同参数从而提供简单易用的性能测试工具命令组合。
参数说明: -n 请求数量, -c 并发数量
ab option url-address
Case 1: ab -n1000 -c10 http://www.sina.com.cn/index.html
结果信息如下:
fantasy@fantasy-PC / $ ab -n1000 -c10 http://www.sina.com.cn/index.html
This is ApacheBench, Version 2.3 <
Revision:1796539
R
e
v
i
s
i
o
n
:
1796539
>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking www.sina.com.cn (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: nginx
Server Hostname: www.sina.com.cn
Server Port: 80
Document Path: /index.html
Document Length: 21831 bytes
Concurrency Level: 10
Time taken for tests: 1.625 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 22403053 bytes
HTML transferred: 21831000 bytes
Requests per second: 615.28 [#/sec] (mean)
Time per request: 16.253 [ms] (mean)
Time per request: 1.625 [ms] (mean, across all concurrent requests)
Transfer rate: 13461.12 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 3 4 1.1 4 17
Processing: 8 12 7.5 10 80
Waiting: 4 7 6.7 6 73
Total: 11 16 7.8 14 84
Percentage of the requests served within a certain time (ms)
50% 14
66% 15
75% 15
80% 16
90% 20
95% 26
98% 37
99% 65
100% 84 (longest request)
参考资料
http://httpd.apache.org/docs/current/programs/ab.html
我们可以依照上面的示例 ,去测试不同网站 做出比较