如何停止 FCGI 进程中的随机上升终止服务器

如何停止 FCGI 进程中的随机上升终止服务器

因此今天早些时候得到了下面的内容...

大约在那个时候,日志显示进程(600)、相关内存(1.2g)、CPU 使用率负载平均(80)不断增加,直到服务器崩溃。

由于没有 ssh 或 plesk 面板访问,因此服务器必须由主机进行硬重置。

Fast CGI 配置如下,用于一个高使用率站点。据我了解,FcgidMaxProcesses 20 应该可以防止发生这种情况,但事实并非如此。

我读过许多论坛,那里有各种不同的答案,也提到了许多不同的 fcgi 指令,但都没有找到定论。有没有人能给出一些明确的答案,说明如何阻止这种服务器进程加速和随后的服务器故障?

如果您需要更多信息,请告诉我。

欢呼 Andy

 /var/log/apache2/error_log
[Thu May 17 07:40:47 2012] [warn] mod_fcgid: process 17651 graceful kill fail, sending SIGKILL
[Thu May 17 07:40:47 2012] [warn] mod_fcgid: process 17650 graceful kill fail, sending SIGKILL
[Thu May 17 07:40:47 2012] [warn] mod_fcgid: process 17649 graceful kill fail, sending SIGKILL
[Thu May 17 07:40:47 2012] [warn] mod_fcgid: process 17644 graceful kill fail, sending SIGKILL
[Thu May 17 07:40:47 2012] [warn] mod_fcgid: process 17643 graceful kill fail, sending SIGKILL
[Thu May 17 07:40:47 2012] [warn] mod_fcgid: process 17638 graceful kill fail, sending SIGKILL
[Thu May 17 07:40:47 2012] [warn] mod_fcgid: process 17633 graceful kill fail, sending SIGKILL
[Thu May 17 07:40:47 2012] [warn] mod_fcgid: process 17627 graceful kill fail, sending SIGKILL
[Thu May 17 07:40:47 2012] [warn] mod_fcgid: process 17622 graceful kill fail, sending SIGKILL
[Thu May 17 07:40:51 2012] [warn] mod_fcgid: process 17674 graceful kill fail, sending SIGKILL
[Thu May 17 07:40:51 2012] [warn] mod_fcgid: process 17673 graceful kill fail, sending SIGKILL
[Thu May 17 07:40:51 2012] [warn] mod_fcgid: process 17672 graceful kill fail, sending SIGKILL
[Thu May 17 07:40:51 2012] [warn] mod_fcgid: process 17667 graceful kill fail, sending SIGKILL
[Thu May 17 07:40:51 2012] [warn] mod_fcgid: process 17666 graceful kill fail, sending SIGKILL
[Thu May 17 07:40:51 2012] [warn] mod_fcgid: process 17665 graceful kill fail, sending SIGKILL
[Thu May 17 07:40:51 2012] [warn] mod_fcgid: process 17664 graceful kill fail, sending SIGKILL
[Thu May 17 07:40:51 2012] [warn] mod_fcgid: process 17659 graceful kill fail, sending SIGKILL
[Thu May 17 07:40:51 2012] [warn] mod_fcgid: process 17658 graceful kill fail, sending SIGKILL
[Thu May 17 07:40:51 2012] [warn] mod_fcgid: process 17657 graceful kill fail, sending SIGKILL
[Thu May 17 07:40:51 2012] [warn] mod_fcgid: process 17656 graceful kill fail, sending SIGKILL
[Thu May 17 07:40:51 2012] [warn] mod_fcgid: process 17651 graceful kill fail, sending SIGKILL

https://docs.google.com/a/thesugarrefinery.com/open?id=0B_XbpWChge0VRmFLWEZfR2VBb2M https://docs.google.com/a/thesugarrefinery.com/open?id=0B_XbpWChge0VWTcwZEhoV2Fqejg https://docs.google.com/a/thesugarrefinery.com/open?id=0B_XbpWChge0VUUtVWWFINHZjZ0U https://docs.google.com/a/thesugarrefinery.com/open?id=0B_XbpWChge0VZEVMclh6ZUdaOUE

<IfModule mod_fcgid.c>

<IfModule !mod_fastcgi.c>
    AddHandler fcgid-script fcg fcgi fpl
</IfModule>
  FcgidIPCDir /var/lib/apache2/fcgid/sock
  FcgidProcessTableFile /var/lib/apache2/fcgid/shm

  FcgidIdleTimeout 40
  FcgidProcessLifeTime 30
  FcgidMaxProcesses 20
  FcgidMaxProcessesPerClass 20
  FcgidMinProcessesPerClass 0
  FcgidConnectTimeout 30
  FcgidIOTimeout 120
  FcgidInitialEnv RAILS_ENV production
  FcgidIdleScanInterval 10
  FcgidMaxRequestLen 1073741824
</IfModule>

答案1

Debian 中至少有一个错误,导致虚拟主机的限制无效。现已修复。

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=615814

答案2

这通常是由挂起的 setuid CGI 脚本引起的;它超过了 IOtimeout,并且 apache 尝试终止它,但由于 uid 的变化而无法终止,从而导致错误。

您可能需要增加 FcgidIOTimeout 或 FcgidProcessLifetime 以允许线程有更多时间完成。

另一个解决方法是让 Apache 服务器在 setuid 脚本要更改为的相同 UID 下运行。这样它就可以终止进程,但出于安全原因,这可能并不可取。同样,以 root 身份运行 apache 也是一种解决方法,但不太安全。如果这样做,请注意您的 fcgi sock 目录(在 /var/lib/apache2/fcgid/sock 或类似目录下)和进程表文件需要由 apache 进程所有者可写入。

但根本原因是 CGI 脚本本身耗时太长。其原因取决于 CGI 代码,而我对它一无所知。

相关内容