Nearby Friends System Design
Visual Problem Diagram

Scenario
Friend map updates every 30 seconds for 10M users in a city—naive "query all friends distance" is O(n) per pan. Geospatial index + privacy grid + push diffs keep the feature usable without draining batteries.
Design a nearby friends feature showing friends within a radius on a map with periodic location updates. You must balance real-time feel, battery, and privacy while querying only a user's friend set—not all users.
You should support opt-in location sharing, nearby query, pause/hide, and block enforcement. Be ready to explain geohash indexing and update throttling.
Constraints
Share location opt-in, nearby friends query, pause sharing, block list, last seen optional
< 500 ms query p95, location freshness minutes, privacy grid enforced, battery-aware
50M DAU sharing location, 1M updates/s peak regional, hundreds friends per user typical