Load Balancing using apache web server(HTTPD).

Apache is most widely used web server in hosting websites.now lets see how to load balance you website using apache.a simple load balancer

1.For load balancing first enable below modules in apache config file httpd.conf

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so

2.Now disable ProxyRequests in apache config file httpd.conf

ProxyRequests off

3.Now create a load balnacer


<Proxy "balancer://mycluster">
    //add number of nodes here
    BalancerMember "http://192.168.1.110:80" route=1
    BalancerMember "http://192.168.1.111:80" route=2
    BalancerMember "http://192.168.1.112:80" route=3

    ProxySet lbmethod=byrequests //Load balancer scheduler algorithm 
    ProxySet nofailover=On //If set to On, the session will break if the worker is in error state or disabled. Set this value to On if backend servers do not support session replication
    ProxySet stickysession=ROUTEID
    ProxySet connectiontimeout=5 timeout=30

</Proxy>

ProxyPass "/test" "balancer://mycluster"
ProxyPassReverse "/test" "balancer://mycluster"

4.Enabling Balancer Manager add below lines to httpd.conf file.


ProxyPass /balancer-manager ! // do not proxy balancer-manager

 <Location /balancer-manager>
          SetHandler balancer-manager
          Order deny,allow
          Allow from all
</Location>


Advertisements
This entry was posted in Linux. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s