Design a ride-hailing service
“Design a ride-hailing service” is a system design interview question. Design the core of a ride-hailing service. A rider requests a ride from where they are, the service offers it to a nearby available driver, and once a driver accepts, each side sees the other’s location live until the trip ends. At peak there are 1 million active drivers, each sending a GPS update every 4 seconds, and 2,000 ride requests a second. A rider should be matched within a few seconds, and a driver must never hold two rides at once. Below is what to cover and 3 hints; press Practice and Dana, the interviewer, asks it out loud while you sketch the design.
Updated · By InterviewMind
Free in your browser, no account.
The problem
System design
Design the core of a ride-hailing service. A rider requests a ride from where they are, the service offers it to a nearby available driver, and once a driver accepts, each side sees the other’s location live until the trip ends.
At peak there are 1 million active drivers, each sending a GPS update every 4 seconds, and 2,000 ride requests a second. A rider should be matched within a few seconds, and a driver must never hold two rides at once.
Things to cover
- Storing driver locations and finding the nearest available ones
- The matching flow, from request to accepted ride
- Making sure a driver gets only one ride at a time
- Splitting the work by city or region, and what happens when one fails
Hints
Open one at a time, and try the question again after each.
Hint 1
Start with location updates: a million drivers every four seconds is 250,000 writes a second, each one replacing the last. Only the latest position matters, so keep it in memory rather than writing a database row per update.
Hint 2
The core is a geospatial index: divide the map into cells, with geohashes or a hexagon grid like H3, and keep the available drivers in each cell. A request searches its own cell and the ring around it.
Hint 3
The hard part is the match itself: two requests can pick the same driver in the same instant. Claim the driver with an atomic compare-and-set on their status, give each offer a timeout, and move on to another driver when it expires.
Practice it out loud
In the practice room Dana reads the question aloud in your browser’s own voice, with captions, and you answer in the editor beside it, in a design doc with the requirements filled in and a section for each part. It’s free and needs no account. Run the InterviewMind desktop app beside it and it hears the question the way it hears a real call, so you can see what it would show you in the live round.
Practice this question