【问题标题】:I optimized my server but still can't go over 500 Requests per second on ApacheBench我优化了我的服务器,但在 ApacheBench 上仍然不能超过每秒 500 个请求
【发布时间】:2016-11-10 02:55:30
【问题描述】:

我正在使用:

  • EC2 c4.2xlarge(16 CPU,32 GB RAM)
  • RDS MYSQL 数据库 db.m4.2xlarge
  • 亚马逊 Linux
  • 阿帕奇 2.4
  • php 5.5
  • Zend OPcache v7.0.6-dev

/etc/httpd/conf.modules.d/00-mpm.conf如下

LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
StartServers 100
MinSpareServers 100
MaxSpareServers 200
ServerLimit 2000
MaxClients 2000
MaxRequestsPerChild 0

当我用

进行压力测试时
ab -t 30 -c 2000

我得到以下信息:


Document Path:          /
Document Length:        46135 bytes

Concurrency Level:      2000
Time taken for tests:   30.006 seconds
Complete requests:      15333
Failed requests:        2
   (Connect: 0, Receive: 0, Length: 2, Exceptions: 0)
Write errors:           0
Non-2xx responses:      2
Total transferred:      717478783 bytes
HTML transferred:       707298139 bytes
Requests per second:    511.00 [#/sec] (mean)
Time per request:       3913.883 [ms] (mean)
Time per request:       1.957 [ms] (mean, across all concurrent requests)
Transfer rate:          23350.93 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0  260 1261.9      0   15035
Processing:    19 1466 3797.3    229   26242
Waiting:       18 1465 3797.3    228   26236
Total:         19 1726 4323.8    232   29231

Percentage of the requests served within a certain time (ms)
  50%    232
  66%    520
  75%   2046
  80%   2109
  90%   4098
  95%   7536
  98%  20550
  99%  26805
 100%  29231 (longest request)

16 个 CPU 不超过 40% 并且使用的 RAM 最大为 4GB 该网站是使用 codeigniter 的自定义 Ecomerce 应用程序

我的问题是为什么我在使用强大的服务器时仍然遇到每秒最多 500 个请求?

谢谢

【问题讨论】:

  • Apache 本身就是一个瓶颈。

标签: php apache optimization amazon-ec2


【解决方案1】:

根据您提供的结果,我认为没有绝对的答案。您必须通过测量本地和远程资源消耗来找到瓶颈,例如CPU、网络、内存。

我假设您调用了应用程序的起始页。这可能不是最有效的页面,因为它必须加载资源、启动会话等,所以你得到的实际上可能还不错。

【讨论】:

  • 16 个 CPU 中的大部分 CPU 最多使用 40%,并且使用的 RAM 不超过 4 GB !!
  • 所以它就像服务器仍然有资源可用。您是否更改了测试以包括更多/更少的客户,或者可能是不同的登录页面,例如只是静态html?
猜你喜欢
  • 2015-11-24
  • 1970-01-01
  • 1970-01-01
  • 2023-04-10
  • 2016-03-18
  • 2020-01-12
  • 1970-01-01
  • 1970-01-01
  • 2022-10-23
相关资源
最近更新 更多