Tim, the Enchanter

What manner of man are you that can summon up code without C# or Java?

Friday, May 2, 2008

 

Mod_rails is AWESOME

Last week, as I was about to deploy a small application, I got a case of "ughh". Well, if there is such a case, I had it. Normally, I deploy with mod_fcgid, Apache, and suexec. It's an awesome solution that's difficult to set up but easier to maintain.

mod_fcgid Deployment

Roughly, here's the steps to such a deployment:

You can imagine why I dreaded doing that for one tiny non-mission-critical application with one controller.

Mongrel Cluster with HTTP Proxy Deployment

The Mongrel Cluster / HTTP proxy is a great solution, perhaps the most popular now. I've never been a huge fan. Why? Well... I'll tell you (he's going to tell, he's going to tell... @ 7:30)

So, it's a great option, but more work than I'd like to do, and I'd still prefer to set up mod_fcgid because I'm much better at it than mongrel, and I just really like having Apache start my application servers.

Passenger (mod_rails) to the rescue

So I heard some buzz recently about Passenger (aka mod_rails): something about rails deployment as easy as uploading your application. That sounded really good. I didn't care about benchmarks for this app, but as it turns out, passenger is about on par with "thin", and is faster than mongrel! Sweet lovin'.

After 2 minutes of going through the setup instructions and deploying my code, I was incredulous. "Watch, I'm going to start the application up, and everything will just fall apart." I was pleasantly proven wrong!

Here's a summary of the install steps for mod_rails (Passenger)

And, I was pleasantly shocked to discover that it intelligently ran the rails processes as the user I deployed the application as. It checks config/environment.rb, and runs as the owner of that file. Hot stuff! And to reboot the server, just type "touch tmp/restart" - You could reboot your app with scp, rsync, ssh, ftp, samba, magnetic needles, anything! No need to have sudo access. No pid files. No "killall". Hot hot hot!

How's stability? I've converted our mongrel and fcgid deployments over to mod_rails now. Things are running smoothly. There seems to be a bit of a lag if the app isn't in use for a while (I don't think it keeps a minimum pool available, which would be a nice feature). I had a few issues with slowness on version 1.0.1, but 1.0.2 and onward has been rock solid. Oh - 1.0.4 doesn't work on the default install of Apache server for OS X Server - use 1.0.3 instead.

In Conclusion...

Here's a table of deployment scenarios with strengths and weaknesses, according to me and my experience.
mod_rails fcgid Mongrel Cluster
Speed Great (enterprise edition rumoured to be much faster) Great Great
Memory usage Slightly better (enterprise edition rumoured to reduce memory consumption by 33%) Slightly better Average
Reliability Great Great Pretty good
Ease of setup Easy Difficult Moderate
Graceful restarts?
(restart app w/out dropping a single request)
Yes Yes Possible (send kill -USR2 all mongrel pids)
App restarted on apache restart Yes Yes No
Automatic process cycling Yes Yes No
Process management Allocates on demand Allocates on demand Fixed regardless of load
Ability to set minimum process count per App No Yes Yes
Set max process count per App No (... actually, yes!) Yes Yes
I'm completely converted. I'm never going to go through that deployment nightmare again! Kudos to the Phusion folks for putting such a great solution together. If you've got a small app that you need to deploy, give it a spin. You won't regret it.

Comments:
Glad you like it. :)

About '"Zombie" process recovery' - Passenger doesn't create zombie processes, ever. We use a technique called "double forking" in order to prevent zombies from being created.

As for OS X compatibility: we're really sorry that 1.0.4 broke it. Before we released 1.0.4, a tester confirmed that 1.0.4 works fine on OS X, but apparently he was wrong or there's something else going on. In order to fix the problem, we're looking for as many OS X users as possible, and we'd really like to have your feedback. Please join #passenger on irc.freenode.net if you're interested.

With kind regards,
Hongli Lai
- phusion.nl
 
Post a Comment

Subscribe to Post Comments [Atom]





<< Home

Archives

March 2008   April 2008   May 2008   June 2008   July 2008   August 2008   October 2008   November 2008   February 2009   June 2009   December 2009   January 2010   February 2010   May 2010   June 2010   November 2010  

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]