apache AH00161:服务器已达到MaxRequestWorkers设置,请考虑提升MaxRequestWorkers设置

ssm49v7z  于 2023-03-24  发布在  Apache
关注(0)|答案(8)|浏览(428)

我有一个非常忙碌的服务器:PHP(WordPress)使用W3 TotalCache APC,Varnish for Apache和Cloudflare来处理所有流量。Ubuntu 14.04.4 LTS
只有一个网站,平均每天点击量约为6万次。
我时不时会收到这条消息,一天几次。与暂时的流量峰值无关,我们用谷歌分析比较了时间。

Thu Apr 28 14:14:42.938075 2016] [mpm_prefork:error] [pid 19137] AH00161: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting
[Thu Apr 28 15:43:25.594147 2016] [core:notice] [pid 19137] AH00051: child pid 19866 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Thu Apr 28 15:43:25.594313 2016] [core:notice] [pid 19137] AH00051: child pid 20386 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Thu Apr 28 15:43:25.594407 2016] [core:notice] [pid 19137] AH00051: child pid 19143 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Thu Apr 28 15:43:25.594498 2016] [core:notice] [pid 19137] AH00051: child pid 19144 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Thu Apr 28 15:43:25.594572 2016] [core:notice] [pid 19137] AH00051: child pid 20597 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Thu Apr 28 15:43:25.594642 2016] [core:notice] [pid 19137] AH00051: child pid 20395 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Thu Apr 28 15:43:25.594704 2016] [core:notice] [pid 19137] AH00051: child pid 20424 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Thu Apr 28 15:43:25.594785 2016] [core:notice] [pid 19137] AH00051: child pid 20598 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Thu Apr 28 15:43:25.594870 2016] [core:notice] [pid 19137] AH00051: child pid 19861 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Thu Apr 28 15:43:25.594957 2016] [core:notice] [pid 19137] AH00051: child pid 19782 exit signal Segmentation fault (11), possible coredump in /etc/apache2
....
....

所以我先把MaxRequestWorkers增加到100,然后是500,现在是1024。
这是我目前的apache2.conf。代码:

<IfModule mpm_worker_module>
StartServers 256
MinSpareThreads 256
MaxSpareThreads 256
MaxClients 256
ServerLimit 256
ThreadLimit 256
ThreadsPerChild 256
MaxRequestWorkers 1024
MaxConnectionsPerChild 0
MaxRequestPerChild 1000
</IfModule>

有大量的空闲RAM,平均负载在0.5左右,有时超过1。但从来没有见过它高于2。所以服务器似乎健康处理流量。

top - 16:07:47 up 3 days, 18:18,  2 users,  load average: 0.57, 0.46, 0.55
Tasks: 113 total,   1 running, 112 sleeping,   0 stopped,   0 zombie
%Cpu(s): 10.5 us,  2.0 sy,  0.0 ni, 87.4 id,  0.1 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:   8176816 total,  2372560 used,  5804256 free,   189684 buffers
KiB Swap:        0 total,        0 used,        0 free.  1286692 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                              
21930 www-data  20   0  337212  83308  60072 S  24.9  1.0   0:52.89 apache2                                                                                                                                              
21945 www-data  20   0  327640  72684  58816 S  24.3  0.9   0:48.37 apache2                                                                                                                                              
 1182 nobody    20   0  702868 442268  83496 S   0.7  5.4  42:41.32 varnishd

为什么Apache会中断?
//j

ar7v8xwq

ar7v8xwq1#

你应该编辑mpm_prefork

<IfModule mpm_prefork_module>
      StartServers                     10
      MinSpareServers               10
      MaxSpareServers              20
      ServerLimit                      2000
      MaxRequestWorkers         1500
      MaxConnectionsPerChild    10000
</IfModule>
hgncfbus

hgncfbus2#

基本上配置被覆盖在:/etc/apache 2/可用的修改/mpm_prefork.conf
我把新的设置在该文件中,现在看起来Apache工作正常。
希望这对其他人有帮助,不要把你的配置直接放在apache2.conf或httpd. conf中,确保你修改了所有加载的配置文件。

lxkprmvk

lxkprmvk3#

您修改了错误的文件。您的日志显示“mpm_prefork”错误。因此您需要修改mpm_prefork.conf而不是mpm_worker. conf。
你也可以使用“apachectl -M”来查看你正在使用的模块。例如,我的apache 2正在使用mpm_event_module,所以我需要修改mpm_event.conf

$ apache2ctl -M
Loaded Modules:
 core_module (static)
 so_module (static)
 watchdog_module (static)
 http_module (static)
 log_config_module (static)
 logio_module (static)
 version_module (static)
 unixd_module (static)
 access_compat_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 filter_module (shared)
 mime_module (shared)
 **mpm_event_module (shared)**
 negotiation_module (shared)
 setenvif_module (shared)
 status_module (shared)
 wsgi_module (shared)
c9x0cxw0

c9x0cxw04#

在我的例子中,我找不到任何解决方案,所以我将把这个答案留在这里,以帮助其他有这个问题的人。在我们的例子中,增加MaxRequestWorkers没有帮助。
我们有一台服务器,已经正常工作了至少一年。突然,它开始有问题,连接到https。在apache错误日志中,我们发现了一个“服务器达到MaxRequestWorkers”错误,但流量非常慢(30 - 40访问者活跃)。
在深入查看日志和一些研究之后,我发现问题是Slowloris DoS attack
这种攻击很容易缓解。你可以看看this post

lg40wkob

lg40wkob5#

我还尝试在我的服务器上增加MaxRequestWorkers,我没有看到任何效果。当我从命令行运行“httpd”时,我意识到发生了什么,它给了我这个警告:

AH00180: WARNING: MaxRequestWorkers of 512 exceeds ServerLimit value of
 256 servers, decreasing MaxRequestWorkers to 256.
 To increase, please see the ServerLimit directive.

在您的配置中,ServerLimit仍然是256,因此MaxRequestWorkers也被这个值限制。

bihw5rsg

bihw5rsg6#

您可能需要检查您的Web服务器访问日志。如果日志中充斥着xml-rpc帖子(例如“POST/xmlrpc.php HTTP/1.1”200 403),您可能会成为xml-rpc攻击的目标。有多种方法可以防止这种情况发生,但Wordpress很容易发生这种情况。

vdgimpew

vdgimpew7#

在我的例子中,在低响应速度之后,我首先将MaxRequestWorkers从150增加到500。但是在apache error.log中出现警告,我意识到我还应该增加ServerLimit,因为它的默认值是256。此外,我在mpm_prefork.conf中没有找到ServerLimit 256,所以我在其中添加了ServerLimit 512作为新的一行,问题解决了。

v09wglhw

v09wglhw8#

我有4个CPU和16GB内存,所以这个配置适合mpm_worker
StartServers 10 MinSpareServers 10 MaxSpareServers 20 ServerLimit 2000 MaxRequestWorkers 1500 MaxConnectionsPerChild 10000

相关问题