Nearby Friends System Design (Geo Indexes, Privacy & Scale)

Scenario

Users who opt in want to see which friends are roughly nearby without broadcasting exact addresses. The system must combine location streams (noisy, bursty) with the social graph, respect privacy and freeze modes, and answer queries fast enough that the feature feels live—not a batch job. The interview is about spatial indexing + graph membership, not Haversine in a loop for every friend.

Design Nearby Friends: given a user who has opted in, return friends who are approximately within a configurable distance, updating as people move.

Constraints

Functional

Opt in/out; set who can see you (all friends, subset); list nearby friends with approximate distance; respect “frozen” or hidden mode

Non-functional

Sub-second queries for typical friend list sizes; minimize PII surface; high write rate from location pings

Scale

Hundreds of millions of users; bursty updates during events; global footprint

Stages ahead

1Requirement Analysis
2API Design
3High-Level Design
4HLD Extensions
5Trade-offs
Nearby Friends System Design (Geo Indexes, Privacy & Scale)