Jan 16, 2010

Moving to Ruby Enterprise Edition

I use Phusion Passenger for all my production stacks these days. But I'm still using plain old Ruby 1.8.7 in production despite the well documented performance improvements provided by Ruby Enterprise Edition. Today was the day I decided to take the plunge.. I have a 1GB stack on Slicehost and noticed some swapping, an indicator that the 33% reduction in memory use would be really helpful. If you decide to undertake this as well, I have a few warnings..

If you followed the directions and the subsequent instructions provided by the installer to update your apache conf, you'll notice something almost immediately:

Your app doesn't work.

Why? Well, you installed a new version of Ruby so you'll need to reinstall your gems too. Good news is that if you've added your config.gems in your environment.rb you should be ok and it can be much faster. First though, I'd highly recommend making some symlinks. This will allow rake tasks to continue to work without adding a giant prefix. Thanks to this blog entry from Webficient:

sudo ln -fs /opt/ruby-enterprise-1.8.7-2009.10 /opt/ruby-enterprise
sudo ln -fs /opt/ruby-enterprise/bin/gem /usr/bin/gem
sudo ln -fs /opt/ruby-enterprise/bin/irb /usr/bin/irb
sudo ln -fs /opt/ruby-enterprise/bin/rake /usr/bin/rake
sudo ln -fs /opt/ruby-enterprise/bin/rails /usr/bin/rails
sudo ln -fs /opt/ruby-enterprise/bin/ruby /usr/bin/ruby

If you followed any of my tutorials on install a rails stack you also have symlinks in /usr/local. Let's get rid of those and then create new symlinks:

vince@lagos:~$ cd /usr/local/
sudo rm gem
sudo rm irb
sudo rm rdoc
sudo rm ri
sudo rm ruby

sudo ln -s /opt/ruby-enterprise/bin/ruby /usr/local/bin/ruby
sudo ln -s /opt/ruby-enterprise/bin/gem /usr/local/bin/gem
sudo ln -s /opt/ruby-enterprise/bin/rdoc /usr/local/bin/rdoc
sudo ln -s /opt/ruby-enterprise/bin/ri /usr/local/bin/ri
sudo ln -s /opt/ruby-enterprise/bin/irb /usr/local/bin/irb

After that you should be able to do a regular sudo rake gems:install, but if not you'll have to reinstall your gems with the full path prefix. e.g.:

sudo /opt/ruby-enterprise-1.8.7-2009.10/bin/ruby /opt/ruby-enterprise-1.8.7-2009.10/bin/gem install will_paginate

I'll be keeping an eye on performance but so far I like what I see. If you are tempted to do this upgrade, I highly recommend you make sure your stack is up to date (both binaries and gems) and that you've backed up everything. Good luck!

No comments:

Post a Comment