Wednesday, November 20, 2013

Apache Load balancing with HAProxy

Overview

HAProxy is an open source load balancing software run on Linux. It will divide the load which may be web page or database query requests upon slave servers from the master. Therefore usual Linux machine can be configured as a load balance without any hardware load balancing capabilities.

Implementation

First we test HAProxy with two Apache servers. Following figure shows the architecture of HAProxy load balancing Apache servers. Table  shows the IP set up.

             
Figure HAproxy load balance Architecture

Table: IP set up

IP                      Name       Usage
10.17.73.126    Node1      High available load balance
10.17.73.131    Node3      Web server
10.17.73.220    Node4      Web server

Summary of installation process

1) You can install HAProxy via Synaptic Package Manager a graphical package installation tool or through terminal.
sudo apt-get install haproxy

2) Edit HAProxy configuration file in /etc/Haproxy/haproxy.cfg.
            i. Web servers IPs should be interchange with your apache servers.
            ii. Your username and password should be specified in stats section.
            iii. The port and incoming IP address can be changed.

Sample Haproxy configuration file is shown below.

listen  webfarm *:80
balance roundrobin
option forwardfor
option httpclose
option httpchk HEAD / HTTP/1.0
server WebA 10.17.73.131:80 cookie A check inter 2000 rise 2 fall
server WebB 10.17.73.220:80 cookie B check inter 2000 rise 2 fall

3) Do the other configurations as well .
4) Install apache server on other nodes.
5) Start apache servers.
6) If you get the index file then HAProxy works fine. Monitor the performance through http:// 10.17.73.126/haproxy?stats using specified username and password. Figure show the different status displayed on the HAProxy stat page on various server cases.


Figure HAProxy stats page
Figure  shows the stat page of HAProxy load balancer. It is like administration page for monitoring load balacing cluster. When one server goes down or already crashes it displays different color combination icon to inform the status of the cluster.

Conclusion

HAProxy is a good load balancing software for handling both TCP and HTTP requests. But when applying to the database related resources data concurrency and replication have be considered.






No comments :

Post a Comment