【问题标题】:mod_fcgid: can't apply process slot for errormod_fcgid:不能为错误应用进程槽
【发布时间】:2011-07-11 19:20:31
【问题描述】:

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

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

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

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

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

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

这是 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

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

<IfModule !mod_php4.c>

# php.ini 的路径默认为 /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 配置:

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

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

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

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

【问题讨论】:

    标签: php apache2 mod-fcgid


    【解决方案1】:

    google 很好地解决了您的问题。看来您必须在配置方面进行一些尝试(使用 MaxProcessCount 等选项)。

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

    【讨论】:

    • 我在问这个问题之前用谷歌搜索过。 MaxProcessCount 设置为 45。而上次服务器失败时,它没有加载。我们计划迁移到 nginx,但这不是内存问题。服务器显示它有 10GB 可用内存。
    • 这不仅仅是关于内存。 Nginx 也比 apache 更高效。
    • 具有讽刺意味的是,这个问题是否定的。当我输入错误消息时,谷歌上的 1 :-P
    • @cebe 在我给出答案时它不是:P
    • 迁移到 Apache 并不总是一种选择,我们的供应商只支持 Apache。
    【解决方案2】:

    尽快移动 -> 到 nginx。 Try -> Caching with APC for single server memcached 用于分布式系统或文件缓存系统 正确使用 -> 数据库索引。这是我经历过的最重要的事情之一。

    【讨论】:

    • apache2 php-fpm 不利用 apc。我们使用文件缓存,因为它是单个服务器。
    • 确实如此 - voidweb.com/2010/07/…
    • mod_fastcgi 可以,但 mod_fcgid 不会。我们应该切换到 mod_fastcgi 吗?
    • 好吧,我没注意您使用的是 fcgi。然而,我的经验告诉我,fastcgi 的性能比 fcgi 更好,并且在高负载下更加稳定。所以你应该切换它,我想这会很有帮助。
    • 发现问题。这是套接字超时问题。我已经更新了这个问题。希望能找到解决办法。
    【解决方案3】:

    重启你的服务器。我用这种方式解决了这个问题~

    【讨论】:

      猜你喜欢
      • 2013-09-11
      • 1970-01-01
      • 2012-02-05
      • 1970-01-01
      • 1970-01-01
      • 2012-09-04
      • 1970-01-01
      • 2013-09-08
      • 2015-06-28
      相关资源
      最近更新 更多