Apache Bench
Whisper Lv5

下载

  1. 下载绿色版(无需装Apache)
  2. 解压后,把ab.exe​所在文件夹路径(比如D:\ab-tool​)添加到系统环境变量PATH
  3. 验证安装:打开cmd/终端,输入 ab -V​,输出版本号

常用参数

参数 说明 示例
-n 总请求数(压测一共发多少个请求) ​-n 1000​(发1000个)
-c 并发数(同时发多少个请求,模拟多用户) ​-c 100​(100并发)
-T 请求头Content-Type(POST请求必加) ​-T “application/x-www-form-urlencoded”​
-p POST请求的参数文件(参数多的时候用,比如登录的账号密码) ​-p params.txt​
-k 启用HTTP Keep-Alive(模拟真实用户的长连接,更贴近实际场景) ​-k​

输出解读

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Server Software:        nginx/1.21.6  # 服务器软件
Server Hostname: test-api.com # 接口域名
Server Port: 80

Document Path: /api/login/v1 # 测试接口
Document Length: 68 bytes # 响应体大小

Concurrency Level: 100 # 并发数
Time taken for tests: 1.201 seconds # 总耗时
Complete requests: 1000 # 成功的请求数
Failed requests: 0 # 失败请求数
Total transferred: 247000 bytes
HTML transferred: 68000 bytes
Requests per second: 832.67 [#/sec] (mean) # TPS(每秒处理请求数)
Time per request: 120.095 [ms] (mean) # 平均响应时间RT(核心)
Time per request: 1.201 [ms] (mea--
n, across all concurrent requests)
Transfer rate: 201.54 [Kbytes/sec] received

# 响应时间分布(参考)
Percentage of the requests served within a certain time (ms)
50% 115
66% 120
75% 125
80% 130
90% 140
95% 150
98% 160
99% 170
100% 200 (longest request)