0
votes

I have created a load balancing scenario in my machine and the same works fine. However, I am stuck at one simple issue and request help on the same.

I have two tomcat workers - worker1 and worker2. I also have a loadbalancer called balancer. workers.properties file has been created as follows -

  • workers.tomcat_home="MyTomcatDirectory"
  • workers.java_home="MyJDKDirectory"
  • worker.list=tomcat1,tomcat2
  • worker.list=balancer
  • worker.tomcat1.type=ajp13
  • worker.tomcat1.host=localhost
  • worker.tomcat1.port=8009
  • worker.tomcat1.lbfactor=1
  • worker.tomcat2.type=ajp13
  • worker.tomcat2.host=localhost
  • worker.tomcat2.port=8019
  • worker.tomcat2.lbfactor=1
  • worker.balancer.type=lb
  • worker.balancer.balance_workers=tomcat1,tomcat2
  • worker.balancer.method=B`

Now, I have a webapp say webapp1 which is used by endusers extensively. I hence want that all the user requests for webapp1 should be handled by worker1. For this I have added the below lines in httpd.conf file in my apache's conf dir -

  • JkMount / balancer
  • JkMount /* balancer
  • JkMount /webapp1 worker1
  • JkMount /webapp1/* worker1

This works fine as well. The only problem here is that if tomcat1 (worker1) is down, the balancer doesn't direct the request for webapp1 to tomcat2 (worker2). How do I resolve this issue?

1
Should you set the load balancing type as round robin or something? - constantlearner
I have defined the worker called balancer of type lb. Balancer should take care of the roundrobin thing by itself. And it does so as well. The only problem is I have used JkMount to direct URLs referring to webapp1 to worker1. But when worker1 is down, the request is not redirected to worker2 and hence the EndUser receives an error stating "Service Unavailable - The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later". Please help - Sreekul Nair
You'd be far better off asking this at serverfault.com. - user207421

1 Answers

1
votes

If you want requests to go to worker 1 by default and then to worker 2 if and only if worker 1 fails you'll need to set up a second lb worker (call it lb2) with two workers (tomcat1b and tomcat2b) and use the distance parameter to give tomcat2b a larger distance than tomact1b. That will cause tomcat1b to be used in preference to tomcat2b unless tomcat1b fails.

See the workers.properties docs for more info: http://tomcat.apache.org/connectors-doc/reference/workers.html

BTW you have tomcat1 in your workers.properties but worker1 in your JKMount. That won't work.