The Awesomeness of Unicorn

The Awesomeness of Unicorn

30 Jan 2010 – Warsaw

This article is a stub. You can’t help, I’m going to make it a full-fledged blog post in the future. As for now — Unicorn ;) is Awesome

Unicorn’s killer features

…or simply advantages over other Rails application servers (Passenger, Mongrel etc.). This is a quite personal list of things that really made me go “wow” while and after tinkering with Unicorn and migrating three deployments (development, beta, production) of one application from Passenger to Unicorn.

So, here’re the things that make Unicorn awesome for me:

no matter the amount of instances, application code is loaded from disk only once, by “master” Unicorn process (the one that just passes requests and manages workers), worker processes get the memory copy using fork()

restarts of the application with zero downtime; simplifying things a bit, Unicorn basically serves old version of the application while the new one is loading and jumps to serving new one the moment it becomes available (it’s a bit more complex under the hood, but that’s what it looks like for the client)

master process manages all the workers by himself, taking care of killing them, spawning new ones or changing the number of workers caused differenly (see below)