Presence and chat fan-out at scale
One illustrative evening in the Goa Trip group chat, five classic bugs, and the layer that fixes them on top of Day 3's connections: three classes of event (durable, soft state, ephemeral); presence as heartbeats with a TTL and a delayed offline trigger, stored per device, with last seen stamped by the server; visible-only subscriptions that take presence from ~84,000 to ~22,000 pushes a second; typing that throttles, expires and drops first; accept then distribute, with write, read and hybrid fan-out; hot rooms (one copy per node, passive sessions, relays); per-conversation sequence numbers fenced by a unique key; receipts as forward-only cursors; store-and-forward sync and multi-device cursors; at-least-once with dedup on both ends; and split-brain presence, clock skew and half-finished fan-outs.
Day 4: presence and chat fan-out.
Previously, on Day 3, you built the pipes: gateways, a connection registry, one pub-sub channel per gateway, and a per-user inbox that clients resume from.