我在这里不知所措。我运行着几十台服务器,流量大小各不相同。随着流量的增加,一些服务器开始崩溃(502/503 错误),我认为这是由于 php 配置与默认配置没有变化。
/etc/php/7.0/fpm/pool.d/www.conf
例如,我根据服务器的硬件设置配置如下:
pm.max_children = 70
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 35
pm.max_requests = 500
经过这些编辑后,所有服务器都运行顺利;不再出现峰值,不再出现错误。直到今天我收到了一条停机推送消息,/var/log/upstart/php7.0-fpm.log
内容如下:
[09-Jul-2018 08:51:01] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 18 idle, and 39 total children
[09-Jul-2018 08:52:03] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 14 idle, and 52 total children
[09-Jul-2018 08:52:04] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 19 idle, and 58 total children
[09-Jul-2018 08:53:06] WARNING: [pool www] server reached pm.max_children setting (70), consider raising it
这和我之前遇到的错误基本相同,但数字更大。我想我缺少一些其他相关设置来控制这个范围,但是,哪一个呢?
答案1
没有其他相关设置。要么进一步增加限制,要么优化 PHP 应用程序,要么添加更多服务器。根据流量/PHP 应用程序,拥有大量工作者可能是正常的,也可能不是