3 Replies Latest reply on Mar 17, 2005 7:50 AM by trackingroi.com

    Tomcat Session Replication in cluster

    trackingroi.com

      I'm trying to test the latest 4.x release of JBoss AS and want to setup a simple cluster of 2 machines and have Tomcat replication sessions. I've been able to have the 2 machines automatically discover eachother and I've deployed a very simple test webapp to the cluster using the farm director. The webapp deploys to both machines and contains a single JSP page which outputs the servers IP address and true or false to say if it's a new jsp session or not.

      When I go to box 1's webapp at http://10.10.0.1:8080/clustertest, it shows the right ip and says it's a new session. if I refresh my browser it shows that it is not a new session - perfect. Now if I change the url to be http://10.10.0.2:8080/clustertest it shows the correct IP address but also shows it is a new session. I was hoping that it would bind me to the same session that was created on 10.10.0.1 but it does not.

      Is this a valid test case? I thought the session would replicate as soon as it was created on one of the boxes, but I'm wondering if I have to store an object in the session to trigger the replication?

      To eliminate any configuration errors, I'm using the out of the box configuration "all" from the latest release of JBoss.

      Thank you for any help you can provide.

        • 1. Re: Tomcat Session Replication in cluster
          trackingroi.com

          Here is some additional informaiton:

          jboss-web.xml

          <jboss-web>
           <replication-config>
           <replication-trigger>SET_AND_GET</replication-trigger>
           <replication-type>SYNC</replication-type>
           </replication-config>
          </jboss-web>


          web.xml

          <web-app>
           <display-name>cluster</display-name>
           <distributable/>
          </web-app>


          In server.log, I am seeing info relating to the session replication on the first machine, but no corresponding entries on the 2nd machine saying it received updates to the session or received the session at all (if it should??). Here is what machine 1 has in its log:

          2005-03-16 10:48:56,429 DEBUG [org.jboss.web.tomcat.tc5.session.JBossCacheManager] Session with id=44c+Sh1CNJge0RYt+M5mGw** added. Current active sessions 1
          2005-03-16 10:48:56,429 DEBUG [org.jboss.web.tomcat.tc5.session.JBossCacheManager] Creating an ClusteredSession with id: 44c+Sh1CNJge0RYt+M5mGw**
          2005-03-16 10:48:56,439 INFO [STDOUT] Test jsp: 1 : : 44c+Sh1CNJge0RYt+M5mGw**
          2005-03-16 10:48:56,469 DEBUG [org.jboss.web.tomcat.tc5.session.JBossCacheManager] check to see if needs to store and replicate session with id 44c+Sh1CNJge0RYt+M5mGw**
          2005-03-16 10:48:56,469 DEBUG [org.jboss.web.tomcat.tc5.session.ClusteredSession] processSessionRepl(): session is dirty. Will increment version from: 1 and replicate.
          2005-03-16 10:48:59,573 INFO [STDOUT] Test jsp: 2 : : 44c+Sh1CNJge0RYt+M5mGw**
          2005-03-16 10:48:59,573 DEBUG [org.jboss.web.tomcat.tc5.session.JBossCacheManager] check to see if needs to store and replicate session with id 44c+Sh1CNJge0RYt+M5mGw**
          2005-03-16 10:48:59,573 DEBUG [org.jboss.web.tomcat.tc5.session.ClusteredSession] processSessionRepl(): session is dirty. Will increment version from: 2 and replicate.
          2005-03-16 10:49:01,406 INFO [STDOUT] Test jsp: 3 : : 44c+Sh1CNJge0RYt+M5mGw**
          2005-03-16 10:49:01,406 DEBUG [org.jboss.web.tomcat.tc5.session.JBossCacheManager] check to see if needs to store and replicate session with id 44c+Sh1CNJge0RYt+M5mGw**
          2005-03-16 10:49:01,406 DEBUG [org.jboss.web.tomcat.tc5.session.ClusteredSession] processSessionRepl(): session is dirty. Will increment version from: 3 and replicate.
          


          • 2. Re: Tomcat Session Replication in cluster

            You need a sw load balancer in front the tomcat server to do failover so they can keep the session id. Check out jboss wiki web site for http session clustering for the example setup.

            -Ben

            • 3. Re: Tomcat Session Replication in cluster
              trackingroi.com

              Thanks Ben! It hit me last night as I was trying to sleep... I think what was happening was that my session id cookie was not being passed to the 2nd node because I was manually changing the IP and the cookie was only stored in my browser for the first IP if I remember how cookies work... In other words, I had a jsp session id cookie stored in IE for host A that got sent to host a each time I made a request. Now when I change the IP manually, there is no cookie stored for host B in IE so it sends none. JBoss can't tell it's the same client b/c there is no cookie so it creates a new session. Is this right??

              This morning I setup a software load balancer and it's working perfectly! The sessions replicate perfectly and at lightning speed!!! I am loving life again ;-)