From: Eric Wong <normalperson@yhbt.net>
To: mongrel-unicorn@rubyforge.org
Cc: Pierre Baillet <oct@fotonauts.com>
Subject: Re: Fwd: Support for Soft Timeout in Unicorn
Date: Thu, 3 Jun 2010 18:22:46 +0000 [thread overview]
Message-ID: <20100603182246.GB19649@dcvr.yhbt.net> (raw)
In-Reply-To: <20100603173749.GA19649@dcvr.yhbt.net>
Pierre Baillet wrote:
> We use Unicorn at fotopedia since yesterday in production. We switched from
> Passenger due to an issue in the way Passenger was handling some error in
> our main application. Things run very well on Unicorn.
>
> We have also modified Unicorn to handle a soft timeout for its workers. The
> Unicorn timeout was killing the workers without any chance for us to catch
> the Rails stack trace and identify the issue. I've forked and branched
> Unicorn from github and added a soft_timeout configuration value that is
> used for long running workers.
>
> The workers now handle SIGABRT and will raise an exception. This will crash
> the Rails application if it can be crashed and force the framework to dump
> the stack trace in the logs. Let me know if this might be useful for other
> people and, why not, integrate that in the main Unicorn code !
Hi Pierre,
I'm thinking there's a better way to do this without involving the
master process.
The current timeout implementation[1] is really the last resort,
point-of-no-return situations when the workers are completely
stuck/blocked and cannot respond to other signals[2]. If the worker can
respond to SIGABRT (especially going through the interpreter and raising
an exception), then that means it could technically respond to
Thread#raise, too...
Unfortunately, the current core Ruby timeout implementation is extremely
naive and inefficient. It shouldn't be hard to write a better timeout
implementation that reuses a single timer Thread which can be rearmed
with every request.
This would be doable as middleware, too, and if done carefully, even
safely reusable in multi-threaded web servers. This would be a good
addition to rack-contrib, even. I might consider doing it myself if I
had time.
[1] - I'm not completely happy with "needing" the current timeout
implementation in the first place. I will at least redo it
at some point (after Unicorn 1.x) to gain some
scalability/performance (and perhaps lose some portability).
[2] - SIGKILL and SIGSTOP are special, userspace has no mechanism
to block/catch/ignore those signals, so we rely on the master
process to deliver them.
--
Eric Wong
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying
next prev parent reply other threads:[~2010-06-03 18:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-03 17:37 Fwd: Support for Soft Timeout in Unicorn Eric Wong
2010-06-03 18:06 ` Pierre Baillet
2010-06-03 18:22 ` Eric Wong [this message]
2010-06-03 18:32 ` Fwd: " Pierre Baillet
2010-06-03 18:47 ` Eric Wong
2010-06-03 19:38 ` Chris Wanstrath
2010-06-03 19:40 ` Pierre Baillet
2010-06-09 13:17 ` Pierre Baillet
2010-06-11 1:56 ` Eric Wong
2010-06-04 20:59 ` Eric Wong
2010-06-18 20:13 ` Ryan Tomayko
2010-06-18 21:48 ` Eric Wong
2010-06-21 19:03 ` Ryan Tomayko
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=20100603182246.GB19649@dcvr.yhbt.net \
--to=normalperson@yhbt.net \
--cc=mongrel-unicorn@rubyforge.org \
--cc=oct@fotonauts.com \
/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).