Messaging with server-side history and multi-device sync, inspired by Facebook Messenger and Slack: persistent connections, per-conversation sequence numbers in a wide-column message store, fan-out to every device, catch-up from the last sequence number, unread counts, push and media. A teaching design.
See why polling and one messages table fall over.
What was missing: Nothing yet.
Why that's risky: Millions of idle devices polling every few seconds swamp the server, messages arrive only on the next poll, and one table holds everyone's history.
What gets added: One server that devices poll for new messages, with all messages in one table.
Trade-offs: Simple request/response, but wasteful and slow.
Deliver instantly and give every conversation one agreed order.
What was missing: Polling, and no guaranteed order across devices.
Why that's risky: The chat service delivers inline to every device of every recipient, so a send to a big group is slow, and a device that was offline misses messages.
What gets added: Chat gateways with a persistent connection per device, a chat service that gives each message the next sequence number in its conversation and appends it to a message store partitioned by conversation before acknowledging, a membership database, a device session registry, and delivery to the recipient's gateway.
Trade-offs: Per-conversation sequence numbers give a total order inside a conversation, not across conversations, which is all users need.
Deliver to every device of every recipient, and let offline devices catch up exactly.
What was missing: Delivery happened inline, and offline devices lost messages.
Why that's risky: Users with no device online never find out about new messages, and there are no unread counts.
What gets added: A delivery log partitioned by conversation and delivery workers that look up all recipients' online devices and hand each message to their gateways; a device that was offline asks for everything after its last sequence number when it reconnects.
Trade-offs: Delivery is at-least-once; devices drop duplicates by sequence number.
Reach users with no device online and show what's unread.
What was missing: No notifications for offline users, no unread counts.
Why that's risky: Photos and voice clips have nowhere to go.
What gets added: Push jobs and workers that notify users with no device online (collapsing bursts into one notification), and an inbox cache of recent conversations with unread counts, cleared using each member's last-read position.
Trade-offs: Unread counts are updated asynchronously and may lag a message by a moment.
Send photos, videos and voice clips without clogging the chat path.
What was missing: No attachments.
Why that's risky: Spam and runaway clients aren't limited, and delivery health isn't visible.
What gets added: A media service that issues upload URLs and makes thumbnails, object storage for attachments, and a CDN that serves them; messages carry only a reference.
Trade-offs: Attachments appear once their upload finishes, slightly after the message.
Contain abuse and watch delivery.
What was missing: No limits or visibility.
Why that's risky: Remaining risk is regional: conversations should fail over to a replica region.
What gets added: Rate limits per account and device, and monitoring of send-to-deliver latency, delivery backlog, catch-up volume and push failures.
Trade-offs: Limits can slow a legitimate burst; they are generous for established accounts.
Use per-conversation partitions and sequence numbers in the message store.
Use append-only logs and periodic compaction to reduce write amplification.
The gateway handles authentication, rate limiting, and connection routing.
Workers fan out messages asynchronously and allow retries without blocking chat servers.
Media has different access patterns and benefits from dedicated storage and CDN caching.
You're in the middle of an interview session. Leaving now will end your current attempt.
Explore concept overviews, real-system examples, key tradeoffs, and interview talking points for each roadmap section.
You've conquered this phase. These are the skills you now own: