php mod_fcgid:无法为错误应用进程槽

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5244632/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 20:43:35  来源:igfitidea点击:

mod_fcgid: can't apply process slot for error

phpapache2mod-fcgid

提问by faraklit

update: Just looked at the cache update times of long queries and they did not collide with server crash time.

update:只是查看了长查询的缓存更新时间,它们与服务器崩溃时间没有冲突。

update2: Found the cause of the problem. Ad server is down and the server hangs even though it seems we set socket timeouts properly. Is there any way to test timeout behaviour?

update2:找到问题的原因。广告服务器已关闭并且服务器挂起,即使我们似乎正确设置了套接字超时。有没有办法测试超时行为?

We have a very busy server. ~3K concurrent connections The server has 32GB ram 2xCPUs. We have service unavailable error issues. The server does not respond with 500 error and the error log shows hundreds/thousands of lines:

我们有一个非常繁忙的服务器。~3K 并发连接服务器有 32GB ram 2xCPUs。我们有服务不可用错误问题。服务器不响应 500 错误,错误日志显示成百上千行:

[warn] mod_fcgid: can't apply process slot for /var/www/fcgi-bin.d/php5-default/php-fcgi-wrapper

We think it can be a configuration error or a database connection/query error. A php process updates a cache which is a very very complex query result. 3 separate queries run each twice a day. I have enabled the slow query log. I suspect if the query exceeds the php run time limit 20 secs in our case (set in the following files). Any help is appreciated.

我们认为这可能是配置错误或数据库连接/查询错误。php 进程更新缓存,这是一个非常复杂的查询结果。3 个单独的查询每天运行两次。我启用了慢查询日志。我怀疑在我们的例子中查询是否超过了 php 运行时间限制 20 秒(在以下文件中设置)。任何帮助表示赞赏。

We use apache worker mpm model with mod_fcgid.

我们使用带有 mod_fcgid 的 apache worker mpm 模型。

Here is fcgid.conf file:

这是 fcgid.conf 文件:

<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi
SocketPath /var/lib/apache2/fcgid/sock

# Communication timeout: Default value is 20 seconds
IPCCommTimeout 20

# Connection timeout: Default value is 3 seconds

IPCConnectTimeout 3

And /etc/apache2/conf.d/php-fcgid.conf file:

和 /etc/apache2/conf.d/php-fcgid.conf 文件:

<IfModule !mod_php4.c>

# Path to php.ini <96> defaults to /etc/phpX/cgi DefaultInitEnv PHPRC=/etc/php5/cgi

# php.ini <96> 的路径默认为 /etc/phpX/cgi DefaultInitEnv PHPRC=/etc/php5/cgi

# Number of PHP childs that will be launched. Leave undefined to let PHP decide.
# DefaultInitEnv PHP_FCGI_CHILDREN 8

# Maximum requests before a process is stopped and a new one is launched
DefaultInitEnv PHP_FCGI_MAX_REQUESTS 5000
# Maximum requests a process handles before it is terminated
MaxRequestsPerProcess 1500
# Maximum number of PHP processes.
MaxProcessCount       45

# Define a new handler "php-fcgi" for ".php" files, plus the action that must follow
AddHandler php-fcgi .php
Action php-fcgi /fcgi-bin/php-fcgi-wrapper

# Define the MIME-Type for ".php" files
AddType application/x-httpd-php .php

# Define alias "/fcgi-bin/". The action above is using this value, which means that
# you could run another "php5-cgi" command by just changing this alias
Alias /fcgi-bin/ /var/www/fcgi-bin.d/php5-default/

# Turn on the fcgid-script handler for all files within the alias "/fcgi-bin/"
<Location /fcgi-bin/>
    SetHandler fcgid-script
    Options +ExecCGI
</Location>

Apache2 worker mpm config:

Apache2 工作者 mpm 配置:

<IfModule mpm_worker_module>
StartServers         10
MaxClients           2048
ServerLimit          2048
MinSpareThreads      30
MaxSpareThreads      100
ThreadsPerChild      64
ThreadLimit          100
MaxRequestsPerChild   5000

We looked at the instructions on this web page and loaded high server config: http://2bits.com/articles/apache-fcgid-acceptable-performance-and-better-resource-utilization.html

我们查看了此网页上的说明并加载了高服务器配置:http: //2bits.com/articles/apache-fcgid-acceptable-performance-and-better-resource-utilization.html

update: Just looked at the cache update times of long queries and they did not collide with server crash time.

update:只是查看了长查询的缓存更新时间,它们与服务器崩溃时间没有冲突。

update2: Found the cause of the problem. Ad server is down and the server hangs even though it seems we set socket timeouts properly. Is there any way to test timeout behaviour?

update2:找到问题的原因。广告服务器已关闭并且服务器挂起,即使我们似乎正确设置了套接字超时。有没有办法测试超时行为?

回答by Jakub Zalas

Your problem is pretty well covered by google. It looks like you have to play a bit with configuration (with options like MaxProcessCount).

google很好地涵盖了您的问题。看起来您必须对配置进行一些调整(使用 MaxProcessCount 等选项)。

I'd advice replacing apache with nginx. I experienced better performance. Also, nginx uses a lot less memory than apache. I'm using php-fpm for fast cgi.

我建议用 nginx 替换 apache。我体验到了更好的表现。此外,nginx 使用的内存比 apache 少得多。我正在使用 php-fpm 进行快速 cgi。

回答by u2786868

restart you server.I have soveled this problem use this way~

重启你的服务器,我已经解决了这个问题用这个方法~

回答by ufucuk

Move -> to nginx as soons as possible. Try -> Caching with APC for single server memcached for distributed systems or file cache systems Use -> DB indexes properly. It is one of the most important things I have ever experienced.

尽快移动 -> 到 nginx。尝试 -> 使用 APC 缓存用于分布式系统或文件缓存系统的单个服务器 memcached 正确使用 -> 数据库索引。这是我经历过的最重要的事情之一。