HTTP Load Balancing - rdirect only if first worker fails using mod_jk

854 views Asked by At

I have used Apache HTTPD mod_jk and Tomcat for a high availability solution. Here is the workers.properties for it.

worker.list=myworker

worker.myworker1.port=8009
worker.myworker1.host=host1
worker.myworker1.type=ajp13
worker.myworker1.lbfactor=1

worker.myworker2.port=8009
worker.myworker2.host=host2
worker.myworker2.type=ajp13
worker.myworker2.lbfactor=1

worker.myworker.type=lb
worker.myworker.balance_workers=myworker1,myworker2
worker.myworker.sticky_session=True

Right now, the requests are equally distributed among the workers and applications are working fine. What I want is, all the requests must go to myworker1. Only if myworker1 is down, it should be redirected to myworker2.

Is there a way possible with mod_jk for this?

1

There are 1 answers

1
pvpks On BEST ANSWER
  1. Redirect to myworker2 in case myworker1 fails
  2. Disable myworker2 for all the requests except for failover

These two lines must be added to your file

worker.myworker1.redirect=myworker2
worker.myworker2.activation=disabled

See: https://salonegupta.wordpress.com/2014/08/27/apache-load-balancer-setup-with-failover-mechanism/ for more information