Layer 3 · Go deeper · 11 min
Go deeper
Size it, build it, then make the calls an interviewer will push you on.
Back of the envelope
Size it up
Tap through each step of the arithmetic.
How many gateways hold the evening peak?
How big is the inbox if you delete on delivery?
How much media moves every day?
Build-up · 6 steps
Build the high-level design
One functional requirement at a time, ending with a messenger that works in one region at moderate traffic, before any scaling.
Step 1 of 6
Send a text message
Store before you push. The chat partition writes one inbox entry per recipient device to replicated storage and only then acks Alice; the session registry says Bob’s phone is on gateway 12.
6 interview moments
You’re the candidate
The interviewer pushes on the hard parts. Pick an approach and see how it holds up.
Deep dive 1 of 6
Interviewer
“600 million phones each keep a connection open for hours. How do you build the servers that hold them?”
Your move. Pick an approach:
Deep dive 2 of 6
Interviewer
“The chat service has an envelope for Bob’s phone. Which of 800 gateways holds its socket?”
Your move. Pick an approach:
Deep dive 3 of 6
Interviewer
“Lifts, metro tunnels and crashing servers drop packets all day. How do you show every message exactly once?”
Your move. Pick an approach:
Deep dive 4 of 6
Interviewer
“Two messages in one chat take different gateways, threads and retries. How does every device show them in the same order?”
Your move. Pick an approach:
Deep dive 5 of 6
Interviewer
“Priya writes to a full 1,024-member group, about 1,500 devices, end-to-end encrypted. Who makes the copies?”
Your move. Pick an approach:
Deep dive 6 of 6
Interviewer
“Alice writes to Bob for the first time. His phone is off, and he also uses a laptop. How is it encrypted end to end?”
Your move. Pick an approach:
Build-up · 7 steps
Follow one message through it
The hot path is gateway, chat service, inbox and back out through a gateway. Everything else wakes a phone, hands out keys or moves media bytes.
Step 1 of 7
Connect
Each device opens one Noise-encrypted TCP connection to a gateway, picked by an L4 load balancer. It authenticates with its key and registers its session with a new epoch.