Load Balance Server on Ubuntu system
Linux Virtual Server (LVS) is a kernel module that allows one to set up machines as load balancing servers. There are many tutorials on how to get it to work. However, when I tried all those tutorials, for some reason or another it would not work. I messed up many things on my server without knowing exactly what I was doing or how to set them right again. So I abandoned the idea.
BalanceNG (Balance Next Generation) is a modern software IP loadbalancing solution available for Linux and Solaris operating systems.BalanceNG is small, fast and quite easy to use and setup. It offerssession persistence and many different distribution methods (likeRound Robin, Random, IP-Address Hash, Least Resource, Least Session,Least Bandwidth and even a custom distribution method plugin).BalanceNG supports VRRP (Virtual Router Redundancy Protocol) to set up High Available (HA) configurations on multiple BalanceNG nodes.A special mode called “local DSR” (local Direct Server Return) allowsproduction quality HA server load balancing without any additionalhardware.BalanceNG implements a very fast in-memory IP-to-location database,allowing powerful location-based server load-balancing.
Balanceng
There are two versions of it available: a free version (Balance) and a commercial version (Balanceng). It is a user-level program and does not make you mess around with the firewall and kernel. I tried BalanceNG as it was free to be evaluated with one virtual server (load balancer) and two real servers (machines between which traffic has to be balanced). I could not set up the configuration file the way I wanted to.
I did not have the required tools to build software so Installing basic development tools pointed me to the right direction.
sudo apt-get install build-essential
cd /usr/local/src/
sudo tar xvzf ~/Desktop/BalanceNG-1.899-Linux-x86.tar.gz
cdBalanceNG-1.899-Linux-x86
sudo cp bng /etc/init.d/bng
Check that the application was installed where it was supposed to be.
ls /etc/init.d/bng
sudo touch /etc/bng.conf
Now follow the instructions on the product’s website on how to configure it. I was unable to get Balance-NG to work for me. I tried Balance and it felt similar to the next product: Crossroads.
Crossroads
I ended up trying Crossroads. The inspiration was a blog entry — Free load balancer (possible connection broker) for VDI. I downloaded the stable tarball on my desktop and followed their instructions. Following are the steps I took. I did not have the required tools to build software so Installing basic development tools pointed me to the right direction.
sudo apt-get install build-essential
cd /usr/local/src/
sudo tar xvzf ~/Desktop/crossroads-stable.tar.gz
cd crossroads-1.59
sudo make install
Check that the application was installed where it was supposed to be.
cd /usr/local/bin
Create a file called crossroads.conf by using the command below.
sudo touch /etc/crossroads.conf
sudo gedit /etc/crossroads.conf
You may use any text editor other than gedit. I use it because it’s graphical and I don’t need to learn copy-paste in vim or other editor.
My configuration included the following setup: Internet > Firewall > (eth0) Ubuntu Server for Load Balancing (eth1) < Real Servers. These real servers were actually the ones providing services. All the Ubuntu server was doing was forwarding traffic both ways.
Initially, I had two real servers which would get traffic. They would be serving web pages to users. I wanted to keep a user connected to the same machine for the whole session so that there were not too many factors to consider when designing the website within a cluster.
My configuration file contained the following, based on the example provided by the documentation. I have no idea if tabbing and formatting affects the configuration.
service www { port 80; revivinginterval 15; type http; dispatchmode random; backend one { server 172.16.0.10:80; } backend two { server 172.16.0.20:80; } }
Once you have written your configuration file, you can start the server
crossroads start
Surf to the IP address (on eth0 in my case) which the user will be using. Your real servers should now receive connections through the load balancing server and respond to the user through it as well.

(1 votes, average: 4 out of 5)