Here''s a quick followup with what we''re going to try: We changed the before_fork/after_fork hooks, getting rid of the original before_fork hook which sent SIGQUIT to the old master. Instead, we send SIGTTOU to the old master at the very end of the after_fork block, so that as each new worker completes booting it tells the old master to kill off one old worker. We''re also using Rack::MockRequest in the after_fork block (but before we send SIGTTOU) to send a request to our most heavily trafficked action. Subsequent requests to the same action are ~20X faster, so it''s clear we''re pulling in a lot of code on that first request and warming up the new workers is definitely needed. Does this sound sane? -- Tony Arcieri
Tony Arcieri <tony.arcieri at gmail.com> wrote:> Here''s a quick followup with what we''re going to try: > > We changed the before_fork/after_fork hooks, getting rid of the > original before_fork hook which sent SIGQUIT to the old master. > Instead, we send SIGTTOU to the old master at the very end of the > after_fork block, so that as each new worker completes booting it > tells the old master to kill off one old worker.AFAIK, this is pretty common in existing deployments due to the default example, so it probably works well for many users already.> We''re also using Rack::MockRequest in the after_fork block (but before > we send SIGTTOU) to send a request to our most heavily trafficked > action. Subsequent requests to the same action are ~20X faster, so > it''s clear we''re pulling in a lot of code on that first request and > warming up the new workers is definitely needed.I haven''t heard of anybody using this, but I expect it to work. A followup report would be much appreciated. Thanks in advance.> Does this sound sane?Sure! (of course, my definition of "sane" may not match the rest of the world :)
Tony Arcieri <tony.arcieri <at> gmail.com> writes:> We''re also using Rack::MockRequest in the after_fork block (but before > we send SIGTTOU) to send a request to our most heavily trafficked > action. Subsequent requests to the same action are ~20X faster, so > it''s clear we''re pulling in a lot of code on that first request and > warming up the new workers is definitely needed.Is this code you''re able to share in a gist or elsewhere? I''m curious to see how you''re using Rack::MockRequest on a per-worker basis. Thanks, Dan
On Fri, Dec 28, 2012 at 1:38 PM, Dan Melnick <danmelnick at gmail.com> wrote:>> Is this code you''re able to share in a gist or elsewhere? I''m curious to > see how you''re using Rack::MockRequest on a per-worker basis.It looks like this, more or less: app = ActionController::Dispatcher.new map = Rack::URLMap.new(''/'' => app) Rack::MockRequest.new(map).get(url) -- Tony Arcieri