Design a Ride-Sharing Service
Design a ride-hailing service like Uber or Lyft. Riders request a ride from their location, the system matches them with a nearby available driver, and both see each other's live location until the trip ends. Plan for 20M daily rides across many cities, with drivers sending a location update every 4 seconds.
How the interview goes
Five phases, and questions the interviewer is likely to ask in each.
1. Requirements
- How fresh does a driver's location need to be?
- Is it acceptable to briefly show a stale position?
Show a hintHint
Separate the hot path (live locations) from the durable path (trips and payments).
2. High-level design
- Where do location updates go, and are they persisted?
- How does the rider's app learn the driver's position?
Show a hintHint
Live locations change every few seconds; ask whether they need a database at all.
3. Deep dive
- How do you find drivers within 2 km in milliseconds?
- How do you prevent two rides claiming the same driver?
Show a hintHint
Divide the map into cells so a nearby search only looks at a few cells.
4. Scaling
- How do you partition the location index?
- What changes in a city with a sudden demand spike?
Show a hintHint
Cities are mostly independent, which suggests a natural partition key.
5. Trade-offs
- Nearest driver versus best overall assignment: what would you choose?
- What would you give up to cut matching latency in half?
Show a hintHint
Think about what happens if a driver's phone goes offline mid-assignment.
Practice this with an AI interviewer
Write your design doc with live diagrams while the interviewer asks one question at a time and pushes on your choices. Get a scored debrief with what to study next.
Start this interview