为什么 wrk 和 ab, locust 压测的结果差异这么大?

2019-10-15 11:23:43 浏览数 (1)

本地使用 wrk 压测 nginx 的一个 hello,world!接口。wrk 的 qps 是 20 多万,全部 200 状态吗,无异常。ab 结果是 1 万多的 qps,locust 只有 6 千多的 qps。本机 32 核 CPU,结果差异这么大,请问该相信哪个呢?

下面是压测过程:

  • wrk
代码语言:javascript复制
./wrk -c 10000 -d 20  http://localhost:8080/status
Running 20s test @ http://localhost:8080/status
  2 threads and 10000 connections
  Thread Stats   Avg      Stdev     Max    /- Stdev
    Latency     2.51ms  654.52us  14.36ms   90.56%
    Req/Sec   105.08k     6.58k  133.08k    72.08%
  4150775 requests in 20.10s, 783.58MB read
  Socket errors: connect 8981, read 0, write 0, timeout 0
Requests/sec: 206509.01
Transfer/sec:     38.98MB

查看请求数量cat access.log|wc -l,结果4089174,打开检查都是 200 状态吗,无错误。ab 压测-c 10000 报错,为了一致,使用 wrk 压测-c 1000,qps 的值为216547.69

  • ab
代码语言:javascript复制
ab -c 1000 -n 200000 http://localhost:8080/status
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 20000 requests
Completed 40000 requests
Completed 60000 requests
Completed 80000 requests
Completed 100000 requests
Completed 120000 requests
Completed 140000 requests
Completed 160000 requests
Completed 180000 requests
Completed 200000 requests
Finished 200000 requests


Server Software:        openresty/1.13.6.1
Server Hostname:        localhost
Server Port:            8080

Document Path:          /status
Document Length:        12 bytes

Concurrency Level:      1000
Time taken for tests:   18.040 seconds
Complete requests:      200000
Failed requests:        0
Total transferred:      31000000 bytes
HTML transferred:       2400000 bytes
Requests per second:    11086.72 [#/sec] (mean)
Time per request:       90.198 [ms] (mean)
Time per request:       0.090 [ms] (mean, across all concurrent requests)
Transfer rate:          1678.17 [Kbytes/sec] received

Connection Times (ms)
              min  mean[ /-sd] median   max
Connect:        0   40  51.9     37    1048
Processing:     1   50  11.8     49     243
Waiting:        1   37  13.2     33     221
Total:          2   90  52.7     89    1104

Percentage of the requests served within a certain time (ms)
  50%     89
  66%     91
  75%     93
  80%     94
  90%     99
  95%    104
  98%    113
  99%    129
 100%   1104 (longest request)

加上 -k参数 qps 就只有 9800。

  • locust

启动了一个 master,28 个 slave,结果 qps 只有 6700 左右,请问哪个比较接近真实?

接口就是直接安装 openresty,无优化,配置里面 echo "hello,world!"

0 人点赞