如何知道 PHP-FPM 上设置了多少个子服务器

如何知道 PHP-FPM 上设置了多少个子服务器

我今天意识到一个大问题,流量太大导致我的网站完全瘫痪,但我有一个大型服务器来托管它。以下是我得到的结果:

[20-May-2019 14:23:02] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 4 idle, and 22 total children
[20-May-2019 14:23:03] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 3 idle, and 30 total children
[20-May-2019 14:23:04] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 42 total children
[20-May-2019 14:23:05] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 57 total children
[20-May-2019 14:23:06] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 72 total children
[20-May-2019 14:23:07] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 87 total children
[20-May-2019 14:23:08] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 102 total children
[20-May-2019 14:23:09] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 117 total children
[20-May-2019 14:23:10] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 9 idle, and 132 total children

但是我认为我已经用这个配置在我的 fpm 上配置了足够的子项:

  • 下午.max_children = 100
  • pm.start_servers = 15
  • pm.min_spare_servers = 15
  • pm.max_spare_servers = 25

但我收到此错误。你知道我可以设置多少个来接受更多流量吗?我有 32GB 的 RAM 和 8 个核心

答案1

该日志文件表明在 8 秒内启动了 110 个进程。请注意,它快速连续地启动了多个批次,每个批次 32 个。pm.min_spare_servers = 15将无法吸收这样的连接增加,响应时间将非常糟糕。

保留足够的空闲进程来吸收最大的连接峰值以及超过该峰值的最大值。当然,前提是您有足够的内存和 CPU。尝试以下操作:

pm.max_children = 500
pm.min_spare_servers = 100
pm.max_spare_servers = 200

将此作为容量规划过程的一部分不断进行调整。例如,您可能拥有更多资源来增加资源。或者,也许您已经达到不需要更多 php-fpm 的程度,并且这些资源最好花在主机上的其他工作负载上。

同样关于服务器故障:警告:池 www 似乎很忙(您可能需要增加 pm.start_servers 或 pm.min/max_spare_servers)

相关内容