Design ETA Prediction for Food Delivery and Ride-Hailing Apps
ML system design for delivery and ride ETA prediction: framing the label, real-time traffic and kitchen features, quantile losses and serving at scale.
The question: design the system that predicts delivery time for a food delivery app (or arrival time for a ride-hailing app). The estimate is shown before ordering, updated during the order, and used internally for dispatch and pricing. Customers punish late deliveries more than early ones, the inputs change by the minute, and the prediction is requested millions of times a day.
1. Clarify requirements
| Question | Answer |
|---|---|
| Which ETA? | Order-to-door time shown at checkout, then updated after the courier is assigned and picks up |
| Scale? | 10M orders per day; ETAs also computed for every restaurant shown in search (~50K requests per second) |
| Latency? | Under 50 ms per request; search pages need ETAs for 30-50 restaurants at once |
| Accuracy goal? | Most orders within ±5 minutes; avoid systematic lateness |
| Consumers? | Customers (displayed range), dispatch (courier timing), pricing |
2. Frame it as an ML problem
Regression on minutes. Decompose the journey so each part can use the right signals and be debugged on its own:
Because lateness hurts more than earliness, predict quantiles (P50 and P80/P90) with a quantile loss, or a distribution, rather than only a mean. Show the customer a range or a slightly conservative point.
3. Data
- Completed orders with timestamps for every stage: placed, confirmed, food ready (where known), courier arrived, picked up, delivered.
- Labels are clean and plentiful: actual durations, available within an hour.
- Food-ready time is often missing or noisy (restaurants tap late); infer it from courier wait times.
- Time-based splits; rolling backtests across weeks to capture weekly and holiday patterns. See training data.
4. Features
| Group | Examples | Freshness |
|---|---|---|
| Restaurant | Historical prep time by item and hour, current open orders (kitchen load), prep-time trend in last 30 min | Batch + seconds |
| Order | Number and types of items, order value | Request |
| Courier supply | Available couriers within 2 km, recent assignment delays | Seconds |
| Route | Road distance and routing-engine travel time, current traffic, weather | Minutes |
| Time | Hour, day of week, holiday, meal peak | Request |
| Location | Drop-off building type (apartment towers add minutes), parking difficulty | Batch |
Real-time kitchen load and courier supply come from stream processing into an online store; historical aggregates come from daily batch jobs. See feature engineering.
5. Model
- Baseline: routing-engine travel time + restaurant's average prep time for that hour.
- Gradient-boosted trees per stage with quantile loss: strong, fast and explainable.
- Deep model that learns from sequences (route segments, recent orders at the restaurant) and predicts the residual on top of the routing engine's estimate, a common approach in industry.
- Post-processing: add a buffer when uncertainty is high; clip to sensible bounds.
6. Architecture
Search ETAs : 50K req/s × 40 restaurants = 2M estimates/s → too many model calls;
cache per (restaurant, delivery area hexagon) for 60 s:
~200K open restaurants × ~20 nearby hexagons = 4M keys, mostly hot
Checkout : 10M orders/day ≈ 115/s avg; exact per-order prediction, no cache
In-flight : re-predict on each stage event and every ~2 min from courier GPS7. Evaluation
- Offline: MAE overall and per stage; percentage within ±5 minutes; lateness rate (actual > shown); quantile calibration (does the P90 cover 90% of orders?).
- Slices: peak vs off-peak, rain, new restaurants, large orders, cities.
- Online: customer complaints and refunds for lateness, conversion at checkout (pessimistic ETAs lose orders), dispatch efficiency.
- See ML evaluation.
ETA is a good place to show a business trade-off: an ETA that's too optimistic increases orders now but causes late deliveries and churn; one that's too pessimistic loses orders. The displayed quantile is a product decision tested online.
8. Monitoring
- Live error dashboards per city and stage; alert when lateness rises above a threshold for an area.
- Feature freshness of courier supply and kitchen load streams.
- Drift during events (storms, sports finals, holidays); fall back to a conservative buffer when inputs look abnormal.
Where it’s used
Prep-time and courier-time models drive the checkout ETA and dispatch timing.
Pickup ETA from driver supply and arrival ETA from routing plus a learned residual.
Parcel delivery windows predicted per stop from route plans and historical stop durations.
In an interview
- Decompose the ETA into stages, each with its own signals.
- Predict quantiles and explain the asymmetric cost of lateness.
- Use real-time kitchen and supply features from streams, and cache for search pages.
- Evaluate MAE, lateness rate and quantile coverage by slice.
Frequently asked questions
How do food delivery apps predict ETA?
They decompose delivery into stages such as preparation, courier travel to the restaurant, pickup wait and drive to the customer, and predict each with models using real-time kitchen load, courier supply and traffic features plus historical patterns.
Why predict quantiles for ETA?
Because lateness hurts more than earliness. Predicting a P50 and a P90 lets the product show a range or a slightly conservative estimate and measure whether the promised time is kept.
Further reading
- DeepETA: How Uber Predicts Arrival Times Using Deep LearningUber Engineering
- XGBoost: A Scalable Tree Boosting SystemChen and Guestrin, KDD 2016