ASF Tomcat Members, I'm trying to configure & demo an Apache Tomcat [v8] cluster env, that supports different apps functioning on different systems. Basically, I'm trying to setup an environment where an app can be on only 1 or 2 (deployed or running) out of the 3 Tomcat systems in the cluster. However, this does not seem to work for me, as I can't get away from the 404s when Apache HTTPD goes to a random (round robin) Tomcat system, that does not have the application (running or deployed) on it. This happens with both new & cached sessions. I can bring an entire Tomcat system down, and it works as designed, but not for (stopped or undeployed) single applications. I'm really not sure how Tomcat and Apache are supposed to communicate with each other in this regard; so they know what apps are deployed/running on each system. Is this even possible? According to the link below, it should work...
http://tomcat.apache.org/tomcat-8.0-doc/config/cluster-manager.html The org.apache.catalina.ha.session.BackupManager also replicates deltas but only to one backup node. The location of the backup node is known to all nodes in the cluster. It also supports heterogeneous deployments, so the manager knows at what locations the web application is deployed. -------------------- Env - Top Down -------------------- [Load Balancer] - (Sticky Sessions) | [HTTPD1] - [HTTPD2] - (Load Balanced, Sticky Sessions) | [Tomcat1] - [Tomcat2] - [Tomcat3] - (BackupManager) ------ Stats ------ [HTTPD] X 2 Server version: Apache/2.4.18 (Unix) Server built: Dec 21 2015 14:42:09 [Tomcat] X 3 Server version: Apache Tomcat/8.0.33 Server built: Mar 18 2016 20:31:49 Server number: 8.0.33.0 OS Name: Linux OS Version: 3.10.0-327.4.4.el7.x86_64 Architecture: amd64 JVM Version: 1.8.0_77-b03 JVM Vendor: Oracle Corporation [Linux] X 3 Tomcat Systems IPv6/IPv4 Group Memberships Interface RefCnt Group --------------- ------ --------------------- lo 1 all-systems.mcast.net eth0 1 228.0.0.4 eth0 1 all-systems.mcast.net eth1 1 all-systems.mcast.net -------- Config -------- [HTTPD] worker.list=tomcattest, statustest worker.tomcat1.type=ajp13 worker.tomcat1.host=tomcat1 worker.tomcat1.port=XXXX #worker.tomcat1.lbfactor=5 worker.tomcat2.type=ajp13 worker.tomcat2.host=tomcat2 worker.tomcat2.port=XXXX #worker.tomcat2.lbfactor=5 worker.tomcat3.type=ajp13 worker.tomcat3.host=tomcat3 worker.tomcat3.port=XXXX #worker.tomcat3.lbfactor=5 worker.tomcattest.type=lb worker.tomcattest.balance_workers=tomcat1,tomcat2,tomcat3 worker.tomcattest.sticky_session=True # lb methods: [R]equest, [S]ession, [T]raffic, [B]usiness worker.tomcattest.method=R worker.statustest.type=status [tomcat] X3 - server.xml <!-- Defining the AJP 1.3 Connector on Port XXXX --> <Connector port="XXXX" protocol="AJP/1.3" redirectPort="XXXX" /> <!-- Defining the Local Host & Route to the local machine --> <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1/2/3"> <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="6"> <Manager className="org.apache.catalina.ha.session.BackupManager" expireSessionsOnShutdown="false" notifyListenersOnReplication="true" mapSendOptions="6"/> <Channel className="org.apache.catalina.tribes.group.GroupChannel"> <Membership className="org.apache.catalina.tribes.membership.McastService" address="228.0.0.4" port="45564" frequency="500" dropTime="3000"/> <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver" address="auto" port="4000" autoBind="100" selectorTimeout="5000" maxThreads="6"/> <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter"> <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/> </Sender> <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/> <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/> <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/> </Channel> <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=""/> <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/> </Cluster> ----------------- Cluster Basics ----------------- All your session attributes must implement java.io.Serializable - Done Uncomment the Cluster element in server.xml - Done If you have defined custom cluster valves, make sure you have the ReplicationValve defined as well under the Cluster element in server.xml - N/A If your Tomcat instances are running on the same machine, make sure the Receiver.port 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 - N/A Make sure your web.xml has the <distributable/> element - Done 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 - Done Make sure that all nodes have the same time and sync with NTP service! - Done Make sure that your loadbalancer is configured for sticky session mode - Done Thanks for reading!