我的服务器运行 Nginx + PHP-FPM 设置时遇到了一些问题。本周我们的用户在中欧标准时间 02.00 左右后看到了 503。从浏览器它在一定时间后超时(超过几分钟的等待时间)。我检查了日志,我唯一注意到的是下面日志的第一行:
[20-Sep-2013 01:45:00] WARNING: [pool web1] server reached pm.max_children setting (25), consider raising it
[20-Sep-2013 01:45:03] NOTICE: [pool web1] child 3657 exited with code 0 after 30.161697 seconds from start
[20-Sep-2013 01:45:03] NOTICE: [pool web1] child 3672 started
[20-Sep-2013 01:45:07] NOTICE: [pool web1] child 3655 exited with code 0 after 33.749738 seconds from start
当它超时时,我检查了每个进程的内存使用和计数,PHP-FPM 似乎有 26 个进程正在运行。
重新启动 PHP-FPM 有所帮助。这是重启后的 FPM 日志:
[20-Sep-2013 07:28:41] NOTICE: Terminating ...
[20-Sep-2013 07:28:41] NOTICE: exiting, bye-bye!
[20-Sep-2013 07:30:09] NOTICE: fpm is running, pid 1905
[20-Sep-2013 07:30:09] NOTICE: ready to handle connections
[20-Sep-2013 07:30:13] WARNING: [pool web1] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 10 total children
[20-Sep-2013 07:30:14] WARNING: [pool web1] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 0 idle, and 12 total children
[20-Sep-2013 07:31:10] WARNING: [pool web1] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 12 total children
[20-Sep-2013 07:31:11] WARNING: [pool web1] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 0 idle, and 14 total children
[20-Sep-2013 07:31:12] WARNING: [pool web1] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 16 total children
[20-Sep-2013 07:31:13] WARNING: [pool web1] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 18 total children
[20-Sep-2013 07:31:14] WARNING: [pool web1] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 20 total children
[20-Sep-2013 07:32:27] NOTICE: [pool web1] child 2079 exited with code 0 after 73.199058 seconds from start
[20-Sep-2013 07:32:27] NOTICE: [pool web1] child 2099 started
[20-Sep-2013 07:32:29] NOTICE: [pool web1] child 2080 exited with code 0 after 74.523488 seconds from start
[20-Sep-2013 07:32:29] NOTICE: [pool web1] child 2100 started
服务器信息:KVM 来宾 - Centos 6.4 x64 与当前内核。PHP 5.4.20 nginx/1.3.14 内存 6GiB
Here is my FPM pool config:
[web1]
listen = /var/run/php-fpm/$pool.sock
user = $pool
group = $pool
pm = dynamic
pm=static
pm.max_children = 25
pm.start_servers = 5
pm.min_spare_servers = 2
pm.max_spare_servers = 5
pm.max_requests = 100
slowlog = /var/log/php-fpm/$pool-slow.log
php_admin_value[error_log] = /var/log/php-fpm/$pool-error.log
php_admin_flag[log_errors] = on
php_admin_value[memory_limit] = 1000M
php_admin_value[upload_max_filesize] = 2000M
php_admin_value[post_max_size] = 2000M
php_admin_value[max_file_uploads] = 1000
php_admin_value[max_execution_time] = 1200
php_admin_value[session.gc_maxlifetime] = 86400
php_admin_value[max_input_time] = 1200
request_terminate_timeout = 14400s
rlimit_files = 131072
chdir = /
listen.backlog = 16384
pm.status_path = /status
env[TMP] = /var/www/vhosts/$pool/tmp
env[TMPDIR] = /var/www/vhosts/$pool/tmp
env[TEMP] = /var/www/vhosts/$pool/tmp
这是服务器无法处理流量的问题吗?由于服务器提供文件上传和下载,我有很长的时间。另外,我不确定这是否是问题,因为我以前也见过这个问题,而没有服务器超时。我一直在这里阅读以找到类似的问题/问题,实际上我的 FPM 配置的某些部分取自这里的推荐设置:)
对我的问题的任何见解将不胜感激。