Nginx 和 unicorn 故障 - 上游超时
我有带有 nginx 和 unicorns 的 Rails 机器。非常典型的设置,您可以在这里查看: https://gist.github.com/7e0f9d762cf4d521d3c4
它有效很好,直到今天,我有很多:
读取响应时上游超时(110:连接超时) 来自上游的标头,客户端:xxx.xxx.xxx.xxx,服务器
在 nginx 的 error.log 中
,重启后就可以了,但我担心它会再次发生。 有谁遇到过类似的问题,或者可以告诉我为什么会发生吗?
I've got rails machine with nginx and unicorns. Quite typical setup, which you can check here: https://gist.github.com/7e0f9d762cf4d521d3c4
It worked quite well, till today, when I've got lots of:
upstream timed out (110: Connection timed out) while reading response
header from upstream, client: xxx.xxx.xxx.xxx, server
in nginx's error.log
After restart it was okay, but I'm afraid that it can happen again.
Does anyone had similar problem, or can tell me why it happened?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我听说过 Monit 和 God 中的实现会检查挂起的套接字。我建议您寻找线程上响应时间增加的情况,这将表明这种情况,当发生这种情况时,让 monit 挂起它,导致独角兽产生一个新的工作线程。
http ://www.stopdropandrew.com/2010/06/01/where-unicorns-go-to-die-watching-unicorn-workers-with-monit.html
另一种可能性是使用thin,这对于非LAN(即WAN 或WWW)设置来说要好一些,因为它不是像Unicorn 那样的快速客户端。
I've heard of implementations in Monit and God that will check for hanging sockets. I would suggest that you look for response times increasing on threads, which will signify this condition, and when it happens, have monit hang it up, causing unicorn to spawn a new worker.
http://www.stopdropandrew.com/2010/06/01/where-unicorns-go-to-die-watching-unicorn-workers-with-monit.html
Another possibility is to use thin, which is a little better for non-LAN (i.e. WAN or WWW) setups because it isn't a fast-client, like Unicorn.
我也有同样的问题。您可以在 unicorn 错误日志文件和 production.log 文件中找到更多信息。然后你就可以找到真正的问题是什么。也许这是因为您正在处理的文件太大,并且对于 unicorn.rb 有一个超时设置,这会出现这个超时问题。
I have had the same issue. And you can find more info in unicorn error log file and your production.log file. Then you can find what is the real problem. Maybe that is because the file you are processing is too big and for unicorn.rb there is a timeout setting which will arise this time out problem.