RETURN TO SYSTEM DESIGN VAULT (55)BLUEPRINT #16 // Very Hard
#16Very HardLocation, Geospatial & Ride-Hailing
Design Yelp or Nearby Friends
ASKED IN INTERVIEWS AT:AmazonMetaGoogleUber
EXECUTIVE SUMMARY & PROBLEM STATEMENT
Design a geospatial search engine capable of locating nearby places or friends within a radius using spatial indexing algorithms (QuadTrees, Geohash, Google S2).
SCALE ESTIMATION & TRAFFIC ENVELOPE
DAILY ACTIVE USERS / TPS100 Million DAU, 50,000 spatial queries/sec
READ / WRITE TRAFFIC RATIOYelp is 99% Read-heavy; Nearby Friends is 50/50 write/read
5-YEAR STORAGE CAPACITY50 Million places with coordinates ~ 5 GB spatial index in memory
FUNCTIONAL REQUIREMENTS
- [1]Search places/friends within R kilometers radius
- [2]Filter places by rating, category, and open status
- [3]Update user live location (for Nearby Friends)
NON-FUNCTIONAL REQUIREMENTS
- •Query response latency < 50ms
- •High throughput spatial lookups
- •Smooth handling of high-density urban areas
CORE ARCHITECTURAL COMPONENTS
Location Update Gateway
Geospatial Index (Redis Geo / PostGIS / QuadTree Node Cache)
Aggregation Filter Worker
CDN Map Tiles
DATA SCHEMA & PERSISTENCE
Places: place_id, name, lat, lng, geohash (char(8)), rating
DISTRIBUTED TRADE-OFFS & FAILURE MODES
- ⟡Geohash (base32 string prefixes, easy B-Tree indexing) vs QuadTree (hierarchical 2D grid, dynamically splits dense cities).