Design Uber ETA Prediction
On this page
Problem Description
In this interview, we're going to design the arrival-time predictions of a ride-hailing app, similar to the ETAs in Uber or Lyft. When a rider enters a destination, the app shows how soon a car can pick them up and how long the trip will take. When the rider requests a ride, the trips service asks how long each nearby driver would take to reach the pickup point, so it can send the one who will arrive first. During the trip, the rider sees the expected arrival time, which keeps updating as the car moves. After every trip, the system knows how long things really took and keeps learning from it. You can use existing building blocks: a routing engine that finds the best route between two points and adds up its time from the road speeds we give it, a location service that receives every online driver's GPS position every 4 seconds, and a trips service that matches riders with drivers, runs the app and records each trip.
Out of Scope
- Choosing which driver to send – the trips service decides; we only give it the times.
- Pricing – the pricing service uses our trip time; how it sets prices is its own interview.
- Building the map and the routing engine – given.
- Food delivery times – they add restaurant preparation time, a different problem; a good follow-up question.
- Turn-by-turn navigation for drivers – the driver app's own product.
Good Clarifying Questions
- How many predictions? – About 20 million trips a day. With riders browsing, dispatch asking about many drivers per request, and updates during trips, that's about 3 billion predictions a day, three times more at the evening peak. A dispatch request asks about up to 50 drivers at once.
- How fast? – One prediction under 100 ms at p99; a dispatch request for 50 drivers under 150 ms, because the rider is waiting for a match.
- How quickly must traffic changes show? – A crash or a sudden jam should affect ETAs within about 2 minutes. About 5 million drivers are online at peak, each sending a GPS position every 4 seconds.
- What matters more, average accuracy or the bad misses? – Both, but a car that arrives 8 minutes later than promised costs far more trust than one that's 2 minutes early.
- What if the prediction service fails? – Dispatch and the app depend on it, so it must always answer, even if less accurately.
Requirements
Functional Requirements
- Predict Pickup and Trip Times – For a pickup point and a destination, or a driver and a pickup point, the system returns the expected time in seconds; dispatch can ask about many drivers at once.
- Keep the Arrival Time Current – During a trip, the expected arrival time is updated every 30 seconds from the car's current position.
- Record Actual Times – The system records every prediction and how long the pickup and the trip really took.
- Keep Learning – The system trains a new model from these records every week and uses it only after it proves at least as accurate as the current one.
Non-Functional Requirements
- Scale – About 3B predictions a day: 35K/s on average, 100K/s at peak; 5M drivers send 1.25M GPS positions/s at peak.
- Latency – One prediction under 100 ms at p99; 50 drivers in one call under 150 ms.
- Freshness – A traffic change affects ETAs within 2 minutes; in-trip ETAs every 30 s; a new model every week.
- Availability – 99.99%. If the model or live traffic is down, the routing engine's own estimate answers; never an error.
Try it yourself first
You have the full problem. Sketch your answer, then sign up free to read the complete walkthrough.
- The complete design, flow by flow, with pictures
- Deep dives into the hard parts
- What mid, senior and staff candidates are expected to say
- Full company question lists
Free forever. No card needed.