Ruby EE, Passenger, and Gems

Last week one of our applications ran out of memory, started swapping like crazy, and taking minutes to return a response. It was one of those bittersweet moments where you're excited to be getting so much load, but panicking because the site is going down. This application is being hosted at Slicehost and the (relatively) quick fix was to resize the slice to get more memory.

In the aftermath, I started investigating some potential fixes to the memory consumption issue. The first thing I looked at was Passenger. To my surprise, when we configured the server, we somehow missed the installation of Ruby Enterprise Edition (Ruby EE). Luckily, the guys at Phusion make it dead simple to install, just download, extract, and run the installer.

If you're using Passenger (you are, right?), you'll need to recompile the Apache module, tell Apache to use the Ruby EE optimized version, and restart Apache. The installers make this whole process seriously easy.

Like a good developer, I freeze my gems and rails itself into the application to avoid gem management on the server as much as possible. I flipped the switch to restart Apache and the application blew up because of missing gem dependencies. As expected, though forgotten, Ruby and Ruby EE don't share their gems. A quick call to rake gems revealed I had one gem requiring compilation that wasn't frozen into the application.

I quickly found the Ruby EE specific gem command, installed the missing gems, and all was well. Here's the command for anyone else that took down their application by missing gem dependencies:

   1  /opt/ruby-enterprise-1.8.6-XXXXXXXX/bin/ruby \
   2  /opt/ruby-enterprise-1.8.6-XXXXXXXX/bin/gem install gem-to-install

Most agencies want to build it, bill it, and move on. Not us. We’re in it for the long haul. Nearly every client we’ve ever had is still our client and those applications are still running at full speed.


FlixCloud - On-demand Video Encoding Red Is White - Christian T-Shirts