Dev Skills

Design a chat app like WhatsApp

Design a messaging service. One-to-one and group chats, messages delivered in order, delivery and read receipts, and history that survives a phone being lost. Assume mobile clients on unreliable networks.

About this problem

“Design a chat app like WhatsApp” is a core-level problem in the write-heavy / fan-out family. One action by one person creates work for thousands of other people.

The key challenge: Two people are looking at the same screen expecting the message to appear. There is almost no slack on delivery. There is plenty on everything around it, and the design depends on using it.

Time budgets: Delivery: under a second. Receipts: a few seconds. History sync: tens of seconds.

The worked solution for Chat and messaging goes through why those budgets shape the design, stage by stage.

Before you start

You will work this in five timed stages. Here is what each one asks you to think about. None of it is the answer; the answers unlock in the workspace below once you have written your own.

  1. Stage 1 · Requirements · 5 min
    • Group size is the assumption that changes the most boxes. Say a number.
    • Is history stored on the server forever, or only until delivered? Those are different products.
    • What does "delivered" mean — reached the server, or reached the device?
  2. Stage 2 · Actors and lifecycle · 6 min
    • A message has more states than sent and received. What are the ticks actually showing?
    • Who else touches this? The push notification provider is an actor you do not control.
    • What happens to a message for a device that has been offline for two weeks?
  3. Stage 3 · Numbers · 6 min
    • Connections are the capacity unit here, not requests per second.
    • Group messages multiply. One send is how many deliveries?
    • A text message is tiny. What fills the disk?
  4. Stage 4 · High-level design · 12 min
    • Where does the connection live, and how does a message reach the right server?
    • What guarantees ordering within a conversation?
    • What is stored per conversation, and what is stored per user?
  5. Stage 5 · Deep dive and tradeoffs · 14 min
    • What happens on deploy, when every connection drops at once?
    • What does the 100,000-member group do to the fan-out design?
    • How does a new phone get five years of history?
Prefer to read first? The worked solution, end to end →

Work it through

Five stages, gated. You write your answer for each stage before its model answer unlocks. That is the core of the method.

Loading your progress…

Done all five? The diagrams, numbers, trade-offs and follow-ups for this problem are on the worked solution page, to check your own design against.

Before you leave
Try this problem again in a week without reading anything. Comparing what you write then with what you wrote today shows you what stuck.
Stuck, or new to this?Read the full worked solutionAll five stages end to end, with the diagrams and the costs, written out the way you would say it. Best read after you have had a go.Read it →

How it is really built

Write your own answer first. Then read how teams who run this at scale describe it. Their constraints were real, and the write-ups often say what their choices cost.