Design a Ride and Courier Matching
Design the part of a ride-hailing or food delivery app that finds a driver. A rider taps “Request” (or a restaurant marks an order ready), and within a few seconds the app should offer the job to a good nearby driver, wait for them to accept, and show the rider who is coming and when. Drivers send their position every few seconds while they are online, and riders see the cars around them on the map.
At peak there are 1 million drivers online across hundreds of cities and up to 2,000 new ride requests a second, with sharp spikes when a concert or a football match ends. What makes it hard is the mix: a firehose of 250,000 location updates a second that is worthless after a few seconds, a search that must look at the right drivers in milliseconds, and an assignment that must be exactly-once, since two riders must never be promised the same driver, all while drivers ignore offers, lose signal and drive through tunnels.
Good questions to ask first
Decide what you would assume for each before you look at ours.
- 1Rides, food delivery or both?
- 2How fresh must driver positions be?
- 3How fast must a match be?
- 4Can a driver refuse?
- 5Do we optimise for the rider or the whole city?
- 6Is pricing in scope?
- 7Shared rides or batched deliveries?
- 8Is one city ever bigger than one machine?
How to spend the 45 minutes
- 5minPart 1: Requirements and scope
- 5minPart 2: Estimates
- 5minPart 3: API
- 15minPart 4: Architecture, stage by stage
- 15minPart 5: Deep dives and trade-offs