安装
brew install httpd
输入参数介绍
-n 请求数量
-c 并发数量
-t 总请求时间
-s 每次请求的超时时间
-v 每次请求的输出信息
示例
ab -n 100 -c 10 http://127.0.0.1:8000/api/photos/530
输出结果分析
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 127.0.0.1 (be patient).....done
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8000
Document Path: /api/photos/530
Document Length: 416 bytes
Concurrency Level: 10
Time taken for tests: 10.842 seconds
Complete requests: 100
Failed requests: 40
(Connect: 0, Receive: 0, Length: 40, Exceptions: 0)
Non-2xx responses: 40
Total transferred: 121790 bytes
HTML transferred: 87680 bytes
Requests per second: 9.22 [
Time per request: 1084.167 [ms] (mean)
Time per request: 108.417 [ms] (mean, across all concurrent requests)
Transfer rate: 10.97 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 1
Processing: 117 1025 207.8 1088 1314
Waiting: 114 1021 207.7 1084 1311
Total: 118 1025 207.7 1088 1314
Percentage of the requests served within a certain time (ms)
50% 1088
66% 1101
75% 1104
80% 1106
90% 1156
95% 1251
98% 1305
99% 1314
100% 1314 (longest request)