1

what is the optimum OS,server, etc setup for rails production environment?

Your recommendations?

thanks

cbrulak
  • 15,436
  • 20
  • 61
  • 101

1 Answers1

4

There are many, many different ways to configure a Rails server. I don't know if there if such a thing as an 'ideal' config. I will tell you how I have my server configured and why.

Operating System: Linux, any distribution.

This is the only server platform that makes any sense. The Ruby community is centered around Linux, but BSD would be a perfectly good choice as well. I am most comfortable with Linux.

OSX is a great development platform, but the extra cost doesn't really buy you anything on the server side you can't get on Linux. And Apple is phasing out the Xserve platform, so there likely isn't a future there anyway. Don't even think about using Windows.

Web Server: Apache + Phusion Passenger

I recommend Apache because it's everywhere. Everyone knows it. Getting support is dead simple.

Phusion Passenger is probably the easiest application server to get started on. Here's a sample VirtualHost config:

<VirtualHost x.x.x.x:80>
    ServerName xxxx.com
    DocumentRoot /var/www/xxxx/current/public
    PassengerHighPerformance on
    <Directory "/var/www/xxxx/current/public">
        AllowOverride all
        Options -MultiViews
    </Directory>
    AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/json
    AddOutputFilterByType DEFLATE image/jpeg, image/png, image/gif
</VirtualHost>

That's it. (And most of that isn't strictly necessary)

Ruby interpreter: Ruby Enterprise Edition

I use this instead of vanilla MRI because it's a bit more memory efficient, which makes a big difference on the server. It is also made to integrate with Passenger.

One downside to REE is that it is based on 1.8.7. You may want to use 1.9.2 instead because there is a significant performance benefit.

Gem Management: RVM

RVM lets you create sandboxed gem environments for different applications, in case there are version conflicts. Highly recommended for your development environment as well.

Deployment System: Capistrano

If you're not using Capistrano, you should. This will be the single biggest time-saver you can do for production deployment. It will also make rolling back to the previous version dead simple if theres a problem.

You should also have ExceptionNotifier installed. If there's an exception on your production server you should know about it.

I also highly recommend checking out NewRelic RPM for profiling. Even the free version provides some useful info.

Community
  • 1
  • 1
Adam Lassek
  • 35,156
  • 14
  • 91
  • 107
  • Great answer. nginx is getting extremely popular, but I think your argument for apache makes sense. Only thing I would maybe question is if we are talking rails 3, MRI 1.9.2 may be a better choice then ree. ree for 1.8.7 is a no brainer though. – Matt Briggs Nov 10 '10 at 04:40
  • @tchrist touche! BSD would be a perfectly good server as well. Sorry for the Linux blinders. – Adam Lassek Nov 10 '10 at 04:47
  • @Matt I would be interested in hearing from an nginx user why they chose it over Apache. I'm always open to trying different configurations if there's a clear benefit. – Adam Lassek Nov 10 '10 at 04:58
  • nginx is (imo) simpler to set up in a general way, and the passenger installer works the same. It also takes less memory, and performs better. Apache is probably the most battle tested server out there though, and supports everything under the sun, but nginx has the advantage of being newer and learning from mistakes. – Matt Briggs Nov 10 '10 at 06:15