使用 ApacheBench 进行轻量级压力测试
ApacheBench 是 Apache Http Server 附带的一个轻量级压力测试功能
先下载一个Apache Http Server :http://httpd.apache.org/
解压之后 进入 /bin 文件夹
ab -n 100 -c 10 http://www.abc.com
-n代表请求数
-c代表并发数
输出:
Server Software: Microsoft-IIS/7.5
Server Hostname: www.abc.com
Server Port: 80
Document Path: /
Document Length: 3677 bytes 请求返回的字节长度
Concurrency Level: 10 并发数
Time taken for tests: 45.686 seconds 压力测试总耗时
Complete requests: 100 请求数
Failed requests: 1 失败请求数
(Connect: 1, Receive: 0, Length: 0, Exceptions: 0)
Total transferred: 394300 bytes 本次测试一共传输的字节长度,包含http header的内容
HTML transferred: 367700 bytes 本次测试一共传输的html的字节长度,不包含http header
Requests per second: 2.19 [#/sec] (mean) 每秒请求数量,平均值
Time per request: 4568.557 [ms] (mean) 用户请求的处理时间,平均值 (一个用户可以有多个请求)
Time per request: 456.856 [ms] (mean, across all concurrent requests) 请求平均处理时间,平均值(非用户请求)
Transfer rate: 8.43 [Kbytes/sec] received 每秒获取数据的字节数
Connection Times (ms)
min mean[+/-sd] median max
Connect: 2 245 1102.4 5 8997
Processing: 31 4078 6221.8 3036 21046
Waiting: 6 2642 4873.6 39 21022
Total: 35 4323 6250.1 3042 21052
Percentage of the requests served within a certain time (ms)
50% 3042 百分之50的请求在3042毫秒返回
66% 3098
75% 6083
80% 6125
90% 12042
95% 21044
98% 21051
99% 21052
100% 21052 (longest request)