You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

服务器PHP-FPM进程管理器配置问题咨询

服务器PHP-FPM配置与资源波动问题

服务器基础信息

  • 硬件配置:8核16GB内存
  • 运行应用:2个PHP应用、2个JS应用
  • 异常现象:CPU和内存统计数据出现波动

PHP-FPM日志信息

WARNING: [pool web] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 10 idle, and 31 total children
WARNING: [pool web] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 53 total children
WARNING: [pool web] server reached pm.max_children setting (64), consider raising it

NOTICE: Terminating ...
NOTICE: exiting, bye-bye!
NOTICE: fpm is running, pid 4182079
NOTICE: ready to handle connections
NOTICE: systemd monitor interval set to 10000ms

相关命令执行结果

ps -ylC php-fpm --sort:rss 输出

S   UID     PID    PPID  C PRI  NI   RSS    SZ WCHAN  TTY          TIME CMD
S     0    1623    1532  0  80   0 22332 20315 ep_pol ?        00:00:02 php-fpm
S    33  224785    1623  0  80   0 32404 24662 inet_c ?        00:00:03 php-fpm
S    33    2094    1623  0  80   0 33164 25185 inet_c ?        00:00:03 php-fpm
S    33    2093    1623  0  80   0 34428 25171 inet_c ?        00:00:04 php-fpm

free -hl 输出

total        used        free      shared  buff/cache   available
Mem:            15Gi       7.1Gi       2.2Gi        83Mi       6.5Gi       8.3Gi
Low:            15Gi        13Gi       2.2Gi
High:             0B          0B          0B
Swap:          4.0Gi       8.0Mi       4.0Gi

初始PHP-FPM配置

pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

疑问与尝试方向

  • 考虑调整pm.max_children、pm.start_servers、pm.min_spare_servers、pm.max_spare_servers参数,但担心操作后情况恶化
  • 若设置如下参数,是否会导致服务器故障?
    pm.max_children = 6
    pm.start_servers = 处理器核心数 × 4
    pm.min_spare_servers = 处理器核心数 × 2
    pm.max_spare_servers = 处理器核心数 × 4
    
  • 设置更高的pm参数会有什么后果?
  • 是否可能是PHP应用内部自调用导致进程数溢出,达到64后触发重启?

更新后的PHP-FPM配置

pm.max_children = 64
pm.start_servers = 24
pm.min_spare_servers = 16
pm.max_spare_servers = 24
pm.process_idle_timeout = 10s;
pm.max_requests = 2500

内容的提问来源于stack exchange,提问作者user26401742

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 11:57:05