Apache Tomcat - Embedded Servlet Container Clustering

Enable in-memory session replication to replicate web application session deltas.

Clustering Type Description
DEFAULT Discovers cluster members via multicast discovery and optionally via statically defined cluster members using the clusterMembers. SimpleTcpCluster with McastService
CLOUD For use in Kubernetes where members are discovered via accessing the Kubernetes API or doing a DNS lookup of the members of a Kubernetes service. Documentation is currently light, see code for details.
Membership Providers Description
kubernetes Uses Kubernetes API to find other pods in a deployment. API is discovered and accessed via information in environment variables set in the container. The KUBERNETES_NAMESPACE environment variable is used to query the pods in the namespace and it will treat other pods in that namespace as potential cluster members but they can be filtered using the KUBERNETES_LABELS environment variable which are used as a label selector.
dns Uses DNS lookups to find addresses of the cluster members behind a DNS name specified by DNS_MEMBERSHIP_SERVICE_NAME environment variable. Works in Kubernetes but doesn’t rely on Kubernetes.
MembershipProvider class Use a membership provider implementation of your choice.

Most settings apply to the DEFAULT clustering type, which requires members to be defined via clusterMembers if multicast discovery doesn’t work. The cloudMembershipProvider setting applies to the CLOUD type.

The following settings and properties are available from the CAS configuration catalog:

cas.server.tomcat.clustering.enabledEnable tomcat session clustering.
false
Required

Enable tomcat session clustering.

Type
Boolean
Default
false
Defined by
CasEmbeddedApacheTomcatClusteringProperties
cas.server.tomcat.clustering.channel-send-optionsThis option is used to set the flag that all messages sent through the SimpleTcpCluster uses.
8
This option is used to set the flag that all messages sent through the SimpleTcpCluster uses. The flag decides how the messages are sent, and is a simple logical OR.
  • 2: SEND_OPTIONS_SYNCHRONIZED_ACK
  • 4: SEND_OPTIONS_USE_ACK
  • 8: SEND_OPTIONS_ASYNCHRONOUS
Type
Integer
Default
8
Defined by
CasEmbeddedApacheTomcatClusteringProperties
cas.server.tomcat.clustering.cloud-membership-providerCloud membership provider, values are case sensitive and only used with clusteringType CLOUD .
dns
Cloud membership provider, values are case sensitive and only used with clusteringType CLOUD. The different providers rely on environment variables to discover other members of cluster via DNS lookups of the service name or querying kubernetes API. See code or Tomcat documentation for the environment variables that are used.
  • kubernetes will use org.apache.catalina.tribes.KubernetesMembershipProvider
  • dns will use org.apache.catalina.tribes.DNSMembershipProvider
  • Class implementing org.apache.catalina.tribes.MembershipProvider
Type
String
Default
dns
Defined by
CasEmbeddedApacheTomcatClusteringProperties
cas.server.tomcat.clustering.cluster-membersStatically register members in the cluster.
no default

Statically register members in the cluster. The syntax is: address:port:index

Type
String
Default
none
Defined by
CasEmbeddedApacheTomcatClusteringProperties
cas.server.tomcat.clustering.clustering-typeAccepted values are: DEFAULT, CLOUD .
DEFAULT

Accepted values are: DEFAULT, CLOUD. Type of clustering to use, set to CLOUD if using CloudMembershipService.

Type
String
Default
DEFAULT
Defined by
CasEmbeddedApacheTomcatClusteringProperties
cas.server.tomcat.clustering.expire-sessions-on-shutdownWhen a web application is being shutdown, Tomcat issues an expire call to each session to notify all the listeners.
false

When a web application is being shutdown, Tomcat issues an expire call to each session to notify all the listeners. If you wish for all sessions to expire on all nodes when a shutdown occurs on one node, set this value to true. Default value is false.

Type
Boolean
Default
false
Defined by
CasEmbeddedApacheTomcatClusteringProperties
cas.server.tomcat.clustering.failure-fatalIndicates whether a failure should be treated as fatal during cluster startup operations.
true

Indicates whether a failure should be treated as fatal during cluster startup operations.

Type
Boolean
Default
true
Defined by
CasEmbeddedApacheTomcatClusteringProperties
cas.server.tomcat.clustering.manager-typeAccepted values are: DELTA, BACKUP .
DELTA

Accepted values are: DELTA, BACKUP. Enable all-to-all session replication using the DeltaManager to replicate session deltas. By all-to-all we mean that the session gets replicated to all the other nodes in the cluster. This works great for smaller cluster but we don't recommend it for larger clusters(a lot of Tomcat nodes). Also when using the delta manager it will replicate to all nodes, even nodes that don't have the application deployed. To get around this problem, you'll want to use the BackupManager. This manager only replicates the session data to one backup node, and only to nodes that have the application deployed. Downside of the BackupManager: not quite as battle tested as the delta manager.

Type
String
Default
DELTA
Defined by
CasEmbeddedApacheTomcatClusteringProperties
cas.server.tomcat.clustering.membership-addressMulticast address for membership.
228.0.0.4

Multicast address for membership. The multicast address that the membership will broadcast its presence and listen for other heartbeats on. Make sure your network is enabled for multicast traffic. The multicast address, in conjunction with the port is what creates a cluster group. To divide up your farm into several different group, or to split up QA from production, change the port or the address

Type
String
Default
228.0.0.4
Defined by
CasEmbeddedApacheTomcatClusteringProperties
cas.server.tomcat.clustering.membership-bind-addressThis tells the underlying multicast socket exactly which local network interface (IP address) to bind to when it: Joins the multicast group Sends and receives the UDP datagrams for group membership By specifying this...
no default
This tells the underlying multicast socket exactly which local network interface (IP address) to bind to when it:
  • Joins the multicast group
  • Sends and receives the UDP datagrams for group membership
By specifying this address, you force Java to use exactly that interface for all joins and sends. This would also be useful if your environment has more than one network interface and the OS might by default bind the multicast socket to the “wrong” one (or none), leading to No route to host or “not a member” errors.
Type
String
Default
none
Defined by
CasEmbeddedApacheTomcatClusteringProperties
cas.server.tomcat.clustering.membership-drop-timeThe membership component will time out members and notify the Channel if a member fails to send a heartbeat within a give time.
3000

The membership component will time out members and notify the Channel if a member fails to send a heartbeat within a give time. The default value is 3000 ms. This means, that if a heartbeat is not received from a member in that timeframe, the membership component will notify the cluster of this. On a high latency network you may wish to increase this value, to protect against false positives. Apache Tribes also provides a TcpFailureDetector that will verify a timeout using a TCP connection when a heartbeat timeout has occurred. This protects against false positives.

Type
Integer
Default
3000
Defined by
CasEmbeddedApacheTomcatClusteringProperties
cas.server.tomcat.clustering.membership-frequencyThe frequency in milliseconds in which heartbeats are sent out.
500

The frequency in milliseconds in which heartbeats are sent out. The default value is 500 ms. In most cases the default value is sufficient. Changing this value, changes the interval in between heartbeats.

Type
Integer
Default
500
Defined by
CasEmbeddedApacheTomcatClusteringProperties
cas.server.tomcat.clustering.membership-local-loopback-disabledMembership uses multicast, it will call java.net.MulticastSocket.setLoopbackMode(localLoopbackDisabled).
false

Membership uses multicast, it will call java.net.MulticastSocket.setLoopbackMode(localLoopbackDisabled). When localLoopbackDisabled==true multicast messages will not reach other nodes on the same local machine. The default is false.

Type
Boolean
Default
false
Defined by
CasEmbeddedApacheTomcatClusteringProperties
cas.server.tomcat.clustering.membership-portMulticast port (the port and the address together determine cluster membership.
45564

Multicast port (the port and the address together determine cluster membership. The multicast port, the default value is 45564 The multicast port, in conjunction with the address is what creates a cluster group. To divide up your farm into several different group, or to split up QA from production, change the port or the address

Type
Integer
Default
45564
Defined by
CasEmbeddedApacheTomcatClusteringProperties
cas.server.tomcat.clustering.membership-recovery-counterMembership uses multicast, it will call java.net.MulticastSocket.setLoopbackMode(localLoopbackDisabled).
10

Membership uses multicast, it will call java.net.MulticastSocket.setLoopbackMode(localLoopbackDisabled). When localLoopbackDisabled==true multicast messages will not reach other nodes on the same local machine. The default is false.

Type
Integer
Default
10
Defined by
CasEmbeddedApacheTomcatClusteringProperties
cas.server.tomcat.clustering.membership-recovery-enabledIn case of a network failure, Java multicast socket don't transparently fail over, instead the socket will continuously throw IOException upon each receive request.
true

In case of a network failure, Java multicast socket don't transparently fail over, instead the socket will continuously throw IOException upon each receive request. When recovery-enabled is set to true, this will close the multicast socket and open a new socket with the same properties as defined above. The default is true.

Type
Boolean
Default
true
Defined by
CasEmbeddedApacheTomcatClusteringProperties
cas.server.tomcat.clustering.receiver-addressThe address (network interface) to listen for incoming traffic.
auto

The address (network interface) to listen for incoming traffic.

Type
String
Default
auto
Defined by
CasEmbeddedApacheTomcatClusteringProperties
cas.server.tomcat.clustering.receiver-auto-bindDefault value is 100.
100

Default value is 100. Use this value if you wish to automatically avoid port conflicts the cluster receiver will try to open a server socket on the port attribute port, and then work up autoBind number of times.

Type
Integer
Default
100
Defined by
CasEmbeddedApacheTomcatClusteringProperties
cas.server.tomcat.clustering.receiver-max-threadsMaximum threads configured for the listener.
6

Maximum threads configured for the listener. The maximum number of threads in the receiver thread pool. The default value is 6 Adjust this value relative to the number of nodes in the cluster, the number of messages being exchanged and the hardware you are running on. A higher value doesn't mean more efficiency, tune this value according to your own test results.

Type
Integer
Default
6
Defined by
CasEmbeddedApacheTomcatClusteringProperties
cas.server.tomcat.clustering.receiver-portThe listen port for incoming data.
4000

The listen port for incoming data. The default value is 4000. To avoid port conflicts the receiver will automatically bind to a free port. So for example, if port is 4000, and autoBind is set to 10, then the receiver will open up a server socket on the first available port in the range 4000-4009.

Type
Integer
Default
4000
Defined by
CasEmbeddedApacheTomcatClusteringProperties
cas.server.tomcat.clustering.receiver-timeoutListener timeout.
5000

Listener timeout. The value in milliseconds for the polling timeout in the NioReceiver. On older versions of the JDK there have been bugs, that should all now be cleared out where the selector never woke up. The default value is a very high 5000 milliseconds.

Type
Integer
Default
5000
Defined by
CasEmbeddedApacheTomcatClusteringProperties

Required settings may be needed to activate or affect the feature; review them even when they have a default. Optional settings only need to be set to change a default or to turn on the behavior they control. Third party settings belong to libraries such as Spring Boot that CAS builds on; their own documentation may have more detail.

Notes on configuration

Configuration Metadata

The collection of configuration properties listed in this section are automatically generated from the CAS source and components that contain the actual field definitions, types, descriptions, modules, etc. This metadata may not always be 100% accurate, or could be lacking details and sufficient explanations.

Be Selective

This section is meant as a guide only. Do NOT copy/paste the entire collection of settings into your CAS configuration; rather pick only the properties that you need. Do NOT enable settings unless you are certain of their purpose and do NOT copy settings into your configuration only to keep them as reference. All these ideas lead to upgrade headaches, maintenance nightmares and premature aging.

YAGNI

Note that for nearly ALL use cases, declaring and configuring properties listed here is sufficient. You should NOT have to explicitly massage a CAS XML/Java/etc configuration file to design an authentication handler, create attribute release policies, etc. CAS at runtime will auto-configure all required changes for you. If you are unsure about the meaning of a given CAS setting, do NOT turn it on without hesitation. Review the codebase or better yet, ask questions to clarify the intended behavior.

Naming Convention

Property names can be specified in very relaxed terms. For instance cas.someProperty, cas.some-property, cas.some_property are all valid names. While all forms are accepted by CAS, there are certain components (in CAS and other frameworks used) whose activation at runtime is conditional on a property value, where this property is required to have been specified in CAS configuration using kebab case. This is both true for properties that are owned by CAS as well as those that might be presented to the system via an external library or framework such as Spring Boot, etc.

:information_source: Note

When possible, properties should be stored in lower-case kebab format, such as cas.property-name=value. The only possible exception to this rule is when naming actuator endpoints; The name of the actuator endpoints (i.e. ssoSessions) MUST remain in camelCase mode.

Settings and properties that are controlled by the CAS platform directly always begin with the prefix cas. All other settings are controlled and provided to CAS via other underlying frameworks and may have their own schemas and syntax. BE CAREFUL with the distinction. Unrecognized properties are rejected by CAS and/or frameworks upon which CAS depends. This means if you somehow misspell a property definition or fail to adhere to the dot-notation syntax and such, your setting is entirely refused by CAS and likely the feature it controls will never be activated in the way you intend.

Validation

Configuration properties are automatically validated on CAS startup to report issues with configuration binding, especially if defined CAS settings cannot be recognized or validated by the configuration schema. Additional validation processes are also handled via Configuration Metadata and property migrations applied automatically on startup by Spring Boot and family.

Indexed Settings

CAS settings able to accept multiple values are typically documented with an index, such as cas.some.setting[0]=value. The index [0] is meant to be incremented by the adopter to allow for distinct multiple configuration blocks.