unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: Farjad Adamjee <fadamjee@vailsys.com>
Cc: unicorn-public@bogomips.org
Subject: Re: Unicorn returns blank page after no use
Date: Wed, 1 Jul 2015 17:30:20 +0000	[thread overview]
Message-ID: <20150701173020.GA12472@dcvr.yhbt.net> (raw)
In-Reply-To: <55941064.70808@vailsys.com>

Farjad Adamjee <fadamjee@vailsys.com> wrote:
> Hello,
> 
> I am not sure if this is the correct place for this, I have googled
> around to see if anyone else has encountered such an issue, but I
> did not find anything.

This is the correct place :)  Plain-text email is the only way I
handle support for ease-of-archival and distribution.

> I am having this issue where after a period of time of no use (on
> beta [production] environment), maybe 12 hours or so, the unicorn
> process sleeps. When I go and re-request the page, it returns blank.

This sounds like a database (or any other persistent connection
backend) connection expiring due to an idle timeout.

This could also be a firewall/router timeout problem between the
server running unicorn and the database host.

Tony experienced this last year:
http://bogomips.org/unicorn-public/m/CAKM1sPNRsES6H6ByK6bO9Djwa8WvYV6HJ-rEaHopRUYBVFfuhg@mail.gmail.com

You can confirm by running lsof on a worker processes to look for
open sockets.  In case the connection loss isn't noticed by the
OS, use strace (or any other similar syscall tracer for your OS)
instead and watch connection activity.

With strace (or similar) knock yourself down to one worker
process via SIGTTOU to the master to ensure you're always tracing
the correct one.

> I am using Apache proxy to Unicorn.

By the way, this is not recommended for slow clients.
nginx (Open Source edition) is currently the only supported proxy.

>   # Using this method we get 0 downtime deploys.
>   defined?(ActiveRecord::Base) and
> ActiveRecord::Base.connection.disconnect!
>   defined?(OathKeeper) and OathKeeper.disconnect!

I suggest disabling any idle timeout you might have, enabling TCP
keepalive and enabling reconnects (see AR and your database driver
documentation).  Worst case (firewall/router problem you can't
fix via configuration), is to send a request to unicorn every
few minutes/hours to keep things going.

Perhaps OathKeeper has the same problem, too...
I've never heard of it until now.

      reply	other threads:[~2015-07-01 17:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-01 16:08 Unicorn returns blank page after no use Farjad Adamjee
2015-07-01 17:30 ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/unicorn/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150701173020.GA12472@dcvr.yhbt.net \
    --to=e@80x24.org \
    --cc=fadamjee@vailsys.com \
    --cc=unicorn-public@bogomips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).