Apache 在达到 MaxClients 设置后停止服务

Apache 在达到 MaxClients 设置后停止服务

我的 Apache 服务器已配置了 worker MPM,如下所示:

<IfModule mpm_worker_module>
    ServerLimit         20
    ThreadLimit         50
    StartServers        3
    MaxClients          1000
    MinSpareThreads     50
    MaxSpareThreads     200
    ThreadsPerChild     50
    MaxRequestsPerChild 10000
</IfModule>

该服务器每天大约处理 200 万个请求。当请求出现时,apache 服务器将停止接受新连接(浏览器无法连接)。并且该进程将保留在进程列表中。内存使用率约为 10%,CPU 为 0%。看来 apache 服务器无法在应该回收进程时回收进程。

我在错误日志中发现了与崩溃相关的一些内容:

[Mon Aug 15 12:36:24 2011] [error] child process 11444 still did not exit, sending a SIGKILL
[Mon Aug 15 12:36:24 2011] [error] child process 12090 still did not exit, sending a SIGKILL
[Mon Aug 15 12:36:24 2011] [error] child process 10698 still did not exit, sending a SIGKILL
[Mon Aug 15 12:36:24 2011] [error] child process 12144 still did not exit, sending a SIGKILL
[Mon Aug 15 12:36:24 2011] [error] child process 12032 still did not exit, sending a SIGKILL
[Mon Aug 15 12:36:24 2011] [error] child process 10699 still did not exit, sending a SIGKILL
[Mon Aug 15 12:36:25 2011] [notice] caught SIGTERM, shutting down
[Mon Aug 15 12:37:31 2011] [notice] mod_python: Creating 8 session mutexes based on 20 max processes and 50 max threads.
[Mon Aug 15 12:37:31 2011] [notice] mod_python: using mutex_directory /tmp 
[Mon Aug 15 12:37:31 2011] [notice] Apache/2.2.17 (Ubuntu) mod_python/3.3.1 Python/2.7.1+ mod_ssl/2.2.17 OpenSSL/0.9.8o configured -- resuming normal operations
[Mon Aug 15 15:36:46 2011] [error] server is within MinSpareThreads of MaxClients, consider raising the MaxClients setting
[Mon Aug 15 15:38:48 2011] [error] server reached MaxClients setting, consider raising the MaxClients setting
[Mon Aug 15 16:17:31 2011] [warn] child process 766 still did not exit, sending a SIGTERM
[Mon Aug 15 16:17:31 2011] [warn] child process 767 still did not exit, sending a SIGTERM

有什么想法吗?谢谢!

答案1

您可能需要使用 mod_status 检查服务器状态。您可能有未断开的连接,但卡在“发送回复”状态 (W)。查看此文章,了解如何诊断此问题解决 httpd maxclients 和 modstatus 报告

相关内容