Problems / Real world, hard
Uber as first shipped: no ETA cache, and the location, ETA and ride services, the geo index, its updaters and the notification workers at an eighth of their real size. 5,000 requests a second: 60% driver location pings, 30% ETA lookups, 10% ride requests. Half of all requests fail.
Unlock it once for 25 credits; everything inside it is free (runs, changes, Submit, results, hints). Sign in with Google to start; new accounts get free credits.
Grow it into the real architecture: every goal must hold at 5,000 requests a second. You may add components, connect them and resize anything.
Like a coding problem, a solution has to pass every case, not just the one it was built for. Submit in the lab runs all 6; 2 of them are hidden until then.
5,000 requests a second for 20 seconds: 60% locate (writes), 30% eta (reads), 10% ride (writes).
What each component does in this design, and what calls it. The simulator mimics each one from these settings.
| Component | Its job here | Settings |
|---|---|---|
| DDoS protectionDDoS protection | Traffic enters here.Calls API gateway.Volumetric floods are absorbed at the network edge, spread over many locations, before they reach you. | 100000 slots |
| API gatewayAPI gateway | DDoS protection forwards to it.Calls Location API, ETA API, Ride matching API.Gateways centralise auth, rate limits and routing so each service does not reimplement them. | 50000 slots · 1,200,000 calls/min |
| Location APIApp service | API gateway forwards to it for /locate.Calls Driver locations (Kafka) (publishes).Little's law: throughput ≈ concurrency ÷ latency. 200 slots at 50 ms serve about 4,000 req/s. | 1 replicas × 100 slots · timeout 1.0 s |
| Driver locations (Kafka)Event stream | Location API publishes to it.Calls Geo index updaters.Kafka keeps order only within a partition, so the partition key decides what stays in sequence. | 8 partitions · retention 600 s |
| Geo index updatersWorker | Driver locations (Kafka) consumes from it.Calls Geospatial index (H3 cells).Queues deliver at least once, so a worker can see the same message twice. | 16 concurrent jobs |
| Geospatial index (H3 cells)Geospatial index | Geo index updaters calls it. ETA API calls it for reads. Ride matching API calls it.Geo indexes split the map into cells, such as geohashes, to find nearby points fast. | 250 slots |
| ETA APIApp service | API gateway forwards to it for /eta.Calls Geospatial index (H3 cells).Little's law: throughput ≈ concurrency ÷ latency. 200 slots at 50 ms serve about 4,000 req/s. | 1 replicas × 100 slots · timeout 1.0 s |
| Ride matching APIApp service | API gateway forwards to it for /ride.Calls Geospatial index (H3 cells), Trips (Postgres, sharded by city), Notification jobs (publishes).Little's law: throughput ≈ concurrency ÷ latency. 200 slots at 50 ms serve about 4,000 req/s. | 1 replicas × 100 slots · timeout 3.0 s |
| Trips (Postgres, sharded by city)SQL database | Ride matching API calls it.Postgres runs one process per connection, which is why poolers like PgBouncer sit in front of busy databases. | 4 vCPU · 50 connections |
| Notification jobsMessage queue | Ride matching API publishes to it.Calls Notification workers.If a consumer does not finish within the visibility timeout, the message is delivered again. | – |
| Notification workersWorker | Notification jobs consumes from it.Calls Push to rider and driver.Queues deliver at least once, so a worker can see the same message twice. | 8 concurrent jobs |
| Push to rider and driverNotification service | Notification workers calls it.Email, SMS and push providers all throttle senders and can delay delivery. | 25 slots · 125,000 calls/min |