System Design: Design DoorDash — Food Delivery, Restaurant Integration, Driver Dispatch, Order Tracking, Batching, ETA

DoorDash processes millions of food delivery orders daily, coordinating three parties: customers, restaurants, and drivers (Dashers). Designing a food delivery platform tests your understanding of real-time dispatch algorithms, multi-party coordination, ETA prediction, and marketplace dynamics. This guide covers the architecture from order placement through delivery completion.

Order Lifecycle

When a customer orders: (1) Order creation — the customer selects items from a restaurant menu, applies promotions, and confirms. The order service validates: restaurant is open, items are available, delivery address is within range, and payment method is valid. (2) Payment hold — pre-authorize the total amount on the customer card. Do not capture yet (the final amount may change with substitutions or tip adjustments). (3) Restaurant notification — push the order to the restaurant via tablet app, POS integration, or fax (legacy restaurants). The restaurant confirms and provides an estimated prep time. (4) Driver dispatch — the dispatch algorithm assigns an optimal driver (detailed below). (5) Prep tracking — the restaurant marks order stages: received, preparing, ready for pickup. (6) Driver pickup — the driver arrives at the restaurant, confirms pickup. Status: picked up. (7) Delivery — the driver navigates to the customer. Real-time GPS tracking shared with the customer. (8) Completion — driver confirms delivery (photo proof). Payment is captured. Tips are finalized. Both parties can rate each other. Each status change publishes an event to Kafka, consumed by: the notification service (push updates to customer), the tracking service (update real-time map), and the analytics pipeline.

Driver Dispatch Algorithm

The dispatch algorithm is the core competitive advantage. Goal: minimize total delivery time across all active orders while maximizing driver utilization. Algorithm: (1) When an order is ready for dispatch (restaurant confirmed, estimated pickup time calculated), the system finds available drivers. (2) Geographic search: Redis GEOSEARCH for drivers within radius of the restaurant (start 3 km, expand if needed). (3) ETA to restaurant: for each candidate, estimate arrival time using routing + traffic. (4) Scoring: each (order, driver) pair gets a score combining: driver ETA to restaurant (lower = better), driver current order load (already carrying an order? can this be batched?), driver acceptance rate and rating, and order priority (express orders, high-value orders, orders that have been waiting). (5) Global optimization: instead of greedily assigning the best driver per order, solve the assignment problem across all pending orders and available drivers simultaneously. This is a bipartite matching problem solved approximately with the Hungarian algorithm or linear programming. (6) Offer: the assigned driver receives the order with details and a time limit to accept (30 seconds). Decline cascades to the next best driver. Batch dispatch: accumulate orders for 30-60 seconds before running the optimization. This produces better global assignments than processing orders one at a time.

Order Batching (Stacked Deliveries)

A driver can carry multiple orders simultaneously (stacked delivery) if the pickup and delivery locations are geographically compatible. Batching increases driver earnings per hour and reduces delivery costs. Batching logic: before assigning a second order to a driver already en route: compute the detour distance and time. Check constraints: (1) The first order delivery ETA must not increase by more than 10 minutes. (2) The second order delivery ETA must be acceptable. (3) Both pickups should be from nearby restaurants (or the same restaurant). Route optimization with 2 pickups (P1, P2) and 2 deliveries (D1, D2): evaluate valid orderings (must pick up before delivering for each order): P1->P2->D1->D2, P1->P2->D2->D1, P1->D1->P2->D2. Select the minimum total time ordering. Customer transparency: when an order is batched, notify the customer: “Your driver has another pickup nearby. Your delivery may take a few extra minutes.” Some customers prefer no batching — offer a “priority delivery” option (no batching, at a higher fee). Driver perspective: batching increases earnings per trip. The driver sees both orders and the optimized route on their app.

ETA Prediction

Total delivery ETA = restaurant prep time + driver-to-restaurant time + restaurant-to-customer time. Restaurant prep time: an ML model predicts prep time based on: restaurant historical average, current order queue (number of active orders at the restaurant — from POS integration or order count), item complexity (pizza takes longer than salad), time of day and day of week, and special events. Model: gradient boosted trees trained on historical (order_placed, food_ready) timestamps. Accuracy target: within 3 minutes for 80% of orders. Driver travel time: routing API (Google Maps, Mapbox) with real-time traffic. For initial estimates before driver assignment: pre-computed travel time matrix (geohash-to-geohash, updated hourly from driver GPS traces). After driver assignment: recalculate every 30 seconds from driver real-time GPS. Display: show a range initially (25-35 min) and narrow to a specific time as the driver approaches. Under-promise, over-deliver: add a 2-3 minute buffer to the estimate. Late deliveries hurt customer satisfaction more than early deliveries help it. ETA updates: push updated ETAs via WebSocket whenever the estimate changes significantly (by more than 2 minutes). Frequent small updates are confusing; significant changes should be communicated.

Restaurant Integration

Restaurants interact with DoorDash via: (1) Tablet app — the most common. DoorDash provides a tablet that displays incoming orders, allows confirmation, prep time updates, and “order ready” marking. (2) POS integration — for large chains, DoorDash integrates directly with the restaurant POS system (Toast, Square, Olo). Orders appear in the POS like dine-in orders. Benefits: no separate tablet, automatic menu sync, real-time inventory (86ed items are automatically unavailable on DoorDash). (3) Middleware (Ordermark/Olo) — aggregates orders from multiple delivery platforms (DoorDash, UberEats, Grubhub) into one tablet or POS integration. Menu management: restaurants manage their DoorDash menu (items, prices, descriptions, photos, modifiers, availability). Menu data is stored in a catalog service. Changes propagate to the customer app within minutes. Menu prices on DoorDash are often higher than in-store (restaurants offset commission costs). Item availability: restaurants can mark items as temporarily unavailable (86ed). This updates the customer app immediately. For POS-integrated restaurants: inventory is synced automatically. Store hours and special closures: the restaurant sets operating hours. The platform respects these — the restaurant does not appear in search outside operating hours. Temporary closures (kitchen too busy) can be toggled in real-time.

{“@context”:”https://schema.org”,”@type”:”FAQPage”,”mainEntity”:[{“@type”:”Question”,”name”:”How does DoorDash driver dispatch algorithm work?”,”acceptedAnswer”:{“@type”:”Answer”,”text”:”The dispatch algorithm optimizes across all pending orders and available drivers simultaneously, not greedily per order. Steps: (1) Geographic search: Redis GEOSEARCH for drivers near the restaurant. (2) ETA computation: routing + traffic for each candidate. (3) Scoring: each (order, driver) pair scored by ETA to restaurant, current order load (can this be batched?), driver rating, and order priority. (4) Global optimization: bipartite matching across all pending orders and available drivers using Hungarian algorithm or linear programming. This produces better assignments than greedy per-order dispatch. (5) Batch dispatch: accumulate orders for 30-60 seconds before optimization, improving match quality. The assigned driver has 30 seconds to accept; decline cascades to the next best match.”}},{“@type”:”Question”,”name”:”How does order batching (stacked delivery) work?”,”acceptedAnswer”:{“@type”:”Answer”,”text”:”A driver carries multiple orders if pickup and delivery locations are geographically compatible. Before assigning a second order to an in-progress driver: compute detour distance/time, verify the first order ETA increase is under 10 minutes, and confirm both pickups are from nearby restaurants. Route optimization with 2 pickups (P1,P2) and 2 deliveries (D1,D2): evaluate valid orderings (must pick up before delivering each): P1->P2->D1->D2, P1->P2->D2->D1, P1->D1->P2->D2. Select minimum total time. Customer transparency: notify when batched — Your driver has another pickup nearby. Offer priority delivery (no batching) at a higher fee. Batching increases driver earnings per hour and reduces platform delivery costs.”}}]}
Scroll to Top