PHP-FPM WARNINGメッセージ server reached pm.max_children setting の対応
Nid: 1206
WARNINGメッセージ
$ sudo tail -f /var/log/php7.2-fpm.log [01-Jan-2019 11:21:55] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it [01-Jan-2019 11:22:26] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it [01-Jan-2019 11:29:52] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it
PHP-FPM プロセス当たりの 平均使用メモリを求める。
$ ps --no-headers -o rss,cmd -C php-fpm7.2 | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }' 94Mメモリ8GBを割り当てるとすると、
pm.max_children = Total RAM dedicated to the web server / Max child process size = 8000MB / 100MB = 80
プロセス当たり100MBとすると、最大で80
$ grep -i cores /proc/cpuinfo | uniq cpu cores : 8pm.start_serversは、4xコア数=4x8=32。pm.min_spare_serversは、2xコア数=4x8=16。pm.max_spare_servers = pm.start_servers = 32
$ sudo vi /etc/php/7.2/fpm/php-fpm.conf pm.max_children = 80 pm.min_spare_servers = 16 pm.max_spare_servers = 32 pm.start_servers = 32 ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
$ sudo systemctl restart php7.2-fpm