希望有人能指出我正确的方向,因为我已经花了上周的时间来试图找出“问题”在哪里,但一直未能,尝试张贴到Apache用户邮件列表,但要在这里反弹以及。
在CentOS 5.8上运行Apache 2.2.3 mod_php。
与此同时,每天当stream量很大时,我们遇到了一个问题,即Apache不再响应任何HTTP请求。
这听起来像一个标准的MaxClients达成的问题,但似乎并非如此。
另外,在此期间login到机器的平均负载不到1,并且仍然有足够的RAM可用。
回顾/ var / log / httpd / error_log我注意到了以下模式:
[Mon Apr 30 07:00:34 2012] [info] server seems busy, (you may need to increaseStartServers, or Min/MaxSpareServers), spawning 32 children, there are 0 idle, and 905 total children [Mon Apr 30 07:00:35 2012] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 32 children, there are 0 idle, and 937 total children [Mon Apr 30 07:00:36 2012] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 32 children, there are 0 idle, and 969 total children [Mon Apr 30 07:00:37 2012] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 32 children, there are 35 idle, and 1001 total children [Mon Apr 30 07:00:42 2012] [debug] mpm_common.c(663): (70007)The timeout specified has expired: connect to listener on [::]:80 <br> [Mon Apr 30 07:00:49 2012] [debug] mpm_common.c(663): (70007)The timeout specified has expired: connect to listener on [::]:80 <br> [Mon Apr 30 07:00:56 2012] [debug] mpm_common.c(663): (70007)The timeout specified has expired: connect to listener on [::]:80 <br> [Mon Apr 30 07:01:03 2012] [debug] mpm_common.c(663): (70007)The timeout specified has expired: connect to listener on [::]:80 <br>
每天几次,在1000 total children Apache之后,Apache停止响应,并且必须重新启动才能重新工作。
我已经回顾了几周前的error_log,它是相同的模式,服务器击中1000 [debug] mpm_common.c(663): (70007)The timeout specified has expired: connect to listener on [::]:80 ,然后立即吐出[debug] mpm_common.c(663): (70007)The timeout specified has expired: connect to listener on [::]:80错误信息并停止响应。
然而,在服务器上的负载是相当低的…即使我试图请求一个简单的index.html文件超时。
这里是configuration的相关部分:
Timeout 45 KeepAlive On MaxKeepAliveRequests 10000 KeepAliveTimeout 3 <IfModule prefork.c> StartServers 80 MinSpareServers 50 MaxSpareServers 120 ServerLimit 3500 MaxClients 3500 MaxRequestsPerChild 2000 </IfModule>
任何人都知道为什么在停止处理更多的请求之前,Apache能够达到的神奇数字是1000?
或者如何理解(70007)The timeout specified has expired: connect to listener on [::]:80消息的(70007)The timeout specified has expired: connect to listener on [::]:80 ?
什么“超时指定”是指?
我仔细检查了最大打开文件,它以前是在1024年,但现在在16384,仍然是同样的问题。
这是一个远射,但我有像这样的问题。 我不记得是什么错误信息,但问题的原因一直是一个错误的PHP程序,它创buildrecursion请求(即程序请求一个URL,反过来又重新请求相同的URL等)。 我已经看到这个例如与ErrorDocument设置有关,应该处理错误的文档是错误的或不存在的,并且触发错误。
你可以很容易地validation这是否是access.log中的问题:你应该在很短的时间内从服务器的IP地址获得大量的请求。 这可以工作,直到您点击MaxClients设置或直到您的系统资源耗尽。 唯一的解决办法是修复有问题的PHP程序。
Timeout 45
我相信这是指这个超时。 可能是某些东西在打开连接,然后什么都不做(即客户端在打开连接之后没有发送任何东西,或者在你写入数据给客户端后,你的脚本没有closures连接),Apache等待放弃之前45秒。 然后closures连接。 你可以降低这个,所以Apache超时连接尝试更快,但更好的解决scheme是试图确定为什么发生这一切。
http://httpd.apache.org/docs/2.1/mod/core.html#timeout
也许也看看这个页面的一般性能问题?
检查Apache的KeepAlive是否开启,KeepAliveTimeout的值是多less。 真的不应该超过3秒。 它将保留那个时间分配给客户端的特定进程/线程。
然后grep httpd的conf目录1000,看看这个号码设置的地方。
grep -r '1000' /etc/httpd/conf grep -r '1000' /etc/httpd/conf.d
除此之外,可能会出现这样的情况:您的php代码(错误地)将每个正在处理它的进程/线程无限期地保持活动状态,您将无法使用它们。