upstream timed out (110 connection timed out)

145 views
Skip to first unread message

马六

unread,
Nov 19, 2013, 4:17:13 AM11/19/13
to open...@googlegroups.com
nginx 日志报大量 upstream timed out (110: Connection timed out) while reading response header from upstream ....... subrequest: "/from_redis",这个种错误
 
  location = /from_redis {
      internal;
      redis2_query get $arg_key;
      redis2_pass redis_server;
   }
 
可以确定 redis_server服务的几台redis服务器肯定没问题。
 
出现upstream timed out错误是在我把系统迁移到centos 6.3只后发生的情况,在centos5.8没有错误。难道是系统导致的?

Yichun Zhang (agentzh)

unread,
Nov 19, 2013, 3:01:56 PM11/19/13
to openresty
Hello!

2013/11/19 马六:
> nginx 日志报大量 upstream timed out (110: Connection timed out) while reading
> response header from upstream ....... subrequest: "/from_redis",这个种错误

这个错误是说 nginx 在等待 redis 服务器的响应时超时了。一般有下面几种可能性:

1. 你的 nginx 阻塞在了某些操作上使得它的事件循环不能及时响应网络连接上的事件,而导致超时错误。这种问题可以通过使用
epoll-loop-blocking-distr 这样的工具加以确认:

https://github.com/agentzh/stapxx#epoll-loop-blocking-distr

如果确实有较严重的阻塞延时,则可以进一步通过 off-CPU 火焰图定位阻塞延时在代码路径上的具体分布:

https://github.com/agentzh/nginx-systemtap-toolkit#sample-bt-off-cpu

2. 你的 Redis 服务器过于繁忙(可能是瞬时的),而不能及时处理新进来的请求。关于这一点,你也可以基于 systemtap 或者
stap++ 编写实时分析工具,在 Redis 服务器一侧对 redis 请求的处理延时的分布进行统计。

3. 你的 nginx 与 redis 之间的网络链路存在丢包等问题。关于这一点,你可以在 TCP 层面上进行追踪和确认。

> 可以确定 redis_server服务的几台redis服务器肯定没问题。
>

你具体是如何确定你的 redis server 服务器肯定没问题的?

Regards,
-agentzh

马六

unread,
Nov 19, 2013, 9:00:12 PM11/19/13
to open...@googlegroups.com
全部一样的配置。在5.8系统上 没有 这个错误提示。但是在6.3系统就发现很多这样的错误。

Yichun Zhang (agentzh)

unread,
Nov 19, 2013, 11:03:00 PM11/19/13
to openresty
Hello!

On Tue, Nov 19, 2013 at 6:00 PM, 马六 wrote:
> 全部一样的配置。在5.8系统上 没有 这个错误提示。但是在6.3系统就发现很多这样的错误。
>

我在上一封邮件中已经给出了各种典型的情形以及可以确认问题的工具。

建议使用相关工具对问题本身进行直接观察和测量,而不是自己进行过多的推理和猜测。毕竟真实世界中我们想象不到的各种变化因素太多了 :)

Regards,
-agentzh
Reply all
Reply to author
Forward
0 new messages