Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache HTTPD mod_proxy_balancer with Active / Passive Setup

I recently decided to use Apache HTTPD (on CentOS - RPM version httpd-2.2.3-45.el5.centos) with mod_proxy and mod_proxy_balancer to create a software load balancer that fronts my JBoss Application Servers. Current set-up (see below configuration) seems to work fine, and both servers are actively handling inbound requests.

However, I would like to setup an Active-Passive cluster where one server actively handles requests and upon failure, it will fail-over to the passive node, making it active. Is it possible with mod_proxy_balancer ?

My current httpd.conf segment related to this is as follows.

<Proxy balancer://mycluster>
       Order deny,allow
       Allow from all

       BalancerMember http://192.168.2.1:8080 route=node1
       BalancerMember http://192.168.2.2:8080 route=node2
</Proxy>


ProxyPass / balancer://mycluster/ lbmethod=byrequests stickysession=JSESSIONID|jsessionid

ProxyPreserveHost On
ProxyPassReverse /  http://192.168.2.1:8080/
ProxyPassReverse /  http://192.168.2.2:8080/

Thanks in advance.

like image 501
Yohan Liyanage Avatar asked Jan 20 '23 11:01

Yohan Liyanage


1 Answers

Use one of the BalancerMember as Hot Standby

<Proxy balancer://mycluster>
    BalancerMember http://192.168.2.1:8080 retry=30 
    # the hot standby
    BalancerMember http://192.168.2.2:8080 status=+H retry=0
</Proxy>

Now node1 serves all requests and node2 waits till node1 fails and takes over. Once node1 is up, all requests will be served by node1 again. Apache checks every 30 secs (retry=30) if node1 is up or still down and switches back to node1.

like image 158
Praveen Avatar answered Jan 30 '23 20:01

Praveen