Процесс PHP-FPM вылетает каждые несколько дней из-за достиг pm.max_children, Я должен запустить его вручную, чтобы создать сайт.
Total Memory: 7986M
CPU: 2 Core
1 PHP Process Taking: 22M
pm = dynamic
pm.max_children = 280
pm.start_servers = 15
pm.min_spare_servers = 15
pm.max_spare_servers = 35
pm.max_requests = 1000
Просмотрите журнал PHP-FPM и обнаружите следующую ошибку.
[02-Aug-2017 23:23:54] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 10 idle, and 41 total children
[02-Aug-2017 23:24:04] 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 55 total children
[02-Aug-2017 23:24:05] 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 63 total children
[02-Aug-2017 23:24:06] 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 78 total children
[02-Aug-2017 23:24:07] 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 93 total children
[02-Aug-2017 23:24:08] 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 108 total children
[02-Aug-2017 23:24:09] 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 123 total children
[02-Aug-2017 23:24:10] 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 138 total children
[02-Aug-2017 23:24:11] 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 153 total children
[02-Aug-2017 23:24:12] 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 168 total children
[02-Aug-2017 23:24:13] 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 183 total children
[02-Aug-2017 23:24:14] 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 198 total children
[02-Aug-2017 23:24:15] 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 213 total children
[02-Aug-2017 23:24:16] 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 228 total children
[02-Aug-2017 23:24:17] 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 243 total children
[02-Aug-2017 23:24:18] 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 258 total children
[02-Aug-2017 23:24:19] 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 273 total children
[02-Aug-2017 23:24:20] WARNING: [pool www] server reached pm.max_children setting (280), consider raising it
Я могу кто-нибудь предложить наиболее оптимизированную конфигурацию для PHP-FPM, которая может помочь избежать сбоя.
Что означает эта строка ниже:
[02-Aug-2017 23:23:54] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 10 idle, and 41 total children
Вот одно из предложений по вычислению правильного числа:
https://myshell.co.uk/blog/2012/07/adjusting-child-processes-for-php-fpm-nginx/
следующая команда поможет нам определить объем памяти, используемый каждым дочерним процессом (PHP-FPM):
ps -ylC php-fpm --sort:rss
Затем вы берете доступную оперативную память вашего сервера и вычисляете:
pm.max_children = Total RAM dedicated to the web server / Max child process size
Также см:
Прежде всего, вы должны выяснить, сколько детей fpm вам действительно нужно. Включите медленный журнал в конфигурации пула или используйте внешние службы, такие как NewRelic, для поиска медленных и слабых мест в вашем коде. Возможно, у вас есть узкое место в соединении MySQL или PHP-curl. У вас "кажется занятым", потому что они заняты ожиданием ответа от базы данных или чего-то еще. Увеличение pm.max_children без причины - плохая практика.