Tomcat6 clustering, loadbalancing ,session sharing ,failover

clusterload balancingtomcat

I am trying to implement a failover enabled loadbalanced cluster using tomcat.(6.0.14/Apache 2.2)

I have 2 tomcats runs in same machine. Both are load balanced using mod_jk/workers.properties and load balancing works fine. Sticky session is enabled and force sticky session is set to false.This also works.

I have added SimpleTCPCluster as mentioned in tomcat 6 documentation to both tomcats server.xml with different listen port. And it also works.(When one tomcat goes down, other tomcat log prints the member disconnected )

Now my problem is when 1 tomcat stops, next request from client goes to the other tomcat, but the session becomes new. So logged in user gets logged out and goes to home page. How can I replicate the session with both tomcats.

I read there are 3 ways . 1 in memory, 2 persistent manager with file and 3rd jdbc. It will be good if I get a solution using in memory or using File

Thanks in advance
Umesh

Best Answer