HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications. It is particularly suited for very high traffic web sites and powers quite a number of the world's most visited ones. Over the years it has become the de-facto standard opensource load balancer, is now shipped with most mainstream Linux distributions.

Deploying your cloud server
If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can easily deploy your cloud servers.

Once you have signed up, log into your Cloudwafer Client Area with the password provided in your mail and deploy your Cloudwafer cloud server.

Updating System Packages on CentOS
It is always recommended that you update the system to the latest packages before beginning any major installations. This is done with the command below:

sudo yum update

Step One: Install Haproxy

Issue the command below to install haproxy:

sudo yum install haproxy

Step Two: Configure the load balancer
An HAProxy basic configuration informs the load balancing system on what kind of connections it should be listening for and which servers it should relay the connections to.

We are going to create a configuration file /etc/haproxy/haproxy.cfg containing the necessary settings and configurations.

sudo nano /etc/haproxy/haproxy.cfg

Enter the following into the file:

   log /dev/log local0
   log /dev/log local1 notice
   chroot /var/lib/haproxy
   stats socket /run/haproxy/admin.sock mode 660 level admin
    stats timeout 30s
    user haproxy
    group haproxy

     log global
     mode http
     option httplog
     option dontlognull
     timeout connect 5000
     timeout client 50000
     timeout server 50000

frontend http_front
     bind *:80
     stats uri /haproxy?stats
     default_backend http_back

backend http_back
     balance roundrobin
     server my_server private_IP:80 check
     server my_server private_IP:80 check

Ensure to save the file before closing it.

Next, restart Haproxy using the command below:

sudo systemctl restart haproxy
sudo systemctl enable haproxy

You can view the official Haproxy Documentation for more information regarding the various types of Load Balancing and more information.