Course map

Project 12

Real-time chat

Real-time delivery, ordering, storage

Brief

One-to-one and group chat: real-time delivery, message history, delivery and read receipts, presence and typing indicators, offline catch-up on reconnect, push-notification handoff.

Targets

2M concurrent connections · delivery p99 < 500 ms · no lost messages · per-conversation ordering · history scrollback across years.

Must cover

  • Ordering per conversation (→ 114).
  • Message storage partitioned by conversation (→ 73).
  • Presence at scale without heartbeat melt (P).
  • Offline sync — per-device cursor catch-up on reconnect (P).
  • Delivery and read receipts — three different facts, modeled separately (P).

Design challenges

  1. Connection tier (→ 40, 91): stateful WebSocket servers — a connection registry (which user is on which node), message routing between nodes, reconnect storms after a node dies.
  2. Delivery guarantees: server ack, recipient ack, read receipt; offline catch-up via a per-device cursor into the conversation log (→ 115–116).
  3. Ordering (→ 114): per-conversation sequence numbers, and why wall-clock timestamps fail (→ 135).
  4. Message store (→ 61, 73): write-heavy, time-ordered, partitioned by conversation — assess the wide-column fit; ID design → 75.
  5. Group fan-out at 1k-member groups: write per recipient vs. read from a shared log — with the arithmetic (→ 99).
  6. Presence at 2M connections (→ 97; → 127 — ahead, Part 8).

Out of scope

End-to-end encryption (its architectural impact honestly noted in step 21), voice/video.

Search the guide