Apache Beach 压力测试

365 阅读1分钟

安装

  • macos
brew install httpd

输入参数介绍

  1. -n 请求数量
  2. -c 并发数量
  3. -t 总请求时间
  4. -s 每次请求的超时时间
  5. -v 每次请求的输出信息

示例

# 10个客户端,每个发出100次请求
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 # 返回状态码不属于2xx
Total transferred:      121790 bytes
HTML transferred:       87680 bytes
Requests per second:    9.22 [#/sec] (mean)
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)