GitHub on Unicorn

Eric Wong normalperson at
Sat Sep 19 20:00:02 EDT 2009

Chris Wanstrath <chris at> wrote:
> Just wanted to say that GitHub has been running on Unicorn for about
> two weeks now. In that time it's successfully served millions of pages
> and has survived two separate DDoS attacks.

Wow, this is wonderful news!

> Here's the config file we currently use (complete with a fun hack to
> gracefully kill the old master when a new worker pool is ready):

Great use of the before/after_fork hooks

One possible issue is a race condition in the before_fork hook,
so I'd put a rescue to protect the in the before_fork:

old master                    new master
                              before_fork for worker=0
                              File.exist?(old_pid) => true
                              Process.kill :QUIT,

                              before_fork for worker=1
                              File.exist?(old_pid) => true
processes :QUIT
unlinks old_pid
                              # the will raise Errno::ENOENT:
                              Process.kill :QUIT,

> (Tom's thread with the `backlog` fix concerns our new servers, which
> aren't yet in production.)
> I plan to do a writeup on our transition from mongrel_cluster to
> Unicorn in the near future, in case others are interested. I'll post
> the link here when it's available.

Looking forward to it!

> Also: I'm keeping a mirror of the project at
> for any other GH users who want to
> watch updates in their generalized feed. I update it semi-regularly.

Cool, more exposure's always good.

Small nit: "Eric Wong's Unicorn" doesn't sound quite right...
While I am the benevolent dictator for now, I do welcome contributions.

I could not have have built it without standing on the shoulders of
Mongrel and the existence of Rack and nginx.

Personally, I try to keep a low public profile and it's always been an
weird balancing act trying to get people to use my work at the same

> Long live fork(2)! And thanks again for the project.


Eric Wong

More information about the mongrel-unicorn mailing list