Design Uber: location, matching, and trip service
Uber
Guided ModeStep 1 β Naive: Client β API β DB
Request Flow
Driver writes GPS
Driver app sends HTTP POST with lat/lng to the API Server every second. The API writes to the Database. 100K drivers Γ 1/s = 100K writes/second β already at the DB limit.
Rider requests ride
Rider opens app, taps 'Request Ride'. The API Server runs: SELECT * FROM drivers ORDER BY ST_Distance(pos, $rider_pos) LIMIT 5 β a full table scan on 100K rows, every request.
Why it breaks
At 300 requests/second each doing a full distance scan on 100,000 driver rows, the Database is overwhelmed in minutes. Two fundamental problems: too many writes AND too-slow spatial reads.
Why We Need This
The DB is doing two conflicting jobs: absorbing 100K location writes/second AND answering nearest-driver spatial queries. No general-purpose relational DB handles both at this scale.
Key Insight
The moment you have moving entities and spatial queries, you need dedicated spatial indexing β not a general-purpose database trying to do everything.
Step 1 of 8
