0

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  
4
  • 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.
    – Napster_X
    Dec 21, 2012 at 16:26
  • Also, can you please paste your workers.properties file here.
    – Napster_X
    Dec 21, 2012 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. Dec 24, 2012 at 18:30
  • @Napster_X this is widely done in the industry, to hide tomcat servers and to do some load balacing.
    – Mehdi
    Feb 6, 2020 at 19:37

3 Answers 3

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.

0

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.

0

Setup redirection for each worker :

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

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

worker.worker2.redirect=worker1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .