Matching riders with nearby drivers

A ride-hailing startup matches by scanning all drivers in a city. Design real-time matching that scales to many cities.

To design ride matching, keep the latest driver locations in memory partitioned by area, with a geospatial index so a search touches a few cells instead of every driver. Model ride offers as a state machine with a lease per driver, and partition by city for scale and failure isolation.

The system today: A ride-hailing startup runs in one city. Drivers send their location every few seconds and the server stores the latest in a table. To match a rider it scans every driver, computes distances, and picks the closest available one.

What has to change: Grow to 100 cities and 500,000 drivers sending a location every four seconds. Design the location pipeline and the matching: find nearby available drivers in under a second, avoid offering the same driver to two riders, and keep working if a server or a whole region fails.

Questions to ask first

Where the interviewer digs in

What a strong answer covers

Common mistakes