Mongrel vs. Unicorn: A Surprising Benchmark Test Urban Impact

Mongrel vs. Unicorn: A Surprising Benchmark Test Urban Impact

Most designers who’ve been developing with Rails for over 3-4 years will keep in mind the Mongrel internet Server. During the early days of Rails development, Mongrel ended up being generally speaking considered the method that is preferred of for Rails deployments, if for hardly any other explanation compared to undeniable fact that mod_ruby ended up being painfully sluggish. Skipping years that are ahead several, we’ve a much wider selection of alternatives for deploying Rails based internet sites. Such options consist of slim, traveler, while the ever popular Unicorn. By using these servers, Rails designers are now actually ruined with a much simpler implementation procedure. Whoever is knowledgeable about the definition of “stuck mongrel”, where a internet worker hangs and needs 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 to a brand new webserver.

The website ended up being utilizing Mongrel as the Ruby handler and we’d noticed an unsatisfactory number of 502 errors. These mistakes happened during durations of high anxiety where in actuality the Mongrel employees had been overloaded and might maybe perhaps maybe maybe not carry on with utilizing the need of demands. We first attempted re re solving the issue by increasing the wide range of employees from 5 to 8. Anyone who’s done this before will probably notice that that is a dual edged blade that may or might not work. Increasing the quantity of employees will develop how many handlers in your pool, however these employees will consume 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 again to the board that is drawing. Just like legacy systems that are most, where in fact the concept of updating an essential component of a classic system is approximately since welcoming as a supper invite from Jeffrey Dahmer, we wasn’t delighted concerning the concept of ripping out of the old Mongrel webserver. Nevertheless, having done upgrades that are several Mongrel to traveler within the past, I’ve heard of performance improvements that may be experienced by changing Mongrel.

And so I put down to see just what form of performance gain i possibly could attain switching from Mongrel to Unicorn. We 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 get a wine in line with the label).

My theory had been that a change to Unicorn should end in a lower life expectancy normal response times and less 502 Bad Gateway mistakes. The things I discovered kept me personally scraping my mind and re-running performance tests over and over I wasn’t crazy until I was sure.

To check my theory, we published tiny a test plan Apache that is using JMeter accessed probably the most usually struck pages during my internet application. The vast majority of these pages are look over hefty and cached (although not as much as i would really like). Upcoming, I went two 30,000 test tests up against the web web site, comparing 5 mongrels after which Unicorn employing a UNIX socket.

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

EVERYTHING?? The difference that is stark 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 contemporary countertop component. Exactly just exactly What troubled me personally nonetheless ended up being that I became not able to replicate the pesky 502 mistakes experienced within the manufacturing environment. This informs me 1 of 2 things: either my test is certainly not representative of real world traffic, or my staging host is certainly not suffering from the exact same memory constraints imposed by way of a cycle-sharing hosting provider like Slicehost.

There’s absolutely no nugget that is golden of in this website post aside from genuine shock that a mature bit of technology nevertheless appears to last therefore well. It is not surprising why slim, another popular internet host, makes use of Mongrel’s parsing engine. We arrived on the scene of the experience with a higher respect for my old, old buddy Mongrel.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *