Tomcat Clustering & Java Servlet Specification

After I read more about Tomcat Clustering I realized that the main purpose of Tomcat clustering is to offer fault tolerance, failover  and high availability support. I read a lot about load balancing but when it comes to Java Servlets I found out that the only choice you have in terms of balancing is to use sticky sessions. This is more a limitation that comes from Java Servlet Specification and not from Tomcat, but it make sense.

For an application to be “distributed” you have to mark  it as “distributable” by add the <distributable/> tag in web.xml.

<distributable />

There are multiple ways to balance the client request to your server pool but when it comes to Java Servlet Specification you have only one choice, as the specs say:

Within an application that is marked as distributable, all requests that are part of a session can only be handled on a single JVM at any one time.

You may have multiple JVMs, each handling requests from different clients concurrently for any given distributable web application

So, I guess you can kiss goodbye the round robin and all other load balancing options, but at least Tomcat will provide you  failover, scalability  and high availability.


2 Responses to “Tomcat Clustering & Java Servlet Specification”

  1. Cris Radu on August 9th, 2009 12:11 pm

    Round robin and other load balancing techniques can still be applied but at session level, not request level. Most load balancers come with a nice feature known as session awareness or sticky session.
    All is not lost 🙂

  2. subhash on June 9th, 2010 8:59 pm

    hi ,

    i didn’t understood one point the tag wich you have given in the article is only for on tomcat server then your application layer is dependent n one server that gives us a tight boundedness. please suggest me the best book for cluster managing using servlets, jsp, jdbc .bye have a good day . thanx a lot in advance