douyi6960 2018-06-01 06:22
浏览 176
已采纳

php-fpm和dns随机不能很好地工作

Sometimes I got error message:

stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known

I found that problem is always with php-fpm, because after restarting php-fpm service its working well again. Its happen randomly on 1-3 month periods. Or it will happen when name resolve functions are used many times in one php session. My server is CentOS 7.5, Apache 2.4, PHP 7.x, updated. Do you know what problem should be?

In log I see only some:

WARNING:server reached pm.max_children setting (8), consider raising it

but it workx normal.

  • 写回答

1条回答 默认 最新

  • dongyi6195 2018-06-01 07:25
    关注

    Most common ones why PHP-FPM would reach the max_children are:

    • A lot of parallel requests from your clients
    • Very low setting of the max_children

    But, for this case I assume that caused by low setting of max_children. So please increase it.

    $ sudo vi /etc/php-fpm.d/www.conf
    

    You can find pm.max_children under [php-fpm-pool-settings] section.

    To get an idea of what to use for the pm.max_children, you can use this calculation:

    pm.max_children = Total RAM dedicated to the web server / Max child process size.

    Remember to leave some RAM for extra services you have running on your system.

    Also remember, higher isn’t always better. If you have a bad PHP script, these settings won’t resolve your issues. Tweak these settings and see what works best on your server. After you make the changes, you need to restart your PHP-FPM service.

    $ sudo systemctl restart php-fpm
    

    Please check this tutorial for more information

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求帮我调试一下freefem代码
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图