Linux Distributions For Rails Hosting: Viget's First Annual(?) Shakedown
Mark Cornick, Former Viget
Here at Viget, we've done a variety of Rails deployments for our many clients. Nearly all of these have been to dedicated Linux systems, and between those we've seen a number of different Linux distributions. Which distribution has what it takes to successfully run your application? This post compares four popular distributions' support for the basic building blocks of a standard Rails stack, and provides some of our own advice and experience.
Let's get a few things settled before we start. As I mentioned, we're going to look at four popular Linux distributions in this article. In no particular order:
- CentOS 5.2: CentOS is built from the same sources as the Red Hat Enterprise Linux offering. We're including it because many of our customers' servers run a form of Red Hat Linux, and so we use CentOS in-house for staging, as well as for most of our internal Linux systems.
- Ubuntu 8.04 (aka "Hardy Heron"): Ubuntu is a popular choice for VPS offerings. We use Ubuntu internally as well, and several of our clients have it in production.
- Fedora 9: As the open-source descendant of the old Red Hat Linux offering, Fedora has a lot of fans, and is typically more up-to-date than CentOS, so it's fair to include it.
- openSUSE 11: I've worked in at least one Novell shop that used Novell's Linux product; openSUSE is the basis for that product, as Fedora is for RHEL.
Whenever anyone, anywhere compares Linux distributions, there is inevitable outcry that someone's favorite Linux distribution wasn't included. To those who are fans of Debian, Gentoo, Mandriva, TurboLinux, Rock Linux, or the Linux you built yourself from source, I apologize that time and space don't permit us to consider every Linux distribution out there. We are also skipping non-Linux operating systems, like Solaris and the BSD clan, for similar reasons. Lastly, we are considering only the most recent stable release of each distribution. In particular, we are skipping RHEL 4, which remains in production for several of our clients; the less said about its suitability for modern Rails deployment, the better.
Next, let's define the elements of the Ruby on Rails stack:
- We need Ruby, of course. Recent versions of Rails need at least version 1.8.4 of Ruby; 1.8.6 is our preferred version at present.
- We need a front-end server. For this, we're going to use Apache, as it's what we use for nearly all of our clients and internal IT. Version 2.2 of Apache is best suited for proxying to Ruby application servers. Nginx is also popular for this purpose; although we don't use it as much as Apache, we will nevertheless compare it as well.
- We are going to assume that we are using RubyGems for installing application servers (such as Mongrel or Thin) and any library dependencies our application needs. Therefore, our distribution should provide a RubyGems package of some sort. We won't get into installing individual gems.
- Lastly, we need a database. With all apologies to fans of PostgreSQL, we are going to use MySQL 5.0 as our database server. (We will disqualify proprietary databases like Oracle, since they are typically not included with the Linux distribution.)
For each of these components, we will look at the version included with each distribution; also, we will apply all of the updates to each distribution that were available for download as of July 18.
A few more preliminaries: We are only considering the support for the packages used in our stack, so factors like the installation process, packaging format, etc. will not factor into the discussion. Also, we are looking at the IA-32 (i386) version of each distribution, although for the packages we are considering, there is almost certainly no difference between the IA-32 platform version and any others.
Let's get started!
Ruby support is pretty good among the four distributions.
- Ubuntu: Ubuntu includes version 1.8.6p111 of Ruby. This is adequate for Rails.
- openSUSE: openSUSE includes version 1.8.6p114 of Ruby. This is also adequate for Rails.
- Fedora: Fedora includes version 1.8.6p230 of Ruby, the most recent release of Ruby 1.8.6.
- CentOS: CentOS includes version 1.8.5 of Ruby. While most current Rails applications will work fine on 1.8.5, most of the rest of the world has moved on to 1.8.6.
Verdict: Fedora, Ubuntu, and openSUSE are all up-to-date, with Fedora the absolute freshest. For CentOS, you may find yourself upgrading to 1.8.6 by hand.
All four distributions include a 2.2.x version of Apache. Furthermore, all four distributions include the mod_proxy_balancer module, which is typically used to load-balance in front of your cluster of application servers.
- Fedora: Fedora includes version 2.2.8 of Apache, one release behind the current version.
- Ubuntu: Ubuntu also includes version 2.2.8 of Apache.
- openSUSE: openSUSE also includes version 2.2.8 of Apache.
- CentOS: CentOS includes version version 2.2.3 of Apache. mod_proxy_balancer has received several updates since 2.2.3, but in our experience, the version in CentOS works fine.
Verdict: The four distributions' Apache packages are all suitable.
All four distributions include a recent 5.0.x build of MySQL.
- openSUSE: openSUSE includes version 5.0.51a of MySQL, the most recent release of MySQL 5.0.
- Fedora: Fedora also includes version 5.0.51a of MySQL.
- Ubuntu: Ubuntu also includes version 5.0.51a of MySQL.
- CentOS: CentOS includes version 5.0.45 of MySQL. This is two releases behind the other distributions, but as with Apache, the CentOS version is working well for us.
Verdict: The four distributions' MySQL packages are all suitable.
So far, all of our distributions have fared well in keeping up to date with current versions of our selected software. Unfortunately, that ends here.
- CentOS: CentOS does not include a RubyGems package. However, one can be obtained by using Fedora's EPEL repository. EPEL includes version 0.9.4 of RubyGems, which is several versions behind the current version of 1.2.0.
- Fedora: Fedora includes version 0.9.4 of RubyGems; the EPEL package is based on the Fedora package.
- Ubuntu: Ubuntu includes version 0.9.4 of RubyGems in the universe repository. However, the backports repository, which is not enabled by default, includes version 1.1.1, which is more nearly up-to-date.
- OpenSUSE: OpenSUSE includes version 0.9.2 of RubyGems, the most out-of-date of the four distributions.
Verdict: All four distributions' RubyGems packages are obsolete (except for the 1.1.1 package in Ubuntu backports.) You will likely be better off downloading and installing RubyGems 1.2.0 by hand. (Additionally, Ubuntu's packages, which are inherited from Debian, place RubyGems-installed executables in a non-standard location due to Debian policy, requiring changes to your shell's dotfiles. Building from source would eliminate this minor frustration.)
- CentOS: CentOS does not include an Nginx package. Again, you can use the package from EPEL, which includes version 0.6.31 of Nginx, which is only one release behind the current 0.6 version.
- Fedora: Fedora includes version 0.6.31 of Nginx; the EPEL package is based on the Fedora package.
- OpenSUSE: OpenSUSE includes three versions of Nginx in its Factory repository: 0.5.36, 0.6.31, and 0.7.1. You probably do not want to use 0.5.36 (a legacy version) or 0.7.1 (a development version) for production sites, but they are available should you need them.
- Ubuntu: Ubuntu includes version 0.5.33 of nginx in the universe repository. There is no Nginx 0.6 package for Ubuntu 8.04, although there is an 0.6.31 package in Ubuntu 8.10 (Intrepid), the upcoming release.
Verdict: CentOS, Fedora and openSUSE all have good Nginx packages. The package currently in Ubuntu is a little out of date.
CentOS trails versions in many of our tests; to be fair, CentOS ships less frequently than the other three distributions, and the RHEL releases upon which they are based are intended to be supported for longer periods of time (the exception being Ubuntu 8.04, which will be supported for five years, as is RHEL; typical Ubuntu releases are not supported for that long.) Red Hat keeps these older versions up to date with necessary patches, so with the exception of Ruby 1.8.5, you should be OK with the CentOS packages, despite their lower version numbers.
The flip side of the sorry state of RubyGems packages is that three of the distributions - Fedora, openSUSE, and Ubuntu - provide their own packages of many popular Ruby libraries. This includes things like RMagick that are sometimes tricky to install. We still prefer using RubyGems itself whenever possible, but you may be able to make things work with these packages. (EPEL provides a subset of Fedora's packages for CentOS, as well.)
The factors we've talked about here are not the only ones worth considering. Assuming you have Linux sysadmin experience on your staff, that experience is important to consider, since all distributions are slightly different; for instance, if your sysadmin has extensive Red Hat experience, Fedora and CentOS should carry a little more weight. Additionally, your options may be limited by your (or your customer's) choice of host; not all hosts will provide all of these distributions as installation options.
You can't go too wrong with any of these choices. CentOS needs some extra work to get going, but works well and is very stable going from there. Ubuntu is also a good long-term choice, with 8.04's five-year support and decent support for nearly everything on our list. Fedora and openSUSE are currently the most up-to-date, and will likely stay that way, although having the newest version of everything is occasionally a curse rather than a blessing.
Here at Viget, we'll likely be sticking with our choices of CentOS 5.2 and Ubuntu 8.04, though Fedora 9 impressed us. openSUSE loses for us solely on the lack of sysadmin experience; as Viget's de facto and de jure system administrator, I've got a much longer track record with Red Hat- and Debian-based distributions. openSUSE is still a worthy choice for those without my particular history.
Whatever you choose, we wish you the best of luck. And if you have anything to add to our analysis, have at it in the comments.