Messaging & realtime
Encrypted delivery - one tick, two ticks, blue
What changes when the server cannot read the message, and why every tick after the first is a device claim.
The first act plays here. Owned once with credits, never a subscription.
What this board gets wrong on purpose
The tension
The ticks are claims the server cannot check. Tick two and tick three are produced by the recipient's device and vouched for by nobody the server can audit, so a patched client shows blue ticks it never earned and a battery-saving OS shows none it did - and the server, holding only ciphertext, has no way to tell the two apart. The offline mailbox is worse: it is undecryptable bytes with no expiry policy drawn, so it can never be deduped, compacted or re-encrypted, and the retention period is a guess worth four orders of magnitude of storage. And because the server never held a key, a device added tomorrow gets no history at all - the fix for that, a sender-side history transfer, is not on this board.
Practise this as an interview
Take Encrypted delivery - one tick, two ticks, blue as a timed system design interview on a blank board - on your own, with the requirements to check yourself against, or with a candidate you invite.
Start here
Why this design
End-to-end encrypted messaging is the chat-system question with the server’s eyes taken away. Interviewers use it to see whether you notice that encryption changes the architecture and not only the security posture: fan-out moves onto the sender’s phone, the server can no longer dedupe, index or re-render, and every delivery status after the first is a claim made by a device. Real messengers live with exactly these consequences - multiple devices per person, offline mailboxes, and receipts that outnumber messages.
What you will learn
- Why a message to one person with three devices is three ciphertexts from the sender’s phone, and how 8 billion messages a day become 32 billion envelopes - 1.11M writes a second at peak.
- What each tick actually means: our queue accepted the bytes, a device stored them, a device claims a human looked.
- Why receipts - 64 billion a day, 740,000 a second - outnumber messages eight to one and must merge as a set that only grows.
- How one retention sentence for undelivered mail moves the message store from 160 GB to 87 PB.
- Why the key directory is the one place the server is trusted, and why safety numbers exist because of it.
- How a push notification wakes a device without carrying a body, and why the connection edge is drained rather than restarted.
How to read this board
- The diagram follows the message left to right: THE SENDER · WHERE PLAINTEXT LIVES, then OUR SERVERS · ENVELOPES ONLY, then ONE PERSON · TWO DEVICES.
- Then the two bands that come back: WAKE-UP · FOR A DEVICE WITH NO SOCKET, and THE THREE TICKS · CLAIMS, NOT FACTS. Press play for the eight-step walkthrough, which starts before anything is typed.
- Page 1 · Requirements - the questions, the first of which moves every box on the board.
- Pages 2 and 3 · Capacity and Storage - envelopes, receipts and retention.
- Page 4 · Availability - the single points of failure, and what degrades rather than dies.
- Page 5 · How it works, told end to end, then Page 6 · Deployment plan - home regions, the edge drain, two-release format changes.
- The DATA MODEL at the bottom: five tables, and not one of them has a body column.
- Finish on the deliberate weakness: the ticks are client claims the server cannot verify, the mailbox has no expiry, and a new device gets no history. Decide which of the three you would fix first, and what it costs.
1 · Requirements
Ask these before drawing anything
Every one of these questions moves a box on the diagram. The first one moves all of them.
- Is the server allowed to read a message body? If yes, half this board disappears and search, backup and web clients become easy. If no, fan-out moves onto the sender's phone and stays there.
- One device per person or several? Multi-device is what turns a message into N ciphertexts and makes "history on a new device" a separate product.
- What ordering do we promise, and across what? Per conversation is achievable. Per sender across devices is not, without a sequencer the sender trusts.
- Can a user switch read receipts off? If so the third tick is optional and the UI must be honest about never getting it.
- How long do we hold an undelivered message - 30 days, or forever? This single sentence is worth four orders of magnitude of storage. See the storage page.
- How large may a group be? 1,024 members is a different fan-out problem from a pair, and the sender's uplink pays for it.
- Do we owe anyone server-side search, backup or a browser client? All three need plaintext, so all three become client features or become a compromise.
Functional
- Send a message from one device to every device the recipient owns.
- Deliver immediately to a device that holds a connection; hold it durably for one that does not.
- Report three states to the sender: accepted by the server, received by a device, read by a human.
- Groups up to 1,024 members, with the same guarantees as a 1:1 chat.
- Carry media without putting bytes on the message path.
- Let a new device register keys and begin receiving new messages.
Non-functional
- The server must never hold a key that can open a message body. This is a constraint on the design, not a feature of it.
- p99 send-accepted under 300 ms on a mobile network.
- p50 delivery to a connected device under 500 ms.
- 99.95% availability for accepting a send; 99.9% for delivering to a device that is connected.
- An undelivered message survives the loss of an availability zone.
- At-least-once delivery; the client deduplicates on message id.
Out of scope, and why
- Server-side search and server-side backup: both need plaintext we do not have.
- Voice and video: a different transport with different failure modes.
- History for a newly added device: needs a sender-side transfer, which is a product on its own.
The rest of this board
Available on Tier Slate
This page publishes the question. The answer — 5 more written pages, an 8-step narrated walkthrough and a 5-table schema — is the board itself, and it opens in Tierslate.
- 5written pages
- 8walkthrough steps
- 5tables33 columns
5 pages behind this one
- Capacity estimation
- Storage estimation
- Availability
- How it works
- Deployment plan