Fwd: Support for Soft Timeout in Unicorn

Eric Wong normalperson at yhbt.net
Thu Jun 10 21:56:21 EDT 2010

Pierre Baillet <oct at fotonauts.com> wrote:
> Hello Unicorns,
> I've manage to create a simple middleware that replaces the soft
> timeout feature. You can have a look at it at
> http://gist.github.com/431451
> Note that some weird Ruby interpreter behavior breaks at least the
> first level of the generated stacktrace (it indicates the actual
> method where the raise happened but the wrong line number and file).

You should be able to avoid spawning a new thread for every request, as
that can get very expensive on some systems.  Maybe a global hash
guarded by a mutex that tells the worker Thread which thread to raise
on.  The worker thread could sleep until the next timeout registered.

But then again, take care to only spawn new threads in workers (with
preload_app=true), as threads never get carried across fork.  And
threads may leave mutexes and such in a bad state when they vanish
in the child.

Eric Wong

More information about the mongrel-unicorn mailing list