Thursday, July 28, 2011

Load balancing with Linux

We want to balance http traffic on a particular link to two backend web servers

User link: http://192.168.1.20

LoadBalancer: 192.168.1.10

Web Server 1: 192.168.1.4

Web Server 2: 192.168.1.5

Method 1

Install the balance module

aptitude install balance

/etc/network/interfaces

auto eth0:1

iface eth0:1 inet static

address 92.168.1.10

netmask 255.255.255.0

post-up /root/balance-script.sh

/root/balance-script.sh

/usr/sbin/balance -b 192.168.1.20 80 192.168.1.4:80 192.168.1.5:80 %

or

/usr/sbin/balance -b ::ffff:192.168.1.20 80 192.168.1.4:80 192.168.1.5:80 %

/etc/sysctl.conf

echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf

Set the web servers default gateway to the Loadbalancer and reboot.

Method 2

Coming soon!

No comments:

Post a Comment