Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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  
share|improve this question

migrated from webmasters.stackexchange.com Dec 20 '12 at 19:22

This question came from our site for pro webmasters.

    
Is there any specific reason that you are running apache as the front-end to the tomcat servers ? Please be as informative as you can. –  GeekRide Dec 21 '12 at 16:26
    
Also, can you please paste your workers.properties file here. –  GeekRide Dec 21 '12 at 17:13
    
There is no particular reason for apache. I'd be willing to try anything. I am not running this in production, this is just a development effort that is at the beginning of flushing out how we are going to make our system highly available. Our customers will likely use many other types of load balancers and app servers. –  user1145530 Dec 24 '12 at 18:30

2 Answers 2

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.

share|improve this answer

Well, as you said that you are not bound to apache, then I would suggest you to use something like Varnish, which is a Load balancer as well as reverse proxy, as well as a very good caching server.

Using the same will not even increase your site performance but will also give you the solution of your current problem.

In varnish, you can configure 2 backends using tomcat. All the requests will come to Varnish which it will load balance between the 2 back-end tomcat servers.

If by any chance one tomcat server will be down, then it will not send any more queries to that tomcat server and will send all the traffic to the healthy back-end. In the background, it will keep checking the health of the bad tomcat server, and once it's back to healthy state, it will start sending back to that tomcat server.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.