Learning on Web Dev Open is free for all.

Interview Prep · System DesignDesign a chat system
← System Design

Design a chat system

Medium45 minFree, no account

Stateful servers, a message that must not be lost, and ordering without a global clock.


The question

Design a one-to-one and small-group chat system: send a message, see it delivered, see when someone is typing.

Fifty million daily users, ten million connected at any moment.

Functional
  • Send a message to a conversation; all members receive it.
  • Message history, paginated, surviving reinstalls.
  • Delivery and read receipts.
  • Online/offline presence.
Non-functional
  • 10M concurrent connections.
  • A sent message reaches an online recipient within ~500ms.
  • A message that was accepted is never lost.
  • Messages in a conversation appear in the same order for everybody.
45:00Commit to an answer before you open the solution. Reading it first teaches you to recognise good answers, which is not the skill being tested.

Stuck?

0 of 3 hints taken

The worked solution

written by a person · not a grade

Score yourself

0 of 5 marked
  • Chose WebSockets and confronted the statefulness with a connection registry25
  • Gave an ordering authority and scoped the guarantee to a conversation20
  • Acknowledged after the durable write and handled retries idempotently25
  • Designed storage around the actual read, with partition growth handled15
  • Kept presence and typing cheap and lossy15

We run no AI here and nothing on this page grades you. The score is yours, and the useful number is the one you get on the same problem a month from now, cold.

kept in this browser only