douxiajia6309 2019-07-18 04:19
浏览 436

为什么php-fpm(nginx)进程不关闭并继续累积?

I have the following Nginx php-fpm5.6 settings

pm = dynamic pm.max_children = 150 min_spare_servers) / 2 pm.start_servers = 10 pm.min_spare_servers = 1 pm.max_spare_servers = 25

Each child process is around 91MB and I have 16GB of of ram.

When the max number of children is reached I start to get errors in the log along the lines of:

- connect() to unix:/run/php/php5.6-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream

- failed (104: Connection reset by peer) while reading response header from upstream

Ultimately I end up having to restart php5.6-fpm to get everything working again.

I don't understand why there are so many open child processes that don't appear to be used. I've attached a screenshot of htop which looks like there are a lot of php-fpm not consuming any ram or cpu time. (https://drive.google.com/file/d/11kEjgcMDyc4EDbJU7DE_y87V6RRJ4ekN/view?usp=sharing)

Any ideas on how to solve / diagnose the issue?

  • 写回答

1条回答 默认 最新

  • duanci3845 2019-07-18 04:30
    关注

    I presume you're using socket_connect() for this task? Whatever the case, you should be able to close the resource of the connection you've created by using code similar to:

    $connection = socket_connect(...);
    // ... code ...
    socket_close($connection);
    

    Perhaps you're using a for loop or something to create many connections, but are not closing them until after?

    If you could post some of your code, that would be awesome :)

    Hope this helps, thanks

    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建