Mongrel vs. Unicorn: A Surprising Benchmark Test Urban Impact

Many designers who’ve been developing with Rails for over 3-4 years will keep in mind the Mongrel online Server. During the early days of Rails development, Mongrel had been generally speaking considered the favored approach to option for Rails deployments, if for hardly any other explanation as compared to undeniable fact that mod_ruby ended up being painfully sluggish. Skipping ahead many years later on, we’ve got a much wider selection of choices for deploying Rails based web sites. Such choices consist of slim, traveler, as well as the ever popular Unicorn. With one of these servers, Rails designers are now actually ruined by having a much simpler implementation procedure. Anybody who is knowledgeable about the word “stuck mongrel”, where a internet worker hangs and requirements to be manually restarted by the operating-system, knows of this discomfort.

This week I experienced the chance to assist a client upgrade one of the legacy systems to a brand new webserver.

Your website ended up being Mongrel that is using as Ruby handler and we’d noticed an unsatisfactory number of 502 errors. These mistakes happened during durations of high anxiety in which the Mongrel employees had been overloaded and may maybe not keep pace using the demand of demands. We first attempted re solving the difficulty by enhancing the wide range of employees from 5 to 8. Anyone who’s done this before will probably observe that this is certainly a dual sword that is edged may or might not work. Enhancing the amount of employees will develop the sheer number of handlers in your pool, however these employees will eat more RAM and can afterwards slow straight down the system.

After a few times of observing performance, we noted that the rise in employees had a web negative impact, therefore it had been back into the board that is drawing. Much like most legacy systems, in which the concept of updating an essential component of a classic system is all about because welcoming as a supper invite from Jeffrey Dahmer, we wasn’t delighted in regards to the concept of ripping out of the old Mongrel webserver. Nevertheless, having done a few upgrades from Mongrel to traveler in past times, I’ve heard of performance improvements which can be skilled by changing Mongrel.

Therefore I put down to see just what style of performance gain i really could attain switching from Mongrel to Unicorn. I selected Unicorn due to its rate benefits (forking, UNIX sockets), the good feedback it has gotten through the Rails community, and because I like Unicorns (yes, I’ve been known to acquire a wine in line with the label).

My theory ended up being that a change to Unicorn should lead to a diminished normal response times and less 502 Bad Gateway mistakes. The thing I discovered kept me personally scraping my mind and re-running performance tests over repeatedly I wasn’t crazy until I was sure.

To check my theory, we penned tiny a test plan Apache that is using JMeter accessed probably the most usually struck pages within my internet application. The vast majority of these pages are look over hefty and cached (although significantly less than i would really like). Upcoming, I went two 30,000 test tests resistant to the web site, comparing 5 mongrels after which Unicorn utilizing a UNIX socket.

Here’s exactly exactly exactly what i discovered evaluation 50 users that are simultaneous a total of 30k examples per run:

EVERYTHING?? The stark huge difference in standard deviation positively perplexed me. It baffled me personally sufficient I experienced similar results that I ran the trials 5 more times, but each time. What exactly is therefore astonishing is the fact that Mongrel, a host understood for stuck employees, done more consistently than its counter that is modern component. Exactly exactly just What troubled me personally but ended up being that I happened to be not able to replicate the pesky 502 mistakes experienced into the manufacturing environment. This informs me 1 of 2 things: either my test just isn’t representative of actual life traffic, or my staging host is certainly not suffering from the exact same memory constraints imposed by a cycle-sharing hosting provider like Slicehost.

There’s absolutely no nugget that is golden of in this website post apart from genuine shock that an adult bit of technology nevertheless appears to endure very well. It is not surprising why slim, another web that is popular, makes use of Mongrel’s parsing engine. I arrived on the scene of the knowledge about a larger respect for my old, old buddy Mongrel.