1

I have setup apache-tomcat clustering(Ubuntu Servers) and I used tomcat supported clustering technique with mod_jk following the link which is clear and easy to follow.

I did this in my LAN with three computers 1 as LB and other two as tomcat web servers and I thought of implementing this for production once I'm completely satisfied with the setup.

I followed many links and the link I pasted is the one of them and I configured it on different physical machine. The configuration is successful and I felt it's very easy to set it up. I checked stopping one tomcat webserver and it immediate started sending request to the other webserver. As far as I know I am clear that this configuration supports both HA & LB.

Below are my apache tomcat clustering details:


1 Load Balancer(192.168.1.100)
2 web Servers(192.168.1.101, 192.168.1.102)

On all the three servers, I installed apache2 & tomcat6 and configured tomcat to run on port 80 with mod_jk on all the servers.

Load Balancer:

Configured apache2 and tomcat with mod_jk setup(both are running on port 80)
As per the link I setup workers.properties with same default ports(as I'm using different machines)


Web Servers:

Let Actual site: www.mydomain.com which is pointing to LB
Configured apache2 and tomcat with mod_jk setup(both are running on port 80)

I can access web application by pointing the browser to following:
http://192.168.1.101/myapp
http://192.168.1.102/myapp

In either of the web servers I configured tomcat virtual hosting with actual site name(www.mydomain.com) as Host Name

I have an issue with tomcat jsp application. On any web server, if myapp directory is removed from webapps, the load balancer still redirects to that web server and the user have to face 404 error page which neither apache nor tomcat identifies and redirects to other available web servers.

Anybody has any technique so that client requests are redirected to other web servers in cluster when the requested application(myapps) in webapps is not available on a web server?

Thank you!

Update:1

Trying the below worker directive in the workers.properties of load balancer. Now the 404 error page is not displayed when myapp in webapps is removed but showing 503 error(this generally shown when tomcat is stopped). But still could not redirect to other available server when myapps is removed.

worker.<worker-name-here>.fail_on_status=-404,-500,503

1 Answer 1

1

I strongly suggest using a tool designed for load balancing purpose such as haproxy. You may define backend checks and thus avoid sending requests to unavailable apps with a great deal of flexibility.

Your solution is also not HA, as the load balancer is a SPOF (single point of failure). You may want to add another machine and use keepalived for failover.

HAproxy can run in any port that you want, you can even balance different kinds of traffic, not only http, and at the same time configuring frontends (service balancing entry points) and backends (container for service instances and balancing behavior). You can see an example here: http://www.tomcatexpert.com/blog/2010/07/12/trick-my-proxy-front-tomcat-haproxy-instead-apache

For the failover part, I would use keepalived. It checks that your active load balancer is available and failover to secondary machine if its not, floating your virtual ip addres.

You may check this link for an example: http://www.howtoforge.com/setting-up-a-high-availability-load-balancer-with-haproxy-keepalived-on-debian-lenny

2
  • Yes, as you said, I should use one more LB with HAProxy failover. Does HAproxy run on port 80? or it doesn't require any port?
    – user53864
    Aug 12, 2011 at 2:33
  • Please answer few questions and I'll accept your answer!
    – user53864
    Aug 13, 2011 at 1:26

You must log in to answer this question.

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