即使未达到限制,php fpm 也会生成新的子项

即使未达到限制,php fpm 也会生成新的子项

我的 php fpm 进程给出以下警告:

[29-Apr-2014 13:06:10] WARNING: [pool www] seems busy (you may need to
increase pm.start_servers, or pm.min/max_spare_servers), spawning 8
children, there are 19 idle, and 51 total children

[29-Apr-2014 13:07:09] 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 47 total children [29-Apr-2014 13:07:10]

WARNING: [pool www] seems busy (you may need to increase
pm.start_servers, or pm.min/max_spare_servers), spawning 16 children,
there are 17 idle, and 53 total children [29-Apr-2014 13:07: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 14 idle, and 56 total children [29-Apr-2014 13:07: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 19 idle, and 62 total children [29-Apr-2014 13:07: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 18 idle, and 63 total children [29-Apr-2014 13:07:14]

我的 fpm.conf 是:

pm.max_children = 161
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 40
pm.max_requests = 1000

我的问题是

  1. 为什么即使我没有达到 max_children 值,也会生成子进程?是因为有额外的流量,而且因为空闲子进程需要达到最低 20 个,所以它们不能被用完吗?

  2. 这是否会给我的系统造成开销?

答案1

为什么即使我没有达到 max_children 值也会生成子代?

因为这是最大值。一旦达到最大值,就不会再创建更多,但在此之前,PHP-FPM 会在需要额外容量时添加工作器。使用您的设置,您将始终拥有至少 20 台服务器,最多不超过 161 台,并且当少于 20 台空闲时 FPM 会添加服务器,当超过 40 台空闲时 FPM 会删除服务器。

答案2

您有pm.min_spare_servers = 20,并且它正在低于 20 个空闲子进程的限制,并生成更多子进程以回到 min_spare_servers 数量。降低此值以减少发生的频率。它旨在抵消负载峰值并拥有足够的子进程来满足需求。

相关内容