Seamless failover with apache and mod_jk

apache-2.2

I have apache fronting two tomcat servers. Both servers are active in the load balancer. If I kill one of the backend tomcat processes, all users on that node receive a HTTP 500 on their next trip to the server. I'd like to avoid the 500 making it to the user – I'd like mod_jk to see the 500 and just send the request to the other server. Once the user does get the 500, if I refresh, the request is sent to the other server. Why does mod_jk return the 500 to the browser instead of trying another active node?

Our application is stateful, but we have done the work in our application to save state and key times. So if we could get the failover to be more seamless, we would get the user experience we are after.

Here is my workers.properties file

worker.list=router,jkstatus  
worker.router.type=lb  
worker.router.balance_workers=worker1,worker2  
worker.router.method=Next  

worker.worker1.type=ajp13  
worker.worker1.host=localhost  
worker.worker1.port=8009  

worker.worker2.type=ajp13  
worker.worker2.host=localhost  
worker.worker2.port=8010  

worker.jkstatus.type=status  

Best Answer

Since jk 1.2.20 you can set the property fail_on_status for workers.

See http://tomcat.apache.org/connectors-doc/reference/workers.html for details.