如果是在win环境下,有apache就会有ab.exe,要注意,线下压力测试中,测试机与服务器尽量不要部署在同一台机器,避免测试误差较大。
输入命令:并发100 总请求1000
apache/bin >ab -c 100 -n 5000 http://localhost:88/fpatent/index
结果如下:
Server Software: Apache/2.4.18
Server Hostname: localhost
Server Port: 89
Document Path: /patent/batch
Document Length: 0 bytes
Concurrency Level: 100 //并发请求数
Time taken for tests: 28.490 seconds //整个测试持续时间
Complete requests: 1000 //完成的请求数
Failed requests: 0 //失败请求数
Non-2xx responses: 1000
Total transferred: 267000 bytes //网络传输总量
HTML transferred: 0 bytes //html文件传输总量
Requests per second: 35.10 [#/sec] (mean) //每秒请求数QPS
Time per request: 2849.013 [ms] (mean) //用户平均请求等待时间
Time per request: 28.490 [ms] (mean, across all concurrent requests) //服务器平均请求处理时间
Transfer rate: 9.15 [Kbytes/sec] received //平均每秒网络流量
Percentage of the requests served within a certain time (ms)
50% 354
66% 1170
75% 1970
80% 2404
90% 6166
95% 11221
98% 19012
99% 25984
100% 4582 (longest request)
请求处理时间分布情况,50%的请求在354ms内,重点是90%的请求在6166ms,等待时间较长,需要优化
注意ab所在机器的cpu 内存 网络 尽量不要超过限度的75%