Ride Sharing (Uber / Lyft)
Requirements: riders request rides; match with nearby available drivers in seconds; live location tracking; ETA & pricing; trip state machine.
Estimates: 1 M active drivers sending location every 4 s → 250k location updates/s.
driver app --loc every 4s--> location svc --> in-memory geo index (geohash/H3 cell -> drivers)
\-> Kafka (history, ETA models)
rider app -> request -> matching svc -> query nearby cells -> rank by ETA -> offer to driver
| (accept / timeout -> next)
v
trip svc (state machine: requested -> matched -> en route -> in trip -> done)
-> payments, notifications
Deep dives
- Geo index: geohash / Google S2 / Uber H3 cells; search the rider's cell + neighbours; keep it in memory (Redis GEO or custom), sharded by region/city.
- High write rate: location updates are ephemeral — keep only the latest in memory, stream history to Kafka.
- Matching consistency: lock a driver while offering (avoid double-assignment) with a short TTL.
- Surge pricing: supply/demand per cell computed in near-real time.