unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* feature request - when_ready() hook
@ 2009-11-26  4:50 Suraj Kurapati
  2009-11-26  6:05 ` Eric Wong
  0 siblings, 1 reply; 6+ messages in thread
From: Suraj Kurapati @ 2009-11-26  4:50 UTC (permalink / raw)
  To: unicorn list

Hello,

I've been trying to achieve truly transparent zero downtime deploys
with Unicorn and Rails for some time now (using SIGUSR2 and SIGQUIT
strategy) and I've always hit the problem of my "last worker sends
SIGQUIT to the old master" logic being executed way too soon.

In particular, I tried killing the old master in:

* before_fork() -- approx. 2 minute downtime
* after_fork() -- approx. 2 minute downtime
* storing the old-master-killing logic inside a lambda in after_fork()
(for the last worker only) and later executing that lambda in Rails'
config.after_initialize() hook -- approx. 20 second downtime

As you can see, the more I delayed the execution of that "killing the
old master" logic, the closer I got to zero downtime deploys.  In this
manner, I request the addition of a when_ready() hook which is
executed just after Unicorn prints "worker=# ready!" to its error log
inside Unicorn::HttpServer#worker_loop().

I am happy to implement this (with tests) and submit a patch, but I
first wanted to know your opinion on this approach.  (I should note
that my unicorn setup does not run very close to the memory limit of
its host; instead, the amount of free memory is more than double of
the current unicorn memory footprint, so I can safely spawn a second
set of Unicorn master + workers (via SIGUSR2) without worrying about
the SIGTTOU before_fork() strategy shown in the Unicorn configuration
example.)

Thanks for your consideration.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-03-09 12:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-26  4:50 feature request - when_ready() hook Suraj Kurapati
2009-11-26  6:05 ` Eric Wong
2009-11-26 19:05   ` Suraj Kurapati
2009-11-26 19:53     ` Eric Wong
2009-11-30 23:47       ` Suraj Kurapati
2010-03-08 22:58         ` Suraj Kurapati

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).