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 messages does pub/sub deliver a second?
How many subscribes a second do app opens cause?
How much memory, and how many socket servers?
Build-up · 5 steps
Build the high-level design
One functional requirement at a time, ending with a design that works for one region at moderate traffic.
Step 1 of 5
Opt in and pick an audience
Settings are low-traffic CRUD that bump a version. An edge builder turns settings, friendships and blocks into mutual share edges per viewer, so “who may see whom?” stays off the hot path.
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
“Rohan wants to see which friends are within 10 km, right now. How do you find them?”
Your move. Pick an approach:
Deep dive 2 of 6
Interviewer
“Every second, 250,000 location updates each need to reach about 3.6 watching friends. How do you route them?”
Your move. Pick an approach:
Deep dive 3 of 6
Interviewer
“7.2M WebSockets on about 200 servers. How do you survive a deploy or a crash?”
Your move. Pick an approach:
Deep dive 4 of 6
Interviewer
“Friends want fresh locations, but the OS throttles background apps and a battery hog gets uninstalled. How often do you send?”
Your move. Pick an approach:
Deep dive 5 of 6
Interviewer
“Assume the attacker is a “friend” running a modified app. How do you show distances without revealing where anyone is?”
Your move. Pick an approach:
Deep dive 6 of 6
Interviewer
“The live feature needs only the latest position. Do you store location history, and how?”
Your move. Pick an approach:
Build-up · 8 steps
Follow Rohan opening the app
The live path is phones, WebSocket servers, pub/sub and the location cache. Settings and history sit to the side, and nothing on the live path waits for a database.
Step 1 of 8
Connect
Rohan’s app opens a WebSocket through an L4 load balancer to one of about 200 WebSocket servers, which authenticates it and starts heartbeats.