Apache Tomcat Connection and Failover-Cluster

Apache Tomcat Connection and Failover-Cluster


For high availability of web applications based on OpenCMS Platform at Pomegranate Portal we provide a Cluster of two Tomcat Servlet Engines, which are hosted on different machines. The Apache Web server, which resides on a separate machine, has the role to forward the client requests to the tomcat servers with load balancing features. Figure 1 illustrates a single environment without clustering and shows how Apache and Tomcat could be connected together via mod_jk module over the AJP (Apache Java Protocol)Connector. Mod_jk works by configuring Apache to load the mod_jk module. When Apache starts, it creates a series of connections with Tomcat over the JK connector, usually on port 8009. A short HowTo could be found on our forum.

Apache Tomcat Connection and Failover-Cluster

Figure 1: Connecting Apache to tomcat with mod_jk

This environment can be extended to a load balanced cluster environment. A cluster is a group of load balanced Tomcat instances, which have the same session data. The sessions will be replicated between Tomcat instances via the DeltaManager of each instance. Clustering works via multicast addressing, whereby all Tomcat instances broadcast their session information on the same port, but listen on different ports. The following Figure 2 shows the cluster architecture with 2 load balanced Tomcat instances.

Apache Tomcat Connection and Failover-Cluster

Figure 2: Appache - Tomcat Cluster Architecture.


If one instance fails or is stopped, due to maintenance or Soft- or Hardware failure, the other instance will pick up the session and have all data available and Apache will be noticed that one Tomcat instance is out of state and redirects the client requests to the next member in the cluster.


For setting up such an environment we have several options:

  • One Apache Web server on its own machine and two tomcat servers on different machines (stable and high performance, high cost)

  • One Apache Web server on its own machine and two tomcat instances on the same machine.

  • One Apache Web server and one tomcat server on one machine and the 2. Tomcat server on a separate machine.