title: Is tomcat clustering only way for session replication?
body: <p>I tested <code>Tomcat Clustering</code> for <code>session replication</code> on ubuntu servers with apache as front end load balancers. From my testing experience I say it's better not using tomcat clustering but running each node as standalone not knowing one another without any session replication as   I felt it's slow, takes much time to startup tomcat service and consumes more memory. And the <code>FarmDeployer</code> is not reliable always in deploying and whole configuration should be placed under<code>&lt;Host&gt;&lt;/Host&gt;</code> element for farm deployer to work and also for each virtual hosting and thus a huge server.xml file. Below is the tomcat virtual hosting with cluster configuration from one of the node I used.</p>
  
  <pre><code>&lt;Host name="site1.mydomain.net" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true"&gt;
  &lt;Logger className="org.apache.catalina.logger.FileLogger"
  directory="logs" prefix="virtual_log1." suffix=".log" timestamp="true"/&gt;
  &lt;Context path="" docBase="/usr/share/tomcat/webapps/myapp" debug="0" reloadable="true"/&gt;
  
  &lt;Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"&gt;
  &lt;Manager className="org.apache.catalina.ha.session.DeltaManager" 
            expireSessionsOnShutdown="false"
            notifyListenersOnReplication="true"/&gt;
  
          &lt;Channel className="org.apache.catalina.tribes.group.GroupChannel"&gt;
              &lt;Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
                    address="192.168.1.8"
                    port="4001"
                    selectorTimeout="100"
                    maxThreads="6"/&gt;
              &lt;Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/&gt;
              &lt;Interceptor className="org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor"&gt;
                  &lt;Member className="org.apache.catalina.tribes.membership.StaticMember"
                        port="4002"
                        securePort="-1"
                        host="192.168.1.9"
                        domain="staging-cluster"
                        uniqueId="{0,1,2,3,4,5,6,7,8,9}"/&gt;
  
               &lt;!--   &lt;Member className="org.apache.catalina.tribes.membership.StaticMember"
                        port="4002"
                        securePort="-1"
                        host="192.168.1.9"
                        domain="staging-cluster"
                        uniqueId="{0,1,2,3,4,5,6,7,8,9}"/&gt; --&gt;
  
              &lt;/Interceptor&gt;
          &lt;/Channel&gt;
  &lt;Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=""/&gt;
  &lt;Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/&gt;
  
  &lt;ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/&gt;
  &lt;ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/&gt;
  
    &lt;Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
              tempDir="/usr/share/tomcat/temp/"
              deployDir="/usr/share/tomcat/webapps/"
              watchDir="/usr/share/tomcat/watch/"
              watchEnabled="true"/&gt;
      &lt;/Cluster&gt;
  &lt;/Host&gt;
  </code></pre>
  
  <p>Is Tomcat clustering good to use on production or is there any alternate way for session replication?. Or I'm missing anything in the above configuration which could be fine tuned?</p>
  
  <p>Any ideas are welcome. Thanks!</p>