LESSON 01 · Product boundary

Define the conversation

Decide whose messages move where before selecting a transport or database.

SYSTEM VIEW

The message path

Diagram view
Promises kept—
Open sockets—
Peak sends—

Watch one message make three separate promises, then size the system that has to keep them.

  1. Ana writes to Ben, who has a laptop and a phone on one account. Assume text, one-to-one chats and groups of at most 250. Decide whether edits, attachments and end-to-end encryption ship first: WhatsApp encrypts by default, which rules out the server-side search Slack offers.

    Groups
    up to 250
    Devices
    several each
    Decide now
    edits, files, E2EE

    What changed

    • Text, 1:1, groups up to 250
    • Several devices per account
    • Edits, files, E2EE: decide now
  2. Ana sends “lunch?”. The Chat service stores it in Message history first, then answers Ana’s phone with “accepted”. That answer is the sender’s promise: the message is durable. It doesn’t say any of Ben’s devices has it.

    What changed

    • “lunch?” stored
    • Ana sees “accepted”
  3. Ben’s laptop is online, holding an open socket on the Gateway. The Chat service sends “lunch?” through it, and the laptop shows it quickly: the second promise. Ben’s phone is offline and has nothing yet.

    What changed

    • “lunch?” live on Ben’s laptop
    • Ben’s phone: nothing yet
  4. Ben’s phone comes back online and fetches what it missed from Message history, so it finds “lunch?” too: the third promise. A green dot or a push notification can’t stand in for this durable delivery.

    What changed

    • Ben’s phone back online
    • “lunch?” fetched from history
  5. Now size the whole system. Of 30 million daily users, 10% are connected at peak with 1.5 devices each: 4.5 million open sockets for the Gateway fleet to hold. Registered accounts alone can’t size that connection fleet.

    Daily users
    30 million
    At peak
    10% connected
    Devices
    1.5 each

    What changed

    • Ana’s and Ben’s devices
    • 30 million daily users
    • Gateway becomes a fleet
    • 4.5M open sockets at peak
  6. At 40 messages per user a day, 30 million users send 1.2 billion messages: about 14,000 a second on average and 42,000 at a threefold peak. One message to a full group of 250 becomes 249 deliveries.

    Per day
    1.2 billion
    Average
    14,000/s
    Full group
    249 deliveries

    What changed

    • 40 messages per user a day
    • 42,000 sends/s at peak
    • 249 deliveries per full-group send
  7. Carry these numbers as assumptions and revisit them. Switch the audience: a 500-person team could run on one server and one database, where connection fleets and sharding would cost more than they return; 30 million daily users need the Gateway fleet.

    Team of 500
    one server, one database

    What changed

    • Audience: a 500-person team
    • Gateway fleet
    • One server, one database
    Audience

Space plays · ← → step · Home resets

THE IDEA

How it works

“Build chat” leaves important choices unanswered. For this design, assume text messages, one-to-one conversations, groups of at most 250 members, multiple devices per account, online indicators, and notifications when the app is away. Agree on a target audience, latency goal, history retention, and whether edits, attachments, or end-to-end encryption belong in the first release. Those are product differences, not just sizes: WhatsApp encrypts messages end to end by default, which rules out the server-side search that Slack offers.

Separate sending a message from receiving it. A sender needs an acceptance result; an online recipient should see the message quickly; an offline recipient should find it on return. These are three different promises. A green dot or push notification cannot stand in for durable message delivery.

Estimate active concurrent connections, messages per second at peak, average message size, and group fanout, meaning how many deliveries one message becomes. Registered accounts alone cannot size a connection fleet. As an example, take 30 million daily users, 10% connected at peak with 1.5 devices each: 4.5 million open sockets. At 40 messages per user per day, that is 1.2 billion messages, about 14,000 per second on average and 42,000 at a threefold peak. One message to a full group becomes 249 deliveries.

Carry uncertain numbers as assumptions and revisit them. A team chat for 500 people could run on one server and one database, so fleets of connection servers and sharding (splitting data across databases) would cost more than they return.

DECISION POINT

A team asks for “real-time chat” and says nothing about groups, devices, or offline users. What should the first design conversation establish?

Write a sentence or two to unlock the guidance. Committing first is what makes it stick.

Keep in mind

  • State the exact chat product and first-release boundary.
  • Define acceptance, live delivery, and later retrieval as separate outcomes.
CHECK YOUR UNDERSTANDING

Put it into practice.

1 OF 3
ApplyQUESTION 01

Which new requirement forces a change to how live messages are routed?

Choose an answer. You’ll see the explanation once you get it right.

Next lesson

0 of 3 checkpoints answered correctly to complete this lesson.