software-engineer-blog logoSoftware Engineer Blog

Question 10 · Track 3 · Deliver it to people

Design a chat application

The transport is the easy part. Ordering is not.

Deliver it to people. 4 clarifying questions to ask first, the answer in 4 moves, the follow-up that catches a memorised answer and 2 supporting topics to watch or read.

What it is really testing

Whether you persist before you acknowledge, and how you order messages without trusting a clock.

Ask these first

Before a single box goes on the board. The answers change the design, which is the point of asking out loud.

The answer, in 4 moves

In this order. Each move earns the next one — say them out loud rather than drawing all four and narrating afterwards.

  1. 1A WebSocket per connected client, and a registry of which server holds which connection.
  2. 2Persist the message BEFORE acknowledging it — the ack is a durability promise.
  3. 3Queue per recipient for anyone offline; drain it on reconnect.
  4. 4Shard history by conversation id, so one hot group stays on one partition.

The trap

The follow-up that separates a rehearsed answer from a real one.

Order is per conversation, not global, and a timestamp is not an order — two phones disagree about the time. A per-conversation sequence number is what makes the transcript identical on every device.

Watch or read

The pieces of this answer, each covered on its own. Take them whichever way suits you, then give the whole answer without looking.

Stateless vs stateful

Stateless servers forget you after each request, scaling infinitely but requiring every call to carry full context. Stateful servers remember you, enabling natural continuity but pinning you to one node.

ReelRead

Part of System Design Interviews, Answered Out Loud. The fundamentals underneath it are the free CS course.