Apache Tribes - Transport

Table of Contents

Overview

The Tribes transport moves application and replication messages between known cluster members. Membership discovery is a separate part of the channel. It supplies the address and ports that the transport uses for each destination.

Sending and receiving are deliberately separate. The sender opens connections on demand for outbound messages, while the receiver owns the listening sockets and the worker pool for inbound messages. The current implementations use Java non-blocking I/O (NIO).

Sending messages

The default channel sender is ReplicationTransmitter. It delegates network delivery to PooledParallelSender, which uses a pool of ParallelNioSender instances. A message addressed to multiple members can therefore be written to those members in parallel, and independent messages do not have to share one connection.

Each NIO sender manages the socket for a destination and applies the configured connection timeout, retry, buffer and keep-alive settings. Connections may be reused until a keepAliveCount or keepAliveTime limit closes them.

Receiving messages

NioReceiver accepts incoming connections and uses a selector to detect sockets that are ready for reading. Completed messages are passed to a pool of NioReplicationTask workers. The workers decode the Tribes message, return any requested acknowledgement and pass the message up through the channel interceptor stack.

This design lets a small receiver thread pool service many connections. The pool size should be tuned for the number of members, message rate, message processing cost and available CPU rather than simply set as high as possible.

TCP and UDP

TCP is the default transport for data messages. A message sent with Channel.SEND_OPTIONS_UDP uses UDP instead. UDP delivery requires a udpPort on the receiver so that each member can advertise a destination UDP port.

TCP is appropriate for the normal replication path and for messages that may exceed a single datagram. UDP avoids establishing a TCP connection, but applications must account for datagram size limits, loss and reordering. Transport selection is made per message, so a channel can carry both TCP and UDP traffic.

Delivery options

Send options are bit flags and may be combined for each message:

  • With no acknowledgement option, completion means the message was written to the transport.
  • SEND_OPTIONS_USE_ACK waits for the destination to confirm receipt. This is the default option.
  • SEND_OPTIONS_SYNCHRONIZED_ACK, when combined with SEND_OPTIONS_USE_ACK, waits until the destination has also processed the message.
  • SEND_OPTIONS_ASYNCHRONOUS hands delivery to the MessageDispatchInterceptor queue when that interceptor is in the channel stack.

Acknowledgements detect a delivery or processing failure and report it to the sender. They do not provide transaction semantics across multiple destinations.

Configuration

Sender

Configure the sender's nested Transport element to control its connection pool, timeouts, retry count, socket buffers and keep-alive policy. See the Cluster Sender reference for the complete attribute list and defaults.

Receiver

The receiver configuration defines its bind address, TCP port, optional UDP port, automatic port range, worker limits and socket buffers. See the Cluster Receiver reference for the complete attribute list and defaults.

Tuning

Start with the defaults and measure under representative traffic. If senders wait for a pooled connection, review poolSize and maxWait. If receiving work queues behind available sockets, review the receiver's thread limits and the time spent by channel listeners. Increasing buffers or thread counts without measuring can add memory use and scheduling overhead without increasing throughput.

Network and security

Every member must advertise an address and port reachable by the other members. Firewalls and network policy must allow the receiver's TCP port and, when used, its UDP port. Membership traffic and data transport traffic use separate sockets and may require separate network rules.

Cluster traffic should use a trusted network. If a trusted network is not available, configure the channel to use TLS with static membership and a secure receiver port. TLS protects confidentiality and integrity, but not availability. See the Cluster security reference and the Tomcat security model when designing the cluster network.