Apache 服务器在 Amazon Linux 上使用 PHP 5.4.40 FPM/Worker 临时停止使用 Apache 2.4.12 处理请求

Apache 服务器在 Amazon Linux 上使用 PHP 5.4.40 FPM/Worker 临时停止使用 Apache 2.4.12 处理请求

由于以下错误,我们的 Apache 服务器不断停止提供请求:

(70007)The timeout specified has expired: [client xxx.xxx.xxx.xxx:33740] AH01075: Error dispatching request to : (polling), referer: https://www.google.com/
[proxy_fcgi:error] [pid 12363:tid 139906999342848] [client xxx.xxx.xxx.xxx:6318] AH01067: Failed to read FastCGI header

似乎无论我们做什么,这种情况都会发生,我尝试在 php.conf 中设置超时:

#
# Cause the PHP interpreter to handle files with a .php extension.
#
RequestReadTimeout header=180 body=180

  <FilesMatch \.php$>
    SetHandler "proxy:unix:/var/run/php-fpm/php5-fpm.sock|fcgi://127.0.0.1 timeout=1800 connectiontimeout=1800"
  </FilesMatch>
<Proxy "unix:/var/run/php-fpm/php5-fpm.sock|fcgi://127.0.0.1" timeout=1800 connectiontimeout=1800>
ProxySet timeout=1800 connectiontimeout=1800
</Proxy>
<Proxy "fcgi://127.0.0.1">
ProxySet timeout=1800 connectiontimeout=1800
</Proxy>
#<FilesMatch \.php$>
#    SetHandler application/x-httpd-php
#</FilesMatch>

#
# Allow php to handle Multiviews
#
AddType text/html .php

#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php

#
# Uncomment the following lines to allow PHP to pretty-print .phps
# files as PHP source code:
#
#<FilesMatch \.phps$>
#    SetHandler application/x-httpd-php-source
#</FilesMatch>

从我们的 mpm-worker.conf 文件中:

<IfModule worker.c>
ThreadLimit 60
StartServers 5
MaxClients 60
ServerLimit 60
MinSpareThreads 10
MaxSpareThreads 250
ThreadsPerChild 60
MaxRequestsPerChild 500
MaxRequestWorkers 300
</IfModule>

从我们的 vhosts 文件中:

<VirtualHost *:80>
    LimitRequestBody 0
    RewriteEngine On
    RewriteOptions InheritBefore
    DocumentRoot "/var/www/html"
    ServerName xxxxx.com
</VirtualHost>

PHP_FPM www.conf:

[www]
listen = /var/run/php-fpm/php5-fpm.sock
listen.allowed_clients = 127.0.0.1
listen.backlog = 10240
listen.owner = apache
listen.group = apache
listen.mode = 0666
user = apache
group = apache
pm = dynamic
pm.max_children = 60 
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 60
pm.max_requests = 500
;pm.status_path = /status
;ping.path = /ping
;ping.response = pong
rlimit_files = 10240
rlimit_core = unlimited
request_terminate_timeout = 180s
php_admin_value[post_max_size] = 64M

Apache 的超时设置为 180。php.ini 有 default_socket_timeout = 180

内存使用情况:php_fpm:

ps -ylC php-fpm | awk '{x += $8;y += 1} END {print "PHP-FPM Memory Usage (MB): "x/1024; print "Average Proccess Size (MB): "x/((y-1)*1024)}'
PHP-FPM Memory Usage (MB): 5121.8
Average Proccess Size (MB): 62.4609

阿帕奇:

ps -ylC httpd | awk '{x += $8;y += 1} END {print "Apache Memory Usage (MB): "x/1024; print "Average Proccess Size (MB): "x/((y-1)*1024)}'
Apache Memory Usage (MB): 319.66
Average Proccess Size (MB): 39.9575

记忆:

             total       used       free     shared    buffers     cached
Mem:          7483       6141       1342          6         44        945
-/+ buffers/cache:       5150       2332
Swap:            0          0          0

我读过一篇有关补丁的文章,但就超时问题而言,它并不适用于我们的 Apache 版本。

MySQL 和 Memcached 在其他服务器上运行。

有任何想法吗?

相关内容