2
votes

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?

2

2 Answers

0
votes

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.

0
votes

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.