Design a Ride Hailing Service
Drivers send their position every few seconds, and riders ask for a car close by. Each request must find nearby drivers, assign exactly one of them, and keep the rider updated as the car approaches. Arrival estimates come from an outside maps provider. When a concert lets out, demand in one small area explodes.
Constraints
- Updating a driver's position must take under 150 ms
- Roughly 30,000 position updates and ride requests arrive every second at the busiest time, most of them updates
- One driver is never matched to two riders
- Arrival estimates come from an external maps provider; a ride must still be matched without one
- Demand in one area can jump eight-fold for a few minutes
- Keep infrastructure under $22,000 a month
Scenarios to survive
Typical peak
Steady position updates with the usual number of ride requests.
Interviewer asks: Position updates and ride requests are different kinds of load on the same map. How do you keep one from hurting the other?
Evening rush (2x)
Traffic doubles across the city.
Interviewer asks: Which part of the location system hits its limit first, and what does adding nodes to it actually buy?
A concert lets out
In one area, ride requests jump eight-fold for a few minutes.
Interviewer asks: All the extra requests land on one small part of the map. How do you stop one hot area from overloading one node?
Maps provider outage
The external maps provider stops answering.
Interviewer asks: No arrival estimates. What do riders see, and does matching still work?
Estimates hang
Whatever runs arrival estimates becomes 12x slower.
Interviewer asks: Estimates hang instead of failing. Where do you cut them off?
What a good design must do
- Position updates meet the latency target at peak
- The evening rush passes
- Total monthly cost stays within $22,000
- Positions live in a geographic index
- Something matches riders to drivers, never twice
- The concert hot spot passes
- Matching keeps working when the maps provider is down
- A hung estimate does not slow matching
- The design explains how the map is split across nodes