|
|
|
|
|
by anotherjesse
5919 days ago
|
|
I thought the coverage was pretty weak. Not due to unicorn but because there are many options (including passenger (aka mod_rails) for apache) that allow queueing to occur at the proxy instead of at the individual workers. I wish they had discussed why unicorn instead of mongrel and why didn't solutions like haproxy or passenger or ... didn't work? This discussion was: our apache configuration didn't work so we switched the load proxy mechanics and our app server at the same time. I've had great success with mongrels with HAProxy (with maxconns=1 so only 1 request per mongrel at a time) for years. I've also had great success at Passenger with apache. I think it is a great step forward for twitter's servers, I just wish the article had some meat. Isn't this the twitter engineer blog, not blog for the general audience about how twitter works? |
|
But in the edge case of immense load, they simply don't keep up to Unicorn.
The thing that sets Unicorn apart is that it does it's load balancing on the Kernel level. All Unicorn worker processes are listening on the same socket. The OS takes care of getting each request to a single, available worker. So unlike Mongrel, you don't end up with per-worker queues. Though HAProxy is smart about distributing load well, Unicorn makes it seamless. The workers simply ask for a new request and the Kernel gives it one.
There are some other niceties too. Unicorn processes are forked from a master process. If you are using REE, they can keep Rails in a shared memory. When we deployed it, we dropped memory usage by 30%.
On top of all that, Unicorn's flawless rolling restarts are a pretty big plus.
In conclusion, if you're in the top 10% of Rails apps by traffic, give Unicorn a look. It is likely that switching over is worth the dev risk and cost. Otherwise, keep it on your radar, but don't consider it a must-have.
[reference]
http://unicorn.bogomips.org/DESIGN.html
http://news.ycombinator.com/item?id=872283