Apache Tribes - Membership
Table of Contents
Membership
The membership service maintains the set of remote nodes known to a
Tribes channel. It advertises the local receiver's address and ports,
discovers or monitors remote members, and reports additions and removals
to the channel's MembershipListeners. Applications use this
view through methods such as Channel.getMembers() and then
choose the members to which a message is sent.
Membership does not carry application messages. It supplies the destination information used by the message transport. A member record includes the host, TCP port, secure port, UDP port, unique identifier, domain, payload, and the time for which the member has been alive.
Choosing a membership service
Tribes provides three membership services. Select the service that fits the environment in which all of the nodes run.
| Service | Discovery source | Typical use |
|---|---|---|
McastService |
UDP multicast heartbeats | Networks where multicast is available and permitted |
StaticMembershipService |
Members listed in the configuration | Fixed topologies or networks without multicast |
CloudMembershipService |
Kubernetes API or DNS | Orchestrated environments with changing node addresses |
The service is configured as the Membership component of a
Channel. The local member's message endpoints are taken from
the channel receiver, so the receiver must advertise an address that the
other nodes can reach. Complete property descriptions are in the
membership configuration
reference.
Multicast membership
McastService periodically sends a heartbeat to a multicast
address and port. Nodes using the same multicast group discover each
other without an explicit list. A node is removed when no heartbeat is
received for dropTime milliseconds. The default
frequency is 500 ms and the default dropTime is
3000 ms.
<Membership className="org.apache.catalina.tribes.membership.McastService"
address="228.0.0.4"
port="45564"
frequency="500"
dropTime="3000"/>The multicast address and port identify the group. Use different values
to keep unrelated clusters apart. On a host with multiple network
interfaces, set bind to the interface used for membership
traffic. The ttl controls how far multicast packets may
travel; network switches and routers must also be configured to pass the
traffic.
A busy JVM or network can delay heartbeats long enough to cause a false
removal. Increase dropTime when necessary, while remembering
that it also increases the time needed to detect a real failure. The
TcpFailureDetector may be added to confirm a suspected
failure with a TCP connection before the event is passed up the channel.
Static membership
StaticMembershipService avoids multicast. Each node is given
the same list of members and the service exchanges point-to-point ping
messages to announce membership and track liveness. This is useful when
the topology changes infrequently or multicast cannot cross the network
boundary between nodes.
<Membership className="org.apache.catalina.tribes.membership.StaticMembershipService">
<Member className="org.apache.catalina.tribes.membership.StaticMember"
host="tomcat-a.example.net"
port="4000"
uniqueId="{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}"/>
<Member className="org.apache.catalina.tribes.membership.StaticMember"
host="tomcat-b.example.net"
port="4000"
uniqueId="{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0}"/>
</Membership>The member host and ports must match the addresses advertised by the
corresponding receivers. Every uniqueId must contain 16
bytes and must be unique and stable across restarts. The local member is
normally identified from the receiver settings; a
LocalMember may be configured explicitly when required.
The default expirationTime is 5000 ms. Pings may be sent by
the channel heartbeat or by a dedicated membership thread when
useThread is enabled. Static membership requires the
Cluster element's channelStartOptions to retain
its default value of 15, so both membership receive and send
processing are started.
Combining dynamic and static membership
StaticMembershipInterceptor provides a second way to add
static members. Unlike StaticMembershipService, it does not
replace the configured membership service. It adds its configured members
to the members discovered by McastService,
CloudMembershipService, or another membership service. This
is useful when most nodes can be discovered dynamically but some nodes
must be configured explicitly.
<Membership className="org.apache.catalina.tribes.membership.McastService"
address="228.0.0.4"
port="45564"
frequency="500"
dropTime="3000"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpPingInterceptor"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor">
<Member className="org.apache.catalina.tribes.membership.StaticMember"
host="tomcat-remote.example.net"
port="4000"
uniqueId="{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}"/>
</Interceptor>Place the StaticMembershipInterceptor after the
TcpFailureDetector in the channel configuration so the
detector verifies the configured nodes and reports their availability in
the same way as dynamically discovered nodes. Place
TcpPingInterceptor before TcpFailureDetector to
trigger periodic liveness checks, including when no application messages
are being sent. If dynamic discovery later reports the same host and
enabled ports, the dynamically discovered
member replaces the configured entry to prevent messages being sent to
the node twice. The static entry is restored if that dynamic member
disappears. See the
cluster
interceptor configuration reference for the complete member
attributes and local-member configuration.
Cloud membership
CloudMembershipService discovers nodes through a pluggable
cloud provider. Its default provider queries the Kubernetes API and can
restrict the returned pods with a label selector. The alternative
dns provider resolves a DNS service name. The channel
heartbeat refreshes the view, and members that are no longer returned are
removed after expirationTime.
<Membership
className="org.apache.catalina.tribes.membership.cloud.CloudMembershipService"
membershipProviderClassName="kubernetes"/>The Kubernetes provider reads its API endpoint, namespace, credentials,
and optional label selector from the pod environment. The DNS provider
uses the service named by DNS_MEMBERSHIP_SERVICE_NAME and is
selected with membershipProviderClassName="dns". See the
cloud membership JavaDoc for the provider-specific environment
variables and examples.
DNS is used to seed the membership view. To tolerate stale DNS caches, the DNS provider also accepts a message from a previously unknown node and adds that sender to the view. Use TLS for the cluster transport when participation must be limited to nodes that possess the configured credentials.
Member events and failure detection
A membership provider reports a member only after it has enough
information to address that node's receiver. A newly discovered member
produces a memberAdded() event. An expired or explicitly
stopped member produces a memberDisappeared() event. These
events update the channel view and are then forwarded to registered
membership listeners.
Discovery and message delivery are separate observations. A member may
disappear from the membership view before a send notices a broken
connection, or a send may fail before the membership timeout expires.
Callers must therefore handle both membership events and
ChannelExceptions from sends.
The domain value is included in member records and can be
used by components such as DomainFilterInterceptor to filter
events and messages. It does not create a security boundary; use separate
discovery groups and protected transport where isolation is required.
Security
Multicast membership traffic is not authenticated or encrypted and always requires a trusted network. Static configuration removes multicast discovery but does not, by itself, protect the point-to-point cluster traffic. Cloud discovery is also a source of addresses rather than an authorization mechanism.
Restrict membership and receiver traffic at the network layer. If a trusted network is not available, configure the channel to use TLS with a pre-shared key and configure the secure port for the receiver and every statically configured member. TLS protects the point-to-point cluster traffic, not multicast discovery. See the cluster security configuration and the Tomcat security model before exposing any Tribes endpoint outside a trusted network.
Operations and troubleshooting
- Verify that every receiver advertises an address and port reachable by all other members. NAT and container addresses frequently require explicit receiver configuration.
- For multicast, verify routing, interface binding, group address, port, and TTL from every node. A node that can send but not receive multicast will have an inconsistent membership view.
- For static membership, keep the member list, ports, and identifiers consistent on every node.
- For cloud membership, verify that the API or DNS response contains the intended running nodes and that the configured refresh and expiration times match the environment.
- Inspect the
component=MembershipMBean to compare the member view on each node. The Tribes status guide describes the available JMX information.
