Link

ab 介绍

目录

  1. ab 介绍
    1. 安装
    2. 常见用法
    3. 结果分析

ab 全称 apache bench,是 Apache 自带的一个性能测试工具

安装

yum -y install httpd-tools

常见用法

- Execute 100 HTTP GET requests to a given URL:
    ab -n 100 url

- Execute 100 HTTP GET requests, processing up to 10 requests concurrently, to given URL:
    ab -n 100 -c 10 url

- Use keep alive:
    ab -k url

- Set the maximum number of seconds to spend for benchmarking:
    ab -t 60 url

- Execute 100 HTTP POST requests to a given URL, using a JSON payload from a file:
    ab -n 100 -T application/json -p data.json url

结果分析

#服务器信息
Server Software:        nginx/1.17.4
Server Hostname:        10.10.50.33
Server Port:            80

# 访问路径,长度
Document Path:          /
Document Length:        324 bytes

#并发数 100
Concurrency Level:      100
#总测试时间
Time taken for tests:   3.737 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      5570000 bytes
HTML transferred:       3240000 bytes
# RPS 每秒请求数
Requests per second:    2676.22 [#/sec] (mean)
# 每个请求的平均响应时间
Time per request:       37.366 [ms] (mean)
# 每个请求的平均响应时间除以并发数
Time per request:       0.374 [ms] (mean, across all concurrent requests)
# 传输速率
Transfer rate:          1455.72 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        2   15  34.0      8     456
Processing:     2   18  51.2      9     621
Waiting:        2   17  50.3      8     620
Total:          5   33  62.1     17     652

Percentage of the requests served within a certain time (ms)
# 50% 的请求在 17ms 内完成
  50%     17
  66%     19
  75%     21
  80%     25
  90%     52
  95%    107
  98%    241
  99%    277
 100%    652 (longest request)

参考资料:

https://blog.csdn.net/lemontree1945/article/details/79818485

[https://www.infoq.cn/article/k9kx0RxEbhhtiluT9iV](https://www.infoq.cn/article/k9kx0RxEbhhtiluT9iV)