WuKongIM Docs

Architecture

Understand WuKongIM cluster boundaries through Controller, Slot, Channel, Transport, and online routing.

WuKongIM places low-frequency cluster intent, sharded metadata, ordered message logs, and high-frequency connection state behind different boundaries. Those boundaries matter more than memorizing one function or in-process call graph: failover, scaling, and diagnosis all depend on which component is authoritative for which state.

Every deployment is a cluster

A one-node deployment is a single-node cluster and still follows Controller, Slot, Channel, and routing semantics. The default route table keeps 256 stable physical hash-slot fences. They map onto a potentially different number of logical Slot Raft Groups and are not the same concept.

Architecture map

The diagram contains two distinct paths: Controller and Slot provide control and metadata authority, while Channel provides message-log authority. Online delivery runs after commit and is not part of Channel quorum commit.

Five primary boundaries

BoundaryAuthoritative stateMain responsibilityDoes not own
Controllercommitted Controller Raft log and applied boundarynodes, Slot assignment, tasks, cluster-wide planshigh-frequency sessions or Channel payloads
Slotmetadata state machine under the current Slot Raft Leaderusers, channels, subscribers, ordinary/CMD memberships, ChannelRuntimeMetaChannel message logs
ChannelChannel Leader, ISR, and committed high watermarkper-channel order, durability, replication, committed visibilityglobal membership plans or concrete TCP sessions
Gateway and online runtimeconnection owner node and the UID Presence Authorityclient sessions, online endpoints, cross-node deliverydurable presence or message-commit decisions
Transportbounded connections, queues, and service entry pointsnode Raft, RPC, replication, and notification transportbusiness authorization or unlimited retries

Four layers of authority in one route

A business request can encounter four kinds of authority, and none substitutes for another:

  1. Controller intent declares desired node and Slot assignments, tasks, and revisions.
  2. Live Slot authority uses the observed Raft Leader, term, and configuration epoch to decide who can commit metadata.
  3. Live Channel authority uses the Leader, ISR, Channel Epoch, and Leader Epoch in ChannelRuntimeMeta to fence message writes.
  4. Connection ownership means only the node holding the concrete Session can perform the final client write.

PreferredLeader is Controller intent. The observed Raft Leader is the runtime authority. If Manager or diagnostics lack a live term, configuration epoch, or freshness evidence, preserve an unknown result instead of filling the gap from intent.

Where data lives

DataTypical locationLifecycle
Cluster plans and tasksController Raft plus materialized state filelow-frequency, durable, cluster-wide
Sharded business metadataSlot Multi-Raft plus pkg/db/metadurable and partitioned by physical hash slot
Channel messagesChannel replicas plus pkg/db/messagedurable and ordered per channel
Connections and online endpointsowner node and Presence Authority memoryhigh-frequency, lease- and Session-bound
Transport queues and runtime cachesnode process memorybounded, rebuildable, protected by backpressure

Continue reading

To apply these boundaries to an incident, continue with Troubleshooting and Diagnostics.

On this page