Skip to content

Commit 30d8322

Browse files
sainadh777markt-asf
andcommitted
Document Tribes transport architecture (#1134)
* Document Tribes transport architecture Co-authored-by: Mark Thomas <markt@apache.org>
1 parent 877f0e9 commit 30d8322

2 files changed

Lines changed: 156 additions & 2 deletions

File tree

‎webapps/docs/changelog.xml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,16 @@
204204
</fix>
205205
</changelog>
206206
</subsection>
207+
<subsection name="Cluster">
208+
<changelog>
209+
<docs>
210+
Expand the Tribes transport documentation to describe the current NIO
211+
sender and receiver pipeline, TCP and UDP selection, delivery options,
212+
configuration and security considerations. Based on pull request
213+
<pr>1134</pr> by sainadh777. (markt)
214+
</docs>
215+
</changelog>
216+
</subsection>
207217
<subsection name="Other">
208218
<changelog>
209219
<fix>

‎webapps/docs/tribes/transport.xml‎

Lines changed: 146 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,153 @@
2828

2929
<body>
3030

31+
<section name="Table of Contents">
32+
<toc/>
33+
</section>
34+
35+
<section name="Overview">
36+
<p>
37+
The Tribes transport moves application and replication messages between
38+
known cluster members. Membership discovery is a separate part of the
39+
channel. It supplies the address and ports that the transport uses for each
40+
destination.
41+
</p>
42+
<p>
43+
Sending and receiving are deliberately separate. The sender opens
44+
connections on demand for outbound messages, while the receiver owns the
45+
listening sockets and the worker pool for inbound messages. The current
46+
implementations use Java non-blocking I/O (NIO).
47+
</p>
48+
</section>
49+
50+
<section name="Sending messages">
51+
<p>
52+
The default channel sender is <code>ReplicationTransmitter</code>. It
53+
delegates network delivery to <code>PooledParallelSender</code>, which uses
54+
a pool of <code>ParallelNioSender</code> instances. A message addressed to
55+
multiple members can therefore be written to those members in parallel,
56+
and independent messages do not have to share one connection.
57+
</p>
58+
<p>
59+
Each NIO sender manages the socket for a destination and applies the
60+
configured connection timeout, retry, buffer and keep-alive settings.
61+
Connections may be reused until a <code>keepAliveCount</code> or
62+
<code>keepAliveTime</code> limit closes them.
63+
</p>
64+
</section>
65+
66+
<section name="Receiving messages">
67+
<p>
68+
<code>NioReceiver</code> accepts incoming connections and uses a selector
69+
to detect sockets that are ready for reading. Completed messages are passed
70+
to a pool of <code>NioReplicationTask</code> workers. The workers decode the
71+
Tribes message, return any requested acknowledgement and pass the message
72+
up through the channel interceptor stack.
73+
</p>
74+
<p>
75+
This design lets a small receiver thread pool service many connections.
76+
The pool size should be tuned for the number of members, message rate,
77+
message processing cost and available CPU rather than simply set as high as
78+
possible.
79+
</p>
80+
</section>
81+
82+
<section name="TCP and UDP">
83+
<p>
84+
TCP is the default transport for data messages. A message sent with
85+
<code>Channel.SEND_OPTIONS_UDP</code> uses UDP instead. UDP delivery
86+
requires a <code>udpPort</code> on the receiver so that each member can
87+
advertise a destination UDP port.
88+
</p>
89+
<p>
90+
TCP is appropriate for the normal replication path and for messages that
91+
may exceed a single datagram. UDP avoids establishing a TCP connection, but
92+
applications must account for datagram size limits, loss and reordering.
93+
Transport selection is made per message, so a channel can carry both TCP
94+
and UDP traffic.
95+
</p>
96+
</section>
97+
98+
<section name="Delivery options">
99+
<p>
100+
Send options are bit flags and may be combined for each message:
101+
</p>
102+
<ul>
103+
<li>
104+
With no acknowledgement option, completion means the message was written
105+
to the transport.
106+
</li>
107+
<li>
108+
<code>SEND_OPTIONS_USE_ACK</code> waits for the destination to confirm
109+
receipt. This is the default option.
110+
</li>
111+
<li>
112+
<code>SEND_OPTIONS_SYNCHRONIZED_ACK</code>, when combined with
113+
<code>SEND_OPTIONS_USE_ACK</code>, waits until the destination has also
114+
processed the message.
115+
</li>
116+
<li>
117+
<code>SEND_OPTIONS_ASYNCHRONOUS</code> hands delivery to the
118+
<code>MessageDispatchInterceptor</code> queue when that interceptor is in
119+
the channel stack.
120+
</li>
121+
</ul>
122+
<p>
123+
Acknowledgements detect a delivery or processing failure and report it to
124+
the sender. They do not provide transaction semantics across multiple
125+
destinations.
126+
</p>
127+
</section>
128+
129+
<section name="Configuration">
130+
<subsection name="Sender">
131+
<p>
132+
Configure the sender's nested <code>Transport</code> element to control
133+
its connection pool, timeouts, retry count, socket buffers and keep-alive
134+
policy. See the
135+
<a href="../config/cluster-sender.html">Cluster Sender reference</a> for
136+
the complete attribute list and defaults.
137+
</p>
138+
</subsection>
139+
140+
<subsection name="Receiver">
141+
<p>
142+
The receiver configuration defines its bind address, TCP port, optional
143+
UDP port, automatic port range, worker limits and socket buffers. See the
144+
<a href="../config/cluster-receiver.html">Cluster Receiver reference</a>
145+
for the complete attribute list and defaults.
146+
</p>
147+
</subsection>
148+
149+
<subsection name="Tuning">
150+
<p>
151+
Start with the defaults and measure under representative traffic. If
152+
senders wait for a pooled connection, review <code>poolSize</code> and
153+
<code>maxWait</code>. If receiving work queues behind available sockets,
154+
review the receiver's thread limits and the time spent by channel
155+
listeners. Increasing buffers or thread counts without measuring can add
156+
memory use and scheduling overhead without increasing throughput.
157+
</p>
158+
</subsection>
159+
</section>
31160

32-
<section name="Transport">
33-
<p>TODO</p>
161+
<section name="Network and security">
162+
<p>
163+
Every member must advertise an address and port reachable by the other
164+
members. Firewalls and network policy must allow the receiver's TCP port
165+
and, when used, its UDP port. Membership traffic and data transport traffic
166+
use separate sockets and may require separate network rules.
167+
</p>
168+
<p>
169+
Cluster traffic should use a trusted network. If a trusted network is not
170+
available, configure the channel to use TLS with static membership and a
171+
secure receiver port. TLS protects confidentiality and integrity, but not
172+
availability. See the
173+
<a href="../config/cluster.html#Security">Cluster security reference</a>
174+
and the
175+
<a href="https://tomcat.apache.org/security-model.html">Tomcat security
176+
model</a> when designing the cluster network.
177+
</p>
34178
</section>
35179
</body>
36180

0 commit comments

Comments
 (0)