请教:关于 PHP -fpm 进程疑似陷入 stuck 的排查

查看 31|回复 0
作者:skvi   

兄弟的公司所 to B 业务
后端大概就是 pg + nignx + php-fpm
偶然会遇到这么个问题很好奇,所以来请教 v 站的大佬们,希望各位大佬不吝赐教!


  • fpm 配置

    贴上编译信息 + 运行配置, php.ini是默认配置就不贴了

    # 版本
    PHP 7.4.20 (cli) (built: Nov 29 2021 15:48:06) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
    # 编译信息
    ./configure  --prefix=/usr/local/php7 --exec-prefix=/usr/local/php7 --bindir=/usr/local/php7/bin --sbindir=/usr/local/php7/sbin --includedir=/usr/local/php7/include --libdir=/usr/local/php7/lib/php --mandir=/usr/local/php7/php/man --with-mhash --with-openssl --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --enable-gd --with-iconv --with-zlib --with-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg --with-freetype --enable-opcache --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --disable-fileinfo PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
    # 配置
      [www]
    user = nginx
    group = nginx
    listen = 127.0.0.1:9000
    pm = dynamic
    pm.max_children = 12
    pm.start_servers = 2
    pm.min_spare_servers = 1
    pm.max_spare_servers = 3
    pm.max_requests = 300

  • 现象

    这个部分目前我没法定位到问题,目前没有办法复现,使用一段时间后有概率出现,重启fpm可解决
    贴一个案例的现象,因为无法复现,无法贴上排查的屏显
    服务器 10C16G, 主频 3.7GHz

    [ol]
  • 用户反映每次刷新页面等待的时间是往常的2 倍以上。(证实描述不虚)。
  • disk、pg、redis、nginx都挺正常,因为每次都是重启fpm能解决,应该排除了。
  • 内存:free -h显示 avaliable 还有1/3以上。
  • CPU:top显示平均负载在8-10之间,cpu 占用高的都是fpm进程。
    [/ol]

    重点就是 cpu 平均负载满了,感觉像是某个进程陷入了死锁,一直在占用 cpu 时间,现在想了解的是:
    [ol]
  • 出现这种情况应该结合什么技能排查(能有具体案例就最好了)?
  • 是否需要后端代码层面植入什么print stack机制?
    [/ol]
    最后感谢各位路过,赐教的 V 站大佬们!
  • 您需要登录后才可以回帖 登录 | 立即注册

    返回顶部