Links User Guide Reference Apache Tomcat Development | Clustering/Session Replication HOW-TOCluster Basics |
To run session replication in your Tomcat 7.0 container, the following steps
should be completed:
- All your session attributes must implement
java.io.Serializable
- Uncomment the
Cluster element in server.xml
- If you have defined custom cluster valves, make sure you have the
ReplicationValve defined as well under the Cluster element in server.xml
- If your Tomcat instances are running on the same machine, make sure the
tcpListenPort
attribute is unique for each instance, in most cases Tomcat is smart enough to resolve this on it's own by autodetecting available ports in the range 4000-4100
- Make sure your
web.xml has the
<distributable/> element
- If you are using mod_jk, make sure that jvmRoute attribute is set at your Engine
<Engine name="Catalina" jvmRoute="node01" >
and that the jvmRoute attribute value matches your worker name in workers.properties
- Make sure that all nodes have the same time and sync with NTP service!
- Make sure that your loadbalancer is configured for sticky session mode.
Load balancing can be achieved through many techniques, as seen in the
Load Balancing chapter.
Note: Remember that your session state is tracked by a cookie, so your URL must look the same from the out
side otherwise, a new session will be created.
Note: Clustering support currently requires the JDK version 1.5 or later.
The Cluster module uses the Tomcat JULI logging framework, so you can configure logging
through the regular logging.properties file. To track messages, you can enable logging on the key:org.apache.catalina.tribes.MESSAGES
|
Overview |
To enable session replication in Tomcat, three different paths can be followed to achieve the exact same thing:
- Using session persistence, and saving the session to a shared file system (PersistenceManager + FileStore)
- Using session persistence, and saving the session to a shared database (PersistenceManager + JDBCStore)
- Using in-memory-replication, using the SimpleTcpCluster that ships with Tomcat (lib/catalina-tribes.jar + lib/catalina-ha.jar)
In this release of session replication, Tomcat can perform an all-to-all replication of session state using the DeltaManager or
perform backup replication to only one node using the BackupManager .
The all-to-all replication is an algorithm that is only efficient when the clusters are small. For larger clusters, to use
a primary-secondary session replication where the session will only be stored at one backup server simply setup the BackupManager.
Currently you can use the domain worker attribute (mod_jk > 1.2.8) to build cluster partitions
with the potential of having a more scalable cluster solution with the DeltaManager(you'll need to configure the domain interceptor for this).
In order to keep the network traffic down in an all-to-all environment, you can split your cluster
into smaller groups. This can be easily achieved by using different multicast addresses for the different groups.
A very simple setup would look like this:
|
|