Monday, November 17, 2008

Load Balancing with pound and Mongrel Clustering

In my previous post I have written about mongrel clustering..

Now if you want to add the load balancing feature to it you may use pound. Pound is a software HTTP Load Balancer and Reverse Proxy.

These are the steps how you can configure pound with mongrel cluster. First configure mongrel cluster as per the previous post.

Then download and install pound from http://www.apsis.ch/pound/Pound-2.0.9.tgz

Now the configuration step

Pound.cfg needs to be configured which will reside in /etc/pound/pound.cfg

also a symlink is required to be made

$ sudo ln -s /etc/pound/pound.cfg /usr/local/etc/pound.cfg

A basic version of pound.cfg will look something like this

User "www-data"
Group "www-data"
LogLevel 2
Alive 30

ListenHTTP
Address 123.123.123.123
Port 80
End

Service
HeadRequire "Host:.*www.dhavalparikh.co.in.*"
BackEnd
Address 127.0.0.1
Port 8080
End
Session
Type BASIC
TTL 300
End
End

Service
URL ".*.mov"
BackEnd
Address 69.12.146.109
Port 8081
End
Session
Type BASIC
TTL 300
End
End

Service
# Catch All
BackEnd
Address 127.0.0.1
Port 9000
End
BackEnd
Address 127.0.0.1
Port 9001
End
Session
Type BASIC
TTL 300
End


Then start pound with the following command

$ sudo /etc/init.d/pound start

finally you will have mongrel cluster setup done so start mongrel cluster

sudo mongrel_rails cluster::start

Thats it you mongrel cluster with pound configuration is done..
njoi the power of load balancing


No comments: