Case study boundary
Use this as a learning model.
This page explains architectural patterns and constraints inspired by Uber. It should not be read as the exact private production architecture or as a one-size-fits-all recommendation.
Evidence
Public info + inference
Learn first
Concepts behind this architecture
Load Balancer
Distribute traffic across healthy servers without making clients know where work runs.
CRDT
Let distributed replicas accept local edits and merge without conflicts.
Operational Transform
Transform concurrent edits so collaborative documents preserve user intent.
Pub/Sub
Broadcast events from publishers to many independent subscribers.
Overview
Uber’s ride-hailing platform connects millions of riders with drivers across 10,000+ cities worldwide. Its architecture must solve complex real-time problems: matching riders to nearby drivers, computing ETAs, tracking live locations, calculating dynamic pricing, and processing payments — all within seconds. The system processes millions of location updates per second and completes trip matching in under 10 seconds.
Scale
130M+
Monthly active riders
~28M
Trips per day
Millions
GPS updates/second
Petabytes
Trip & location data
Requirements
Functional
- Rider-driver matching based on proximity and ETA
- Real-time GPS tracking of rides
- Dynamic pricing (surge pricing)
- ETA estimation and route optimization
- Payment processing and fare calculation
- Trip history and receipts
- Driver and rider ratings
Non-Functional
- Sub-10 second ride matching
- Real-time location processing at massive scale
- High availability across cities worldwide
- Accurate ETA predictions
- Fraud detection in real-time
- Support for millions of concurrent GPS streams
High-Level Architecture
Key Components
Location Service
Ingests millions of GPS updates per second from driver apps. Uses a geospatial index (Google S2 cells) to efficiently query nearby drivers. Data is partitioned using consistent hashing (Ringpop).
Matching Service (DISCO)
Uber’s dispatch optimization system. Matches riders with the best available driver based on proximity, ETA, driver preferences, and supply-demand balance.
Pricing Service
Calculates fares and implements dynamic (surge) pricing based on real-time supply-demand ratios per geographic zone. Uses ML for demand forecasting.
ETA Service
Predicts arrival times using real-time traffic data, historical patterns, and ML models. Considers road segments, traffic signals, and time-of-day patterns.
Trip Service
Manages the full trip lifecycle from request to completion, including state machine transitions, fare calculation, and receipt generation.
Maps/Routing Service
Custom routing engine built on OpenStreetMap data, enhanced with road network data from billions of historical trips.
Data Model
Geospatial Indexing with S2 Geometry
Uber uses Google S2 Geometry to solve the core problem of finding nearby drivers efficiently.
How S2 Works:
- Divides Earth’s surface into hierarchical cells using a Hilbert curve
- Each cell has a unique 64-bit ID
- Cells at level 12 (~3.3km²) are used as the primary partitioning unit
Finding Nearby Drivers:
- Convert rider’s location to an S2 cell ID
- Query the geospatial index for all drivers in that cell and neighbors
- Filter by distance, then compute road-network ETA for top candidates
- The matching algorithm selects the optimal driver
Why S2 over alternatives (Geohash, H3)?
- No edge-case distortion at poles or date line
- Hierarchical cells enable efficient range queries
- Cell IDs map naturally to distributed storage keys
- Better approximation of circular search areas
The geospatial index is sharded using Ringpop (consistent hashing) so each server owns a set of S2 cells, enabling horizontal scaling.
Dynamic Pricing (Surge)
Uber’s surge pricing balances supply and demand in real-time:
How Surge Works:
- The city is divided into geospatial zones (hexagonal cells)
- For each zone, compute the supply-demand ratio every few seconds
- When demand > supply, apply a surge multiplier (e.g., 1.5x, 2.0x)
- Higher prices incentivize more drivers to enter the zone
- As supply increases, surge naturally decreases
ML-Based Demand Forecasting:
- Uses historical data, weather, events, and time patterns
- Predicts demand spikes before they happen (concert ending, sports game)
- Pre-positions drivers in anticipated high-demand areas
Pricing Components:
- Base fare + per-minute rate + per-mile rate
- Surge multiplier applied to the total
- Minimum fare and booking fee
- Tolls, airport fees, and surcharges
The pricing service must be extremely fast (<50ms) since it’s called for every ride request.
Real-Time Trip Tracking
Once a trip is in progress, Uber tracks it in real-time:
Location Pipeline:
- Driver app sends GPS updates every 4 seconds
- Updates flow through Kafka to the Location Service
- Location Service updates the geospatial index and publishes to subscribers
- Rider app receives real-time driver position via WebSocket
State Machine: Each trip follows a strict state machine:
- REQUESTED → ACCEPTED → ARRIVING → IN_PROGRESS → COMPLETED
- At each transition, specific actions are triggered (notifications, fare updates)
Route Snapping: Raw GPS coordinates are “snapped” to the road network to:
- Accurately calculate distance traveled (for fare computation)
- Show smooth movement on the map
- Handle GPS jitter in urban canyons and tunnels
Uber processes millions of GPS events per second through this pipeline.
Architectural Tradeoffs
S2 Geometry for geospatial indexing
Pros
- +No distortion at edges unlike geohash
- +Hierarchical multi-resolution queries
- +Efficient consistent hashing integration
Cons
- −More complex than simple geohash
- −Requires custom tooling
- −Steep learning curve
Dynamic surge pricing
Pros
- +Balances supply and demand efficiently
- +Incentivizes driver availability
- +Optimizes platform economics
Cons
- −User perception issues during emergencies
- −Complex ML models required
- −Regulatory scrutiny
Event-driven architecture with Kafka
Pros
- +Decouples services effectively
- +Natural audit trail of all events
- +Supports real-time and batch processing
Cons
- −Eventually consistent by nature
- −Kafka operational complexity
- −Message ordering challenges at scale
Learn From Uber
Copy a learning context prompt for an AI assistant. It keeps assumptions visible and asks for tradeoffs, cost drivers, failure modes, and what to measure before adding complexity.