问题:
PHP-FPM日志中出现了如下警告信息:
[26-Jul-2012 09:49:59] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 8 idle, and 58 total children
[26-Jul-2012 09:50:00] WARNING: [pool www] server reached pm.max_children setting (50), consider raising it
PHP-FPM进程数不够用了。
解决方案:
根据系统内存调整PHP-FPM进程数。
/etc/php-fpm.d/www.conf
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
如下命令帮你查看PHP-FPM占用的内存数
ps -ylC php-fpm --sort:rss
RSS列显示的是PHP-FPM占用的物理内存数。
pm.max_children = 总内存 / PHP-FPM占用最大内存
PHP-FPM进程平均占用内存数计算
ps --no-headers -o "rss,cmd" -C php-fpm | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'