php-fpm dies when reaches max_children
Sergey Kobzar
sergey.kobzar на itcraft.org
Вс Мар 25 11:40:30 UTC 2012
Приветствую
Не уверен, что по адресу...
На сервере раз в неделю запускается тяжелый скрипт. В это время
увеличивается число php-fpm процессов и при достижении max_children
лимита php-fpm помирает.
Linux 3.2.1-gentoo-r2 x86_64
php-5.3.9
/etc/php/fpm-php5.3/php-fpm.conf:
[site]
listen = 127.0.0.1:9002
user = site
group = site
pm = dynamic
pm.max_children = 256
pm.start_servers = 16
pm.min_spare_servers = 16
pm.max_spare_servers = 24
pm.status_path = /phpfpm_status
ping.path = /phpfpm_ping
request_slowlog_timeout = 10
slowlog = /var/log/php/php-fpm-$pool_slow.log
php_admin_flag[log_errors] = on
php_admin_value[date.timezone] = Europe/London
php_admin_value[error_log] = /var/log/php/php-fpm-$pool_error.log
php_admin_value[memory_limit] = 256M
php_flag[short_open_tag] = on
В логах это выглядит так:
[25-Mar-2012 02:14:29] WARNING: [pool site] seems busy (you may need to
increase pm.start_servers, or pm.min/max_spare_servers), spawning 16
children, there are 6 idle, and 241 total children
[25-Mar-2012 02:14:34] NOTICE: child 6399 stopped for tracing
[25-Mar-2012 02:14:34] NOTICE: about to trace 6399
[25-Mar-2012 02:14:34] ERROR: failed to ptrace(PEEKDATA) pid 6399:
Input/output error (5)
[25-Mar-2012 02:14:34] NOTICE: finished trace of 6399
[25-Mar-2012 02:14:34] NOTICE: child 6444 stopped for tracing
[25-Mar-2012 02:14:34] NOTICE: about to trace 6444
[25-Mar-2012 02:14:34] ERROR: failed to ptrace(PEEKDATA) pid 6444:
Input/output error (5)
[25-Mar-2012 02:14:34] NOTICE: finished trace of 6444
[25-Mar-2012 02:14:34] NOTICE: child 6445 stopped for tracing
[25-Mar-2012 02:14:34] NOTICE: about to trace 6445
[25-Mar-2012 02:14:34] NOTICE: finished trace of 6445
[25-Mar-2012 02:14:34] NOTICE: child 6451 stopped for tracing
[25-Mar-2012 02:14:34] NOTICE: about to trace 6451
[25-Mar-2012 02:14:34] ERROR: failed to ptrace(PEEKDATA) pid 6451:
Input/output error (5)
...
[25-Mar-2012 02:16:34] NOTICE: child 6358 stopped for tracing
[25-Mar-2012 02:16:34] NOTICE: about to trace 6358
[25-Mar-2012 02:16:35] NOTICE: finished trace of 6358
[25-Mar-2012 02:16:35] NOTICE: child 6383 stopped for tracing
[25-Mar-2012 02:16:35] NOTICE: about to trace 6383
[25-Mar-2012 02:16:35] NOTICE: finished trace of 6383
[25-Mar-2012 02:16:35] NOTICE: child 6456 stopped for tracing
[25-Mar-2012 02:16:35] NOTICE: about to trace 6456
[25-Mar-2012 02:16:35] NOTICE: finished trace of 6456
[25-Mar-2012 02:16:35] NOTICE: Finishing ...
[25-Mar-2012 02:16:37] NOTICE: exiting, bye-bye!
Как решение, можно увеличить max_children, но IMO это не совсем правильно.
Я ожидал след. поведения:
если число процессов равно max_children, то перестают создаваться новые
чаилды, но php-fpm прдолжает обслуживать существующие соединения, но не
помирать совсем же!
Any ideas?
Спасибо.
Подробная информация о списке рассылки nginx-ru