服务是nginx+php-fpm配置,
在运行过一段时间后,会经常出现:
WARNING: [pool www] server reached pm.max_children setting (50), consider raising it 子进程达到最大数量,需要提供子进程数
503/502一般是因为服务器维护或者过载,近期服务器并未进行维护,查询监控记录发现负载也不是很高,猜测是不是服务器对项目的某些配置产生了限制,查看nginx,php日志发现:
找到php-fpm.conf 文件 ,查找php日志错误
[15-Nov-2017 15:23:51] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it [15-Nov-2017 17:10:53] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it [15-Nov-2017 17:12:56] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it [15-Nov-2017 18:29:28] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it [16-Nov-2017 10:25:17] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it
该警告频繁出现,子进程达到最大数量,查询php-fpm配置文件www.conf,发现pm.max_children采用的是默认配置,显然是因为设定值过小导致
问题解决:
修改
pm.start_servers = 10 //php-fpm启动起始进程数 pm.min_spare_servers = 10 //php-fpm的最小空闲进程数 pm.max_spare_servers = 24 //php-fpm的最大空闲进程数 pm.max_requests = 500 //所有子进程重启时间
参考:https://lirongyao.com/server-reached-pm-max_children-setting.html
原文地址:https://www.cnblogs.com/achengmu/p/9054911.html
时间: 2024-10-11 06:07:13