ApacheBench大雜燴
ApacheBench是命令列下一個常用的HTTP服務壓力測試工具。
ApacheBench使用示例
1. 測試百度首頁一次
ab www.baidu.com/
預設情況下,ApacheBench只進行一次測試。
注意: URL必須至少有一個斜槓,否則ApacheBench不識別。
控制檯輸出
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 www.baidu.com (be patient).....done Server Software:BWS/1.1 Server Hostname:www.baidu.com Server Port:80 Document Path:/ Document Length:153011 bytes Concurrency Level:1 Time taken for tests:0.048 seconds Complete requests:1 Failed requests:0 Total transferred:153973 bytes HTML transferred:153011 bytes Requests per second:21.04 [#/sec] (mean) Time per request:47.533 [ms] (mean) Time per request:47.533 [ms] (mean, across all concurrent requests) Transfer rate:3163.37 [Kbytes/sec] received Connection Times (ms) minmean[+/-sd] medianmax Connect:12120.01212 Processing:35350.03535 Waiting:13130.01313 Total:48480.04848
2. 壓測百度首頁,4併發共40個請求
ab -n 40 -c 4 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/ Benchmarking www.baidu.com (be patient).....done Server Software:BWS/1.1 Server Hostname:www.baidu.com Server Port:80 Document Path:/ Document Length:153337 bytes Concurrency Level:4 Time taken for tests:5.136 seconds Complete requests:40 Failed requests:39 (Connect: 0, Receive: 0, Length: 39, Exceptions: 0) Total transferred:6166547 bytes HTML transferred:6127863 bytes Requests per second:7.79 [#/sec] (mean) Time per request:513.563 [ms] (mean) Time per request:128.391 [ms] (mean, across all concurrent requests) Transfer rate:1172.59 [Kbytes/sec] received Connection Times (ms) minmean[+/-sd] medianmax Connect:461 234.661086 Processing:30407 568.12973302 Waiting:61841.010266 Total:34468 610.23163309 Percentage of the requests served within a certain time (ms) 50%316 66%433 75%584 80%671 90%1088 95%1757 98%3309 99%3309 100%3309 (longest request)
可見,這些請求最短耗時34毫秒,最長耗時3309毫秒,平均耗時468毫秒