Configure Apache and Tomcat severs together

The most common way to deploy your application in the production environment is to hide the Tomcat behind Apache. This has good and bad parts but it gives you a lot of flexibility and support from Apache. There are a couple of alternatives to put these two severs together:

Read more

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.

<web-app>
<distributable />
</web-app>

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.