Menu

Node.js Full State Fan-Out: 2 Counters for Late Joiners
📰

Node.js Full State Fan-Out: 2 Counters for Late Joiners

DEV Community: typescript·MalachiNilsson7591·about 6 hours ago
#thF8YLyx
#devtotypescript#devto#dev#snapshot#state
Reading 0:00
15s threshold

TL;DR: For a B2B SaaS chat room, publish a periodic full snapshot beside every incremental diff. Put snapshotVersion and diffVersion on the messages, and apply a diff only when its base matches the snapshot already held by the client. That gives a reconnecting or late-joining browser a bounded route to the current room state without building a per-client history service.

Choice Late joiner Fan-out cost Server state Pick it when

Diffs only Cannot reconstruct earlier state Low Low Never for authoritative room state

Snapshot plus diffs Converges at the next snapshot Predictable broadcast Current state plus two counters Most chat rooms and live dashboards

Per-client replay Replays from a cursor Depends on backlog Durable ordered history Every intermediate event matters

My default is the middle row. The hard part is not WebSocket syntax. It is deciding what a subscriber may safely apply after packets are delayed, duplicated, or observed only after a reconnect.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.