【Performance】ab 压测工具

Posted by 西维蜀黍 on 2021-07-18, Last Modified on 2021-09-21
  • -c (concurrency): Number of multiple requests to perform at a time. Default is one request at a time.
  • -n (requests): Number of requests to perform for the benchmarking session. The default is to just perform a single request which usually leads to non-representative benchmarking results.
  • -k: Enable the HTTP KeepAlive feature, i.e., perform multiple requests within one HTTP session. Default is no KeepAlive.
$ ab -k -n 500 -c 100 http://127.0.0.1:8080/example2
This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
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)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Finished 500 requests


Server Software:
Server Hostname:        127.0.0.1
Server Port:            8080

Document Path:          /example2
Document Length:        14 bytes

Concurrency Level:      100
Time taken for tests:   1.046 seconds
Complete requests:      500
Failed requests:        0
Keep-Alive requests:    500
Total transferred:      77500 bytes
HTML transferred:       7000 bytes
Requests per second:    478.03 [#/sec] (mean)
Time per request:       209.190 [ms] (mean)
Time per request:       2.092 [ms] (mean, across all concurrent requests)
Transfer rate:          72.36 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.9      0       3
Processing:     9  201 189.5    153    1004
Waiting:        9  201 189.5    153    1004
Total:          9  201 189.9    153    1007

Percentage of the requests served within a certain time (ms)
  50%    153
  66%    241
  75%    269
  80%    304
  90%    460
  95%    562
  98%    774
  99%    945
 100%   1007 (longest request)
  • -c (concurrency): Number of multiple requests to perform at a time. Default is one request at a time.
  • -n (requests): Number of requests to perform for the benchmarking session. The default is to just perform a single request which usually leads to non-representative benchmarking results.
  • -k: Enable the HTTP KeepAlive feature, i.e., perform multiple requests within one HTTP session. Default is no KeepAlive.

Reference


TOC