RETURN TO SYSTEM DESIGN VAULT (55)BLUEPRINT #25 // Very Hard
#25Very HardLocation, Geospatial & Ride-Hailing
Surge Pricing System: Uber - Stream Processing, etc.
ASKED IN INTERVIEWS AT:UberLyft
EXECUTIVE SUMMARY & PROBLEM STATEMENT
Design Uber's dynamic surge pricing engine analyzing real-time supply (available drivers) and demand (app opens & ride requests) in geospatial hexagon cells (H3).
SCALE ESTIMATION & TRAFFIC ENVELOPE
DAILY ACTIVE USERS / TPSMillions of concurrent app pings and driver telemetry pings
READ / WRITE TRAFFIC RATIOContinuous stream processing
5-YEAR STORAGE CAPACITYFast spatial memory grid in Redis Cluster
FUNCTIONAL REQUIREMENTS
- [1]Calculate surge multiplier per H3 hexagon cell every 15-30 seconds
- [2]Lock surge multiplier for user for 2-5 minutes once quote is requested
NON-FUNCTIONAL REQUIREMENTS
- •Calculate city-wide surge in < 15 seconds
- •Zero sudden cliff drops across adjacent hexagons (spatial smoothing)
- •High resilience
CORE ARCHITECTURAL COMPONENTS
Driver Location Stream (Kafka)
Rider Request Stream
Flink Complex Event Processor
Surge Multiplier Cache (Redis)
Quote Pinning Service
DATA SCHEMA & PERSISTENCE
SurgeCell: h3_index, supply_count, demand_count, multiplier, updated_at
DISTRIBUTED TRADE-OFFS & FAILURE MODES
- ⟡Spatial smoothing algorithms prevent drivers from gaming the system by waiting on border lines between adjacent hexagons.