Load Balancing with HAProxy
HAProxy stands for High Availability Proxy, is an open-source TCP/HTTP load balancer. In case you are new to the idea of a load balancer, the work of a load balancer is to distribute incoming requests to an array of upstream servers so as no single upstream server is overworked/overloaded by the incoming requests.
HAProxy has been reported to be highly efficient and fault tolerant, and it is also claimed that HAProxy has never crashed in a production environment. HAProxy is very configurable, you can chose for a variety of load balancing algorithms like Round-Robin, Source, LeastConn, etc., it also provides support for sticky session, provides detailed logs and monitoring stats. In this article we'll look at installing and setting up a basic HAProxy load balancer.
Firstly, download the source tarball from HAProxy official website (http://haproxy.1wt.eu/), then untar, build and install:
Now, you have built and copied the standalone HAProxy executable to the sbin directory, you can run haproxy as a command.
There are lots of configuration options, it can be as easy as the installation or something very complicated, it all depends on your requirements. Here we'll look at a very simple configuration example, I've added comments for easier understanding of the configuration directives, you can find the complete configuration guide on the HAProxy website (http://haproxy.1wt.eu/#docs)
You can put the HAProxy configuration file wherever you want, for example I put it in /etc/conf/haproxy.conf
To start HAProxy with the configuration issue the following command:
To view the stats, the URL would be haproxy.go4expert.com/haproxy?stats
I hope it has been helpful to you, post your experiences so that we all can share and learn.
|All times are GMT +5.5. The time now is 00:55.|