Scope
Functional
- Drivers share location while online. Riders request a ride with pickup/drop.
- Match a nearby available driver; driver accepts/declines.
- Live tracking during pickup and trip; fare estimate and final fare.
Non-functional
- Match within ~5 s (p95). Location freshness ~5 s.
- A driver is never assigned two trips at once; a trip never has two drivers.
- Highly available per city; one city's issue mustn't affect others.
Out of scope: payments (Case Study C12 of the book), ratings, pooling.
Size
- 2M online drivers at peak, update every 4 s → 500k location writes/s.
- 20M rides/day → ~230/s average, ~1,500/s peak requests.
- Location history: 500k/s × 50 B ≈ 2 TB/day (to cold storage).
APIs and data
Driver: PUT /v1/drivers/me/location {lat,lng,heading,ts} (or a persistent stream)
Rider: POST /v1/rides {pickup, drop, product} → {ride_id, status: MATCHING}
Driver: POST /v1/offers/{offer_id}/accept
Both: WS /v1/rides/{id}/live (driver position, ETA, status)- Driver state (in memory, per city shard): location, cell, status (AVAILABLE / OFFERED / ON_TRIP), vehicle type.
- Trips (sharded SQL by
city_id/ride_id): state, rider, driver, fares, timestamps.
The architecture
The 30-second summary
Say it in the interview
"Drivers stream locations through gateways into Kafka; per-city dispatchers keep an in-memory H3 index of available drivers. A ride request queries nearby cells, ranks by routing ETA, and offers to one driver at a time using a conditional status change with a timeout, so a driver can't be double-assigned. Trips are a validated state machine with events driving payments and notifications. Everything is partitioned by city for scale and blast-radius control."
Follow-up questions the interviewer may ask
- How do you prevent two riders getting the same driver?
- How does surge pricing work?
- How do you compute ETAs?
- What happens if the matching service in a city fails?
Model answers to each of these are in the book.