UberDifficulty: Advanced
How Uber Works: Geospatial Querying & Dispatching
Uber's core challenge is matching riders with drivers in real-time while processing high-velocity GPS updates.
High-Level Architecture
[Driver App] -> (Location Update) -> [Kafka] -> [Dispatch System] <- (Request) <- [Rider App]Database Design
Schemaless (built on top of MySQL) and Cassandra for ride data. Redis for real-time location tracking.
Caching Strategy
In-memory stores keep the exact coordinates of active drivers, updating every 4 seconds.
Scaling & APIs
Scaling: H3 (a hexagonal hierarchical geospatial indexing system) divides the world into hex grids to quickly find nearby drivers without scanning the whole database.
API Design: WebSockets or Server-Sent Events (SSE) for real-time driver location updates to the rider.
Real-World Challenges
- •Handling network drops for drivers moving through tunnels.
- •Dynamic pricing (surge) calculation in real-time.
- •Resolving concurrent dispatch conflicts if two riders request the same driver.