Design a Ride-Sharing Service

HardGeoGeospatial IndexingReal-timeMatchingConsistencyAbout 45 minutes

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. 1. Requirements

    • How fresh does a driver's location need to be?
    • Is it acceptable to briefly show a stale position?
    Show a hint

    Separate the hot path (live locations) from the durable path (trips and payments).

  2. 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 hint

    Live locations change every few seconds; ask whether they need a database at all.

  3. 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 hint

    Divide the map into cells so a nearby search only looks at a few cells.

  4. 4. Scaling

    • How do you partition the location index?
    • What changes in a city with a sudden demand spike?
    Show a hint

    Cities are mostly independent, which suggests a natural partition key.

  5. 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 hint

    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