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 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 undeniable fact that mod_ruby had been painfully sluggish. Skipping ahead a long period later on, we’ve a much wider array of choices for deploying Rails based sites. Such choices consist of slim, traveler, plus the ever popular Unicorn. With one of these servers, Rails designers are now actually ruined with a easier deployment procedure. Anybody who is acquainted with the definition of “stuck mongrel”, where a internet worker hangs and requirements become manually restarted by the operating-system, does know this discomfort.

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

Your website had been 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 might maybe perhaps not carry on with because of the need of demands. We first attempted re solving the situation by increasing the wide range of workers from 5 to 8. Anyone who’s done this before will probably notice that this really is a dual edged blade that may or might not work. Increasing the wide range of employees will develop how many handlers in your pool, however these employees will eat more RAM and can later slow along the system.

After a few times of observing performance, we noted that the rise in employees had a net negative effect, therefore it ended up being back once again to the board that is drawing. Much like most legacy systems, where in actuality the notion of updating an extremely important component of a classic system is mostly about 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 upgrades that are several Mongrel to traveler in past times, I’ve heard of performance improvements that may be skilled by changing Mongrel.

And so I put down to see just what types of performance gain i possibly could attain switching from Mongrel to Unicorn. We decided to go with Unicorn due to the rate benefits (forking, UNIX sockets), the feedback that is positive 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 had been that a change to Unicorn should end up in a diminished response that is average 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 had written little a test plan Apache that is using JMeter accessed probably the most usually struck pages during my internet application. The majority of these pages are look over cached and heavy(although significantly less than i would really like). Then, I went two 30,000 sample tests from the web web web site, comparing 5 mongrels after which Unicorn utilizing a UNIX socket.

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

EVERYTHING?? The difference that is stark standard deviation positively perplexed me. It baffled me personally sufficient that We went the studies 5 more times, but every time We experienced comparable outcomes. What’s therefore astonishing is that Mongrel, a host understood for stuck employees, performed more consistently than its counter that is modern part. Just just exactly What troubled me personally nonetheless had been that I happened to be not able to replicate the pesky 502 mistakes experienced within the manufacturing environment. This informs me 1 of 2 things: either my test isn’t representative of true to life traffic, or my staging host is certainly not suffering from the memory that is same imposed by a cycle-sharing hosting provider like Slicehost.

There’s no nugget that is golden of in this website post apart from genuine shock that a mature bit of technology nevertheless mexican cupid beoordelingen generally seems to last therefore 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 experience with a larger respect for my old, old buddy Mongrel.