ProblemReal-time and messaging
Chat
One-to-one and group messaging: every message on every device, in the same order, all over the world.
The brief
Global messenger · suggested for Senior
Design a chat app like WhatsApp
Design a WhatsApp-style messaging app: 1:1 and group chats, delivered in real time to every device a person uses, in the same order everywhere, and readable only by the people in the chat.
People chat one to one and in groups of up to 1,000, on a phone plus up to four linked devices such as a laptop or a tablet. A message to someone online should arrive within about half a second; someone whose phone is off should get it when they come back, even days later. Each message shows when it was sent, delivered and read, people can send photos, videos and files, and contacts can see whether someone is online. Chats are end-to-end encrypted, so the service passes on messages it cannot read. The service is global: about two billion users, half a billion devices connected at the busiest moment, and about 100 billion messages a day. Design the messaging service, from the tap on Send to the message on every device.
Functional requirements
- CoreSend and receive messages in 1:1 chats and in groups of up to 1,000 members.
- CoreA message to someone whose phone is off reaches them when they come back, even days later.
- CoreEach message shows when it was sent, delivered and read.
- CoreSend photos, videos and files of up to 100 MB.
- CoreUse one account on a phone and up to 4 linked devices (desktop, web, tablet), all in sync.
- CoreSee whether a contact is online, or when they were last seen.
Non-functional requirements
- DurabilityA message the service has accepted is never lost while it waits for a device (up to 30 days), and it shows exactly once on each device.
- ConsistencyEveryone in a chat sees its messages in the same order, on every device.
- LatencyA message to someone who is online arrives within about 500 ms at the 99th percentile, worldwide.
- SecurityChats are end-to-end encrypted: only the devices in a chat can read its messages, not the service.
- AvailabilitySending and receiving stay available (99.99%), even when a whole region is down.
- QualityMessages that have not reached every device yet are kept for 30 days; chat history lives on each user's devices.
Scale
- ScaleAbout 2 billion users; about 500 million devices connected at the busiest moment.
- ScaleAbout 100 billion messages a day.
- ScaleMost chats are 1:1 and most groups have under 20 members, but a busy 1,000-member group can get about 50 messages a second.
- ScaleAbout 5% of messages carry a photo, video or file, about 200 KB on average.
- ScaleUsers on every continent; the service runs in several regions.
Nice to mention (below the line)
- Below the lineTyping indicators.
- Below the lineSearching old messages.
- Below the lineEditing and deleting sent messages.
- Below the lineBacking up chats.
Out of scope
- Out of scopeVoice and video calls.
- Out of scopeStatus updates and stories.
- Out of scopePayments.
- Out of scopeFinding contacts from the address book.
- Out of scopeSpam and abuse detection.
Variants
Each variant is a full brief at a different size, smallest first. The variant decides which requirements matter; the level decides how strictly you’re graded. Any variant works at any level.
- Suggested for SeniorChosen
1:1 and group chats for two billion people, end-to-end encrypted, on every device they use.
9 steps · 7 must-pass · about 51 min at Senior · Scale it up → Team chat
- Suggested for Senior
Channels, threads and DMs for companies: a workspace each, channels of 100,000 people, badges on every device and years of searchable history.
9 steps · 7 must-pass · about 53 min at Senior
What each level is graded on
Global messenger, step by step. A result at a level needs its must-pass steps answered, and only the steps you answer count. Going up a level adds steps or holds them to a stricter bar.
| Step | Entry level | Mid-level | Your levelSenior | Staff |
|---|---|---|---|---|
| The numbers that shape the design (optional) | Graded | Graded | Graded | Graded |
| Messages, chats and devices | Graded | Graded | Graded | Graded |
| What travels on the connection | Graded | Must-pass | Must-pass | Must-pass |
| A message, end to end | Must-pass | Must-pass | Must-pass | Must-pass |
| The same order on every screen | Must-pass | Must-pass | Must-pass | Must-pass |
| Never lose a message | Must-passcan block | Must-passcan block | Must-passcan block | Must-passcan block |
| A phone that drops out, and a laptop too | — | Must-pass | Must-pass | Must-pass |
| What the service can't read | — | — | Must-pass | Must-pass |
| Ten people, or a thousand | — | — | Must-pass | Must-pass |
| Regions, busy groups and slow phones | — | — | — | Must-pass |
| At this level | 6 steps 3 must-pass about 32 min | 7 steps 5 must-pass about 38 min | 9 steps 7 must-pass about 51 min | 10 steps 8 must-pass about 58 min |
Entry level6 steps · 3 must-pass · about 32 min
- The numbers that shape the design (optional)Graded
- Messages, chats and devicesGraded
- What travels on the connectionGraded
- A message, end to endMust-pass
- The same order on every screenMust-pass
- Never lose a messageMust-passcan block
Mid-level7 steps · 5 must-pass · about 38 min
- The numbers that shape the design (optional)Graded
- Messages, chats and devicesGraded
- What travels on the connectionMust-pass
- A message, end to endMust-pass
- The same order on every screenMust-pass
- Never lose a messageMust-passcan block
- A phone that drops out, and a laptop tooMust-pass
SeniorYour level9 steps · 7 must-pass · about 51 min
- The numbers that shape the design (optional)Graded
- Messages, chats and devicesGraded
- What travels on the connectionMust-pass
- A message, end to endMust-pass
- The same order on every screenMust-pass
- Never lose a messageMust-passcan block
- A phone that drops out, and a laptop tooMust-pass
- What the service can't readMust-pass
- Ten people, or a thousandMust-pass
Staff10 steps · 8 must-pass · about 58 min
- The numbers that shape the design (optional)Graded
- Messages, chats and devicesGraded
- What travels on the connectionMust-pass
- A message, end to endMust-pass
- The same order on every screenMust-pass
- Never lose a messageMust-passcan block
- A phone that drops out, and a laptop tooMust-pass
- What the service can't readMust-pass
- Ten people, or a thousandMust-pass
- Regions, busy groups and slow phonesMust-pass
- Must-pass
- a result at that level needs this step answered.
- Can block
- a miss there is a Blocking issue at that level.
Going up a level
- Mid-level
- “What travels on the connection” becomes must-pass.Adds “A phone that drops out, and a laptop too”, must-pass.
- Senior
- Adds “What the service can't read”, must-pass.Adds “Ten people, or a thousand”, must-pass.
- Staff
- “What the service can't read” is graded more strictly.Adds “Regions, busy groups and slow phones”, must-pass.
Skills this problem practises
Your coach tracks readiness per skill across every problem you practise. Each links to the lesson that teaches it.
- Capacity estimation
- Idempotency and retries
- Data modelling
- Choosing storage
- Indexing
- Sharding and partitioning
- High-level architecture
- Queues and async messaging
- Networking and protocols
- Traffic surges and backpressure
- Consistency and concurrency
- Replication and durability
- Security and privacy
Worked solution
Try it first: practise a variant, then read the walkthrough and compare it with your own design. Reading it first makes the practice much less useful.
Learn: Design WhatsAppYour history
Sign in to see your sessions on this problem.