Uber Surge Pricing & Geospatial Architecture
H3 hexagonal indexing, real-time dispatch, and dynamic pricing
Key Insight
Hexagonal grids have equal-distance neighbors (unlike squares), making them ideal for proximity queries.
Request Journey
How It Works
① Driver app sends GPS every 4s
② Kafka ingests location stream
③ H3 maps GPS to hexagonal cell
④ Supply/demand counted per cell
⑤ Surge ML model computes price multiplier
⑥ Price shown to rider for acceptance
⚠The Problem
Uber must match millions of riderswith nearby drivers in real-time across 70+ countries with sub-second latency. Traditional geospatial approaches using rectangular bounding boxes produce uneven cell sizes and inconsistent neighbor distances. Pricing must respond instantly to hyper-local supply/demand imbalances — a concert ending in one neighborhood shouldn't spike prices three blocks away. The dispatch system must solve a bipartite matching problem in under 100ms.
✓The Solution
Uber developed H3, a hexagonal hierarchical spatial index that divides Earth into hexagonal cells at 16 resolution levels. Hexagons have the unique property that all neighbors are equidistant, making proximity calculations uniform. Driver GPS updates stream through Kafka into an H3-indexed geospatial store, and a dispatch service (DISCO) combines ETA estimation, per-cell supply/demand ratios, and driver state to assign rides optimally.
📊Scale at a Glance
25M+
Trips/Day
~1M
GPS Updates/sec
<100ms
Dispatch Latency
10,000+
Cities Served
🔬Deep Dive
H3 Hexagonal Grid — Why Hexagons Beat Squares
Uber's H3 system divides the Earth's surface into hexagons at 16 resolution levels, from continent-scale down to roughly 1m² cells. Hexagons have a critical geometric advantage over squares: all six neighbors are equidistant from the center cell, eliminating the diagonal-distance problem where square-grid corner neighbors are √2× farther than edge neighbors. This means 'find all drivers within k cells' returns a uniform circular area rather than a diamond. H3 supports hierarchical containment — a resolution-7 cell contains exactly 7 resolution-8 children — enabling multi-resolution aggregation for surge pricing and demand forecasting.
Real-Time Driver Location Indexing
Every active driver's phone sends a GPS update every 4 seconds via a persistent connection. These updates flow through Kafka into a geospatial index service that converts each (lat, lng) to an H3 cell ID at resolution 7 (~5km² cells). The service maintains an in-memory map of cell → [available_driver_ids], continuously updated as drivers move between cells. When a rider requests a ride, the system queries the rider's cell and its k-ring neighbors (concentric hexagonal rings) to find nearby available drivers. This spatial index is sharded by geographic region and replicated across availability zones.
Surge Pricing — Supply/Demand Equilibrium per Cell
Uber computes a surge multiplier per H3 cell by comparing rider demand (open ride requests) to driver supply (available drivers) within a sliding time window. The algorithm blends current real-time conditions with short-term predictions from event calendars, weather data, and historical day-of-week patterns. Surge multipliers are spatially smoothed — adjacent cells have similar values to prevent jarring price cliffs at cell boundaries. The system recalculates pricing every 1–2 minutes per cell, and the multiplier incentivizes drivers to move toward high-demand areas.
DISCO — The Dispatch Assignment Problem
When a rider requests a trip, Uber's dispatch system (DISCO) solves a batched bipartite matching problem: given N available drivers and M pending requests in a region, find the assignment that minimizes total expected pickup time. This is approximated from the Hungarian algorithm for real-time performance. The system considers not just Euclidean distance but live traffic conditions, driver heading direction, road network topology, and even which side of the street the driver is on. The entire dispatch decision — from request to driver notification — completes in under 100ms.
Kafka as the Real-Time Event Backbone
All location updates, trip lifecycle events, pricing signals, and ETA computations flow through Apache Kafka. Uber's Kafka deployment handles millions of messages per second with sub-second end-to-end latency. Topics are partitioned by geographic region, ensuring all events for a given area are processed by the same consumer group for ordering guarantees. This event-driven architecture cleanly decouples the GPS ingestion, surge pricing, and dispatch subsystems — each can scale and deploy independently without tight coupling.
⬡Architecture Diagram
Uber Surge Pricing & Geospatial Architecture — simplified architecture overview
✦Core Concepts
H3 Hexagonal Grid
Apache Kafka
Geofencing
Supply/Demand Modeling
Real-time Dispatch
DISCO
⚖Tradeoffs & Design Decisions
Every architectural decision is a tradeoff. Here's what you gain and what you give up.
✓ Strengths
- ✓H3 hexagons provide uniform-distance neighbor queries unlike rectangular grid systems
- ✓Sub-100ms dispatch latency enables real-time rider-driver matching at global scale
- ✓Hierarchical cell resolution allows multi-granularity pricing and demand analysis
- ✓Event-driven Kafka backbone decouples ingestion, pricing, and dispatch subsystems
✗ Weaknesses
- ✗H3 cell boundaries still create edge effects at borders for surge pricing transitions
- ✗GPS inaccuracy in urban canyons (tall buildings) can misplace drivers into wrong cells
- ✗Real-time geospatial index requires significant in-memory resources per active city
- ✗Surge pricing algorithm must carefully balance revenue optimization with user trust and regulatory compliance
🎯FAANG Interview Questions
Interview Prep💡 These questions appear in FAANG system design rounds. Focus on tradeoffs, not just what the system does.
These are real system design interview questions asked at Google, Meta, Amazon, Apple, Netflix, and Microsoft. Study the architecture above before attempting.
- Q1
Design a ride-matching system. How would you partition geographic space for efficient nearest-neighbor queries?
- Q2
Why did Uber choose hexagonal cells over square grid cells? What geometric properties make hexagons superior for proximity queries?
- Q3
How would you implement surge pricing that responds to hyper-local demand spikes without causing jarring price boundaries at cell edges?
- Q4
A driver is on a cell boundary and two riders in adjacent cells request rides simultaneously. How does the dispatch system decide assignment?
- Q5
Design a system that ingests 1M GPS updates per second and answers 'find nearest K drivers' queries in under 50ms.
Research Papers & Further Reading
H3: Uber's Hexagonal Hierarchical Spatial Index
Brodsky, I. (Uber)
Listen to the Podcast Episode
Alex & Sam break it down
Listen to a conversational deep-dive on this architecture — real trade-offs, production context, and student-friendly explanations. Free, no login required.
Listen to EpisodeFree · No account required · Listen in browser
More Distributed Systems
View allNetflix Content Delivery Architecture
How Netflix streams to 260M users without a single datacenter
Netflix · Disney+ · Hulu
Twitter Fan-Out & Timeline Architecture
The push vs pull dilemma at 500M tweets/day
X (Twitter) · Instagram · LinkedIn
WhatsApp Messaging at 100B Messages/Day
How 50 engineers built a system bigger than Twitter
WhatsApp · Telegram · Signal
Listen to more architecture deep-dives
30 free podcast episodes — Alex & Sam break down every architecture in this library. Listen in your browser, no account needed.
All architecture articles are free · No account needed