微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在 Apache Bench 中生成 1Gbps?

如何解决如何在 Apache Bench 中生成 1Gbps?

  1. 我有一个带有 16GB RAM 的 i7 处理器(8 核)
  2. 我已经安装了 Windows Docker
  3. 我已经创建了一个 Ubuntu docker 实例
  4. 在 Ubuntu 实例中,我安装了 Nginx(8 个工人)
  5. 在 Ubuntu 实例中,我安装了 Apache Bench (ab)
  6. 在 Ubuntu 实例中,我设置了如下所示的高 ulimit 值

# 个 ulimit 值

root@c8c1c6a106c2:/# ulimit -a
core file size          (blocks,-c) 0
data seg size           (kbytes,-d) unlimited
scheduling priority             (-e) 0
file size               (blocks,-f) unlimited
pending signals                 (-i) 24682
max locked memory       (kbytes,-l) 82000
max memory size         (kbytes,-m) unlimited
open files                      (-n) 1048576
pipe size            (512 bytes,-p) 8
POSIX message queues     (bytes,-q) 819200
real-time priority              (-r) 0
stack size              (kbytes,-s) 8192
cpu time               (seconds,-t) unlimited
max user processes              (-u) unlimited
virtual memory          (kbytes,-v) unlimited
file locks                      (-x) unlimited
root@c8c1c6a106c2:/#

现在,当我运行以下 ab 命令时,在 Ubuntu 实例中,我只得到 137.73 KBytes/sec (1.1MBits/sec)。虽然我的网卡可以支持10Gbps,但为什么吞吐量很低,我该如何改进?

root@c8c1c6a106c2:/# ab -c 20000 -n 200000 http://localhost/
This is ApacheBench,Version 2.3 <$Revision: 1843412 $>
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:        Nginx/1.18.0
Server Hostname:        localhost
Server Port:            80

Document Path:          /
Document Length:        612 bytes

Concurrency Level:      20000
Time taken for tests:   79.265 seconds
Complete requests:      200000
Failed requests:        383419
   (Connect: 0,Receive: 0,Length: 196509,Exceptions: 186910)
Total transferred:      11178860 bytes
HTML transferred:       8011080 bytes
Requests per second:    2523.17 [#/sec] (mean)
Time per request:       7926.525 [ms] (mean)
Time per request:       0.396 [ms] (mean,across all concurrent requests)
Transfer rate:          137.73 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0 5617 2756.1   6147   13044
Processing:    77 1725 2069.8    461   13055
Waiting:        0  122 792.8      0    8190
Total:       4238 7342 2197.9   6903   20681

Percentage of the requests served within a certain time (ms)
  50%   6903
  66%   7217
  75%   8236
  80%   8263
  90%  10447
  95%  12159
  98%  13138
  99%  14928
 100%  20681 (longest request)
root@c8c1c6a106c2:/#

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。