A quick note to announce the release of mongrel_cluster, a gem_plugin for the Mongrel web/application server. This plugin makes it easy to manage multiple Mongrel processes behind a reverse-proxy server and load balancer such as Pound, Balance, Lighttpd, or Apache.

This is the first of many release to support simplified Ruby on Rails application deployment using Rails Machine.

Setup

To get started, install the gem:

sudo gem install mongrel_cluster
Configure the cluster and generate a configuration file. This will run 2 mongrel processes on port 8000 and 8001 using “production” environment :
cd /path/to/my/rad/app
mongrel_rails cluster::configure -p 8000 -e production -a 127.0.0.1

With the configuration file written, you can easily start, stop, and restart the cluster. By default the file is written to config/mongrel_cluster.yml, but you can change the path with the “-C” option.

Start the cluster:
mongrel_rails cluster::start
Restart the cluster:
mongrel_rails cluster::restart
Stop the cluster:
mongrel_rails cluster::stop

Reverse proxy and load balancing

Pound is a reverse proxy, load balancer and HTTPS front-end. It is very easy to configure for use in front of a mongrel cluster.

Install Pound from source or packaging system of choice then edit your configuraton (most likely in /etc/pound/pound.conf).

Sample configuration for use with mongrel_cluster:
User "nobody" 
Group "nobody" 

ListenHTTP
  Address ip.address.goes.here
  Port 80

  Service
    Backend
      Address 127.0.0.1
      Port 8000
    End
    Backend
      Address 127.0.0.1
      Port 8001
    End
  End 
End
Start Pound:
sudo pound -f /etc/pound/pound.conf

So far in our testing for Rails Machine, this setup works well and its dead simple to setup and maintain. If you don’t want Mongrel to handle static files you could put lighttpd behind Pound and route requests for /images, /stylesheets, /javascript, and other specific paths. This will give you a performance boost on static files, but increase the complexity of your deployment. Your application may not need faster static file serving.

For information on using Mongrel behind Apache, read Scaling with Rails with Apache 2.2, mod_proxy_balancer and Mongrel.

Good luck!

2 Comments

Hey thanks for this Bradley. Very nice. I am using pen instead of pound as my load balancer but the idea is exactly the same. It works great. Now it will be even easier to manage the mongrels with your plugin.
The question that you may be asking is How do I get these reciprocal links?

Leave a Comment

back to top

micro theme by seaofclouds, and powered with Mephisto