Tomcat 6 in-memory session replication

22 / Jul / 2010 by Abhishek Tejpaul

Hi All,

Here are the few basic steps that you need to follow in order to achieve the in-memory session replication between two or more Tomcat 6 instances.

This blog refers the Apache Tomcat documentation as found here: http://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html.
The Tomcat documentation provides more detailed explanation of the Clustering concepts as well as the definition of tags, attributes etc. used in server.xml file.

Step 1: Include the <distributable> tag in web.xml file i.e. you can simple write the following line in your deployment descriptor(i.e. web.xml):

  

Please read the following link to know more about this tag: http://wiki.metawerx.net/wiki/Web.xml.Distributable

Step 2: Add the following lines of XML in the server.xml file inside the <Engine> element/tag:


      
                     
                      
                                
                              
                                
                                              
                                
                      
                      
                  
            
           
           
                   
                  
     
 .
 .
 .
 .
 
 

Please note that there might be some other elements such as <Host>, <Realm> etc. inside the <Engine> element. Also, for each tomcat instance the value defined for the ‘port’ attribute of the <Receiver> tag must be unique.

And, that’s all. You now have a basic session-replication in place. Your sessions are replicated amongst all the tomcat instances which are part of your cluster.

NOTE: Please make sure if you make any changes to the “context.xml” file, you have to delete the following xml file located in the <TOMCAT_HOME>/conf/Catalina/localhost/{yourAppName}.xml. If you don’t delete this file, then your changes will be ignored and the settings defined in this file will take effect.

Cheers!!!

Abhishek Tejpaul
abhishek@intelligrape.com
[Intelligrape Software Pvt. Ltd.]

FOUND THIS USEFUL? SHARE IT