Eric Wong’s mostly pure-Ruby HTTP backend, Unicorn, is an inspiration. I’ve studied this file for a couple of days now and it’s undoubtedly one of the best, most densely packed examples of Unix programming in Ruby I’ve come across.
Unicorn is basically Mongrel (including the fast Ragel/C HTTP parser), minus the threads, and with teh Unix turned up to 11.
That means processes. And all the tricks and idioms required to use them reliably. We’re going to get into how Unicorn uses the OS kernel to balance connections between backend processes using a shared socket, fork(2), and accept(2) — the basic Unix prefork model in 100% pure Ruby.
I like Unicorn because it’s Unix
I really, really love the whole philosophy this article points to. Aside from how easily it leverages the good ideas in a good operating system, it’s the antidote to all the pain and suffering a lot of my colleagues go through day after day due to the thread based applications they’ve designed or inherited.