At work, the datacenter has been expanding with more work and more traffic. As part of the expansion plan I’ve been researching different loadbalancing solutions. Traditionally, we’ve used the Windows Network Load balance service built into Windows Server but it is a Layer4 load balancer. It isn’t very intelligent and, sometimes, isn’t reliable. The web service on Windows server 1 could be stopped, yet Windows server 2 is still operating and half your visitors will get the downed server. This is the difference between Network (layer 4/TCP) and application (layer 7/HTTP) load balancers.
RabbitMQ cluster with HAProxy on a single Windows machine Recently I had to deal with RabbitMQ. I use Windows 7 x64, but any version supported by RabbitMQ should be fine. Switch to the folder with unpacked sources and run make to build and install HAProxy: cd haproxy-1.4.24.
We’ve had a good experience with Cisco so were looking forward to try their ACE load balancer. Sadly, they shut that down. Barracuda was a little expensive as was the F5. I’ve heard a lot of great things about HAProxy so I decided to give that a shot. In this lab we’ll be creating a HAProxy loadbalancer connected to 2 webservers.
All of this is virtualized in our datacenter. The datacenter is comprised of a cluster of VMware ESXi servers with 1 management and 1 public network. Management: 10.0.5.0/24 Public: 10.0.0.0/24. Grab your favourite Linux distribution. I alternate between Debian and CentOS, a lot. Debian has been my go to for ages so I’ll be using for this post. We won’t need the full install since it will be a stripped down appliance, basically.
Create your virtual machine. Set the cluster to using guest OS “Debian 6 GNU/Linux (64-bit)”, 1 CPU, 2 GB RAM, use VMXNET3 (the Intel E1000 driver is CPU constrained), with LSI Logic SAS, and 10GB thin provisioned disk. Boot your virtual machine with the Debian Netinstall ISO and complete the installation. Once complete install the VMware tools. In the vSphere Windows console select guest and “Install/Upgrade VMware Tools.” Then in the console server console: # mount /dev/cdrom /media/cdrom; # cp /media/cdrom/VMwareTools-x.x.x.tar.gz /tmp/ # cd /tmp/; tar -xzvf VMwareTools-x.x.x.tar.gz # apt-get install gcc make # apt-cache search linux-header # apt-get install linux-headers-x.x.x-amd64 # /tmp/vmware-tools-distrib/vmware-install.pl Once VMware tools is installed you may need to restart the server. HAProxy isn’t in the main library of Debian Wheezy.
To get it will need the backports repo. So create the file # nano /etc/apt/sources.list.d/backports.list And add the line deb wheezy-backports main And update your catalog and install HAProxy # apt-get update # apt-get install haproxy After install haproxy change the service default to enabled # nano /etc/default/haproxy ENABLED=1 We won’t be creating the failover just yet. Once the main haproxy server is configured we can clone it using the vSphere console and update the IP address.
For the moment install. # apt-get install keepalived In part 2 we’ll continue working on the load balancer appliance by configuring web server delegation (round robin, etc).