Ruby-on-rails – Phusion Passenger (for Dummies!)

passengerruby-on-rails

I'm an experienced LAMP developer moving into Rails. I have a very stupid question to ask: what the hell does Phusion Passenger do?

I've read a lot of documentation, I've Googled, I've read Wikipedia, I've read Stack Overflow. I've even installed it and gotten it running on a development machine (with Apache). I still don't know what it's actually doing though.

Here's one guess: I think it's weird that the Apache document root points to /mywebapp/public/ instead of /mywebapp/, so I assume it has to do with making everything inside of /mywebapp/ accessible. (That's a wild guess though, based on the fact that I don't know how else that stuff is getting accessed.)

I've gathered that Passenger is revolutionary, groundbreaking, etc, etc, but what does it do!?

Sorry for the n00b question, everyone. Thanks!

Best Answer

Passenger is a system for preparing and launching instances of Ruby for use with Rack-based applications such as Ruby on Rails. Apache and nginx, the two supported web server platforms, cannot run Ruby like they can PHP, Perl, or Python because there's no built-in Ruby module that works as well as those do. This means Ruby tends to run as an independent group of processes that the web server will have to direct traffic through.

Rails tends to run as a persistent process because the start-up time for the whole stack is significant. Passenger launches new instances as they are required, and will kill off those that are no longer required. You can see this in the process list as they are clearly identified with "Passenger" and "Rails" prefixes.

One feature of Passenger is it will re-use a portion of the Rails stack so that creating additional processes is faster, cloning one instance instead of spinning up a new one from scratch. The loader is written in C++ and handles properly configuring and kicking off each Ruby process as efficiently as possible and also helps save memory by sharing it amongst different processes.

The reason you host things out of the public/ directory is to avoid exposing your application code-base. PHP needs to be configured properly to prevent people from simply browsing directories and downloading the source because there's no specific distinction between static content and executable scripts. A mis-configured server will gladly serve up raw .php files instead of running them, for instance.

Passenger isn't exactly revolutionary, but it does incorporate a number of essential features in a very convenient package. What makes it such a great thing is that it works very well and doesn't demand a lot of attention. Out of the box it's pretty much ready to go.

Related Topic