Client-Cluster Communication Flow
Clients never talk to your service directly. They talk to the cluster. That indirection is the whole point — it is what turns a stream of client requests into an ordered, replicated, durable log before your business logic ever sees a byte.
This page traces a message end to end: connect, redirect to the leader, ingress, consensus, service execution, egress. Knowing where each hop happens tells you exactly where p50, p99, and throughput are won or lost.
The protocol at a glance
Section titled “The protocol at a glance”A client message follows four phases. Each phase has a job, and each adds latency you can reason about.
- Client connects to any cluster node — and may be redirected to the leader.
- Messages flow through the consensus module — ordered and replicated.
- Service processes committed messages — deterministic execution.
- Responses flow back through egress — leader to client.
The indirection is the feature. Because every message is ordered and replicated before execution, the service sees a single, agreed-upon stream — identical on every node.
Who’s in the conversation
Section titled “Who’s in the conversation”These are the participants in the full sequence. Keep them in mind; the latency budget is spread across all of them.
| Participant | Role |
|---|---|
| Aeron Cluster Client | Your application’s client library |
| Aeron Cluster Leader Node | The node that accepts writes |
| Aeron Cluster Member Node (Follower) | Replicates the log |
| Consensus Module | Raft implementation; orders and replicates entries |
| Aeron Archive | Persists log entries to disk |
| Service Container | Hosts your clustered service |
| Customer Built Cluster Logic | Your business code (matching engine, etc.) |
The full calling sequence (24 steps)
Section titled “The full calling sequence (24 steps)”The complete journey is four phases. Read it top to bottom and the latency story tells itself.
Phase 1 — Client connection (steps 1-6)
Section titled “Phase 1 — Client connection (steps 1-6)”A client may connect to any node. If that node is a follower, it gets redirected to the leader. Then the connection itself is logged.
The takeaway: even connecting goes through the log. The session is durable from the first handshake.
Phase 2 — Request processing (steps 7-14)
Section titled “Phase 2 — Request processing (steps 7-14)”This is the consensus hop. The leader appends the request locally and replicates it to followers in parallel. Commit happens only when a quorum acknowledges.
This phase dominates the latency budget. The leader counts itself toward the quorum (quorumThreshold = n/2 + 1, ClusterMember.java), so in a 3-node cluster commit needs just one follower to have appended to its archive and ACKed back. That round trip — replicate, persist, acknowledge — is where p99 lives.
Phase 3 — Service execution (steps 15-17)
Section titled “Phase 3 — Service execution (steps 15-17)”Only committed log fragments reach the service. Execution is deterministic — same input, same state change, on every node.
Your matching engine runs here. Because it only ever sees committed, ordered messages, it never has to reason about consensus, retries, or replication. Keep onSessionMessage() tight: this is in the hot path, and any allocation or blocking call here shows up directly in p50.
Phase 4 — Response to client (steps 18-24)
Section titled “Phase 4 — Response to client (steps 18-24)”The response is not a shortcut back to the client. It goes through consensus too — logged, replicated, committed, then delivered.
So a single request crosses consensus twice — once on the way in, once on the way out. That is the price of exactly-once semantics and clean replay.
What this means for tuning
Section titled “What this means for tuning”Map the phases to your latency targets and the priorities fall out:
- p99 is mostly Phase 2 and Phase 4 — the two consensus round trips. Faster follower disks and lower-jitter inter-node links move p99 more than anything you do on the leader alone.
- p50 is mostly Phase 3 — your
onSessionMessage()logic. Determinism plus a tight hot path keeps the median low. - Throughput is set by the consensus module’s ability to batch — the more requests it can append and replicate per round trip, the higher the ceiling. Ingress and egress are both gated by it.
Because every request pays the consensus tax twice, the cheapest win is almost always making the quorum round trip faster — not optimizing the service code that runs once in the middle.