Apache Bench:为什么这么多503s?

时间:2012-07-31 18:40:00

标签: php linux performance apache apachebench

我在DreamHost上运行专用服务器:四核,4GB内存。

Linux(Debian),Apache,PHP(使用XCache进行操作码缓存),MySQL。

我查询的URL每次都有18个MySQL查询。

我想知道为什么当我做“ab -n 500 -c 50 http://< url > /”我得到以下结果:

Server Software:        Apache
Server Hostname:        <url>
Server Port:            80

Document Path:          /
Document Length:        162809 bytes

Concurrency Level:      50
Time taken for tests:   12.664 seconds
Complete requests:      500
Failed requests:        377
   (Connect: 0, Receive: 0, Length: 377, Exceptions: 0)
Write errors:           0
Non-2xx responses:      377
Total transferred:      20291876 bytes
HTML transferred:       20147278 bytes
Requests per second:    39.48 [#/sec] (mean)
Time per request:       1266.372 [ms] (mean)
Time per request:       25.327 [ms] (mean, across all concurrent requests)
Transfer rate:          1564.81 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.4      0       2
Processing:   194 1190 1617.0    248    6060
Waiting:      194  965 1263.9    248    5190
Total:        194 1190 1617.0    248    6060

Percentage of the requests served within a certain time (ms)
  50%    248
  66%    359
  75%   1555
  80%   2787
  90%   3979
  95%   4709
  98%   5427
  99%   5967
 100%   6060 (longest request)

所有377个失败的请求都是503个。可能是什么导致了这个?在执行此操作时运行top看到我的处理器飙升至约24%,但并未过多征税。

我的CMS说,只需一次加载页面,加载基类需要.0017秒,控制器执行时间需要.1711秒,总执行时间为.1731秒,使用2.887 MB内存。 / p>

ab -n 100 -c 10总是有0个失败的请求,但似乎任何超过~25的并发连接都有一堆失败的连接。

我预计下周会有大量的流量,我怎样才能最好地准备我的服务器?这会保持原样吗?

编辑:来自我的httpd-mpm.conf文件,该文件包含在httpd.conf

<IfModule mpm_worker_module>
    StartServers          4
    MaxClients          600
    MinSpareThreads      50
    MaxSpareThreads      150
    ThreadsPerChild      25
    MaxRequestsPerChild   0
</IfModule>

2 个答案:

答案 0 :(得分:1)

如果这是一个DreamHost服务器而不是VPS,可能是因为你已经用尽了你的CPU分享,他们就是在杀死你的php进程。如果您的某个进程占用了太多资源或传入连接太多,它将被终止并且网络服务器将返回503。

我不知道这些限制设置了什么,但是someone from dreamhost explains in this thread

  

您的网站可以在DH上处理内存和连接的限制。如果您遇到许多使用过多资源的访问者,您将收到503错误。也许你的网站三年后变得太大了?如果没有关于访问者数量和使用过的软件的更多信息,我们只能推测。

答案 1 :(得分:0)

这可能是由一些不同的事情造成的

  1. 您的网络服务器达到了打开文件限制(检查ulimit)
  2. 如果您使用FPM,则可能超出了子限制(检查fpm配置)
  3. 您可以超出连接限制(检查sysctl.conf)
  4. 您应该做的第一件事是检查nginx或apache日志。