Mongrel vs. Unicorn: A Surprising Benchmark Test Urban Impact

Mongrel vs. Unicorn: A Surprising Benchmark Test Urban Impact

Many designers who’ve been developing with Rails for over 3-4 years will recall the Mongrel internet Server. During the early days of Rails development, Mongrel had been generally speaking considered the method that is preferred of for Rails deployments, if for hardly any other explanation compared to the proven fact that mod_ruby ended up being painfully sluggish. Skipping ahead a long period later on, we’ve got a much wider number of alternatives for deploying Rails based sites. Such choices include slim, traveler, plus the ever popular Unicorn. With one of these servers, Rails designers are actually ruined by having an easier deployment procedure. Anybody who wiccan dating apps is acquainted with the definition of “stuck mongrel”, where an internet worker hangs and requirements become manually restarted by the os, does know this discomfort.

This week I experienced the chance to assist a client upgrade one of the legacy systems up 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 occurred during durations of high anxiety where in actuality the Mongrel employees had been overloaded and may perhaps perhaps not keep pace with the need of demands. We first attempted re re solving the issue by enhancing the amount of employees from 5 to 8. Anyone who’s done this before will probably notice that that is a dual sword that is edged may or may well not work. Increasing the range 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 ended up being back again to the drawing board. Much like most legacy systems, where in actuality the notion of updating a key component of a classic system is approximately because welcoming as a supper invite from Jeffrey Dahmer, we wasn’t delighted concerning the notion of ripping out of the old Mongrel webserver. Nonetheless, having done a few improvements from Mongrel to traveler within the past, I’ve heard of performance improvements that may be skilled by changing Mongrel.

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

My theory ended up being that a change to Unicorn should end up in a diminished response that is average and less 502 Bad Gateway errors. The thing I found kept me personally scratching my mind and re-running performance tests over and over I wasn’t crazy until I was sure.

To try my theory, we composed tiny a test plan making use of Apache JMeter that accessed probably the most usually struck pages during my internet application. The vast majority of these pages are look over cached and heavy(although lower than i would really like). Upcoming, I went two 30,000 test tests from the web web web site, comparing 5 mongrels after which Unicorn employing a UNIX socket.

Here’s exactly exactly just what i discovered assessment 50 simultaneous users for a total of 30k examples per run:

EVERYTHING?? The stark difference between standard deviation positively perplexed me. It baffled me personally sufficient that We ran the studies 5 more times, but every time We experienced similar outcomes. 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 exactly What troubled me personally but had been 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 true to life traffic, or my staging host just isn’t suffering from the memory that is same imposed by a cycle-sharing hosting provider like Slicehost.

There is absolutely no nugget that is golden of in this website post apart from genuine shock that a mature little bit of technology nevertheless generally seems to last very well. It is no wonder why slim, another popular internet host, makes use of Mongrel’s parsing engine. We arrived on the scene of the knowledge about a larger respect for my old, old buddy Mongrel.