ab(apache bench)是apache下的一个工具,主要用于对web站点做压力测试,
基础用法:
其中-c选项为一次发送的请求数量,及并发量。
-n选项为请求次数。
实验测试:
- [dev@web ~]$ ab -c 20 -n 50000 http://192.168.1.210/
- This is ApacheBench, Version 2.3 <$Revision: 655654 $>
- 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.210 (be patient)
- Completed 5000 requests
- Completed 10000 requests
- Completed 15000 requests
- Completed 20000 requests
- Completed 25000 requests
- Completed 30000 requests
- Completed 35000 requests
- Completed 40000 requests
- Completed 45000 requests
- Completed 50000 requests
- Finished 50000 requests
- Server Software: nginx/1.6.2
- Server Hostname: 192.168.1.210
- Server Port: 80
- Document Path: /
- Document Length: 41005 bytes # 请求的页面大小
- Concurrency Level: 20 # 并发量
- Time taken for tests: 1180.733 seconds # 测试总共耗时
- Complete requests: 50000 # 完成的请求
- Failed requests: 0 # 失败的请求
- Write errors: 0 # 错误
- Total transferred: 2067550000 bytes # 总共传输数据量
- HTML transferred: 2050250000 bytes
- Requests per second: 42.35 [#/sec] (mean) # 每秒钟的请求量。(仅仅是测试页面的响应速度)
- Time per request: 472.293 [ms] (mean) # 等于 Time taken for tests/(complete requests/concurrency level) 即平均请求等待时间(用户等待的时间)
- Time per request: 23.615 [ms] (mean, across all concurrent requests) # 等于 Time taken for tests/Complete requests 即服务器平均请求响应时间 在并发量为1时 用户等待时间相同
- Transfer rate: 1710.03 [Kbytes/sec] received # 平均每秒多少K,即带宽速率
- Connection Times (ms)
- min mean[+/-sd] median max
- Connect: 0 1 18.5 0 1001
- Processing: 38 471 534.1 155 9269
- Waiting: 37 456 524.6 147 9259
- Total: 40 472 534.5 155 9269
- Percentage of the requests served within a certain time (ms)
- 50% 155
- 66% 571
- 75% 783
- 80% 871
- 90% 1211
- 95% 1603
- 98% 1839
- 99% 2003
- 100% 9269 (longest request)