尝试使用 php-fpm 停止“池似乎很忙”错误

尝试使用 php-fpm 停止“池似乎很忙”错误

我有一台运行 3 核和 7GB RAM 的机器。在这台机器上,我们运行 Nginx 1.4.2 和 PHP-FPM。每个 PHP-FPM 进程使用约 30MB 的 RAM。

这是我设置的池配置:

[www]
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
user = nginx
group = nginx
pm = dynamic
pm.max_children = 200 ; 200 x 30MB = 6000MB (leaving ~1.5GB for random stuff on the server)
pm.start_servers = 20 ; 20 + (35 - 20) / 2 (rounded to the nearest 5)
pm.min_spare_servers = 20
pm.max_spare_servers = 35
pm.max_requests = 500
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session

我的/etc/nginx/nginx.conf

user              nginx;
worker_processes  3;

events {
    worker_connections  4096;
    multi_accept on;
}

我现在的问题是,我看到其中一些不时地在日志中滚动;这会导致110 (connection timed out)Nginx 出现错误。:

[24-Jul-2013 11:58:20] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 42 total children
[24-Jul-2013 11:58:21] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 0 idle, and 50 total children
[24-Jul-2013 11:58:22] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 66 total children
[24-Jul-2013 11:58:23] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 86 total children
[24-Jul-2013 11:58:24] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 106 total children
[24-Jul-2013 11:58:25] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 17 idle, and 126 total children

根据 CPU/RAM 规格,设置我的pm.*值的安全数字是多少?我不想将它们推得太高,以免机器比现在更糟糕。

相关内容