nginx日志报错upstream timed out (110: Connection timed out)

一 、 nginx日志报错upstream timed out (110: Connection timed out)

最近nginx出现了频繁出现(110: Connection timed out)报错,出现报错之后web站点就无法访问了。必须重启php-fpm才能恢复。报错信息如下:

2017/08/04 08:10:06 [error] 27269#0: *34444805 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 183.131.0.26, server: www.aaabbb.com, request: "POST /Open/dongwutoken HTTP/1.1", upstream: "fastcgi://unix:/dev/shm/php-cgi.sock", host: "www.aaabbb.com"

二 、 排错流程

1.基本百度这个报错,百度到的都是nginx的一些参数调优。
我服务器的调优配置已经配置过了,经过排查可以确定是后端代码出了问题。
我对php-fpm和mysql的参数进行调优以后,报错显著减少。

拍错流程我就不写了,有需要的同学可以参考下这个拍错流程。

http://chenpipi.blog.51cto.com/8563610/1682450

三 、解决方法

1.对php-fpm和mysql的参数进行排查调优,报错显著减少,但还是存在。之后可以让开发人员针对代码进行排查。

2.应急处理方法,/etc/init.d/php-fpm reload

3.脚本检测站点访问情况,通信状态不为200的时候平滑重启php-fpm。(这个脚本只能暂时使用,逻辑性并不强。因为如果是nginx等前端问题,也会导致重启php-fpm。只是提供应急使用。)另外提醒一下,不能使用nginx的报错来判断是否平滑重启php-fpm,测试发现有时候php-fpm死掉了,nginx日志并不会有写入。

#!/bin/bash
#Date:2017/7/4
#Author: create by xingcheng
#Mail:
#Function:监控php5.6错误日志,Connection timed out报错情况。


DIR=/home/xingcheng/function_1/php_fpm_reload
cd $DIR
while :
do
  status=$(curl -sL -w "%{http_code}" "www.aaabbb.com/public/index" -o /dev/null)
  if [ $status -eq 200 ]
  then
      sleep 10
  else
      /etc/init.d/php-fpm reload >> php56_monitor_reload_2.log
      status1=$(echo $0)
      if [ $ status1 -eq 0 ]
      then
           /usr/bin/python /home/xingcheng/monitor/mail/mail.py "56565656@qq.com"  "www.aaabbb.com/public/index is down"  "$(tail -n 10 php56_monitor_reload_2.log)"
           sleep 60
      else
          /usr/bin/python /home/xingcheng/monitor/mail/mail.py "56565656@qq.com"  "www.aaabbb.com Restart failed"  "$(tail -n 10 php56_monitor_reload_2.log)"
          sleep 10
      fi
  fi
done

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值