System Design Lab›System Design Questions›Design Food Delivery (DoorDash)

Design Food Delivery (DoorDash)

MediumE-commercegeolocationmatchingreal-timepayments⬛ Uber

Question Overview

Design a three-sided marketplace connecting customers, restaurants, and couriers for on-demand food delivery. Key challenges include geo search for restaurants, a reliable order and payment flow, ingesting a constant stream of courier GPS updates, matching orders to couriers, and live tracking with ETAs.…

Sign up to see the full question and AI interviewer

Requirements

  • Browse and search restaurants that deliver to the customer's address, with live menus and hours
  • Place an order and pay exactly once, with the order moving through a clear status state machine
  • Dispatch each order to one available courier near the restaurant, timed to food preparation
  • Live courier location and ETA on the customer's map, updated every few seconds
  • Restaurant and courier apps to accept, prepare, pick up, and complete orders
  • Browse under 200 ms at p99 and 99.95% availability through lunch and dinner peaks

Back-of-the-envelope numbers

  • Orders: 10M/day ÷ 86,400 s ≈ 116/s average, ~350/s at 3× meal peak
  • Browse: 20 requests per order × 10M = 200M/day ÷ 86,400 s ≈ 2.3K QPS average, ~7K at peak, mostly cacheable
  • Courier GPS: 500K couriers ÷ 4 s = 125K location writes/s at peak, which belong in an in-memory geo index, not the order database
  • Location history: 250K average couriers ÷ 4 s ≈ 62.5K/s × 86,400 s ≈ 5.4B points/day × 100 B ≈ 540 GB/day, ~16 TB for 30 days
  • In-flight deliveries: 350 orders/s × 1,800 s (30 minutes) ≈ 630K at peak, served by 500K couriers with some batched orders
  • Live tracking: up to 630K watched orders ÷ 4 s update interval ≈ 160K pushes/s to customers at peak
  • Menus: 500K restaurants × 100 items × ~1 KB ≈ 50 GB, small enough to cache fully and index for search

Key components

  • Restaurant and menu service with a geo index (geohash or H3 cells, or Elasticsearch geo queries) filtered by delivery zone and hours, heavily cached
  • Order service: an order state machine in a relational database with idempotency keys; payment authorized at checkout and captured on completion
  • Courier location service that ingests GPS pings, keeps latest positions in an in-memory geo index such as Redis GEO, and streams history to Kafka
  • Dispatch service that batches pending orders per zone every few seconds and solves an assignment using distance, prep time, and batching
  • Offer protocol with timeouts: couriers get time-limited offers, and assignment is a conditional write so each order has exactly one courier
  • ETA service combining predicted prep time, routing-engine travel time, and historical data, recomputed as the courier moves
  • Tracking gateway pushing courier position and status to the customer's app over WebSocket or SSE, plus push notifications for key transitions

Common mistakes

  • Finding nearby couriers with latitude and longitude range scans on the relational database instead of an in-memory geospatial index
  • Writing every GPS ping to the transactional order database, adding 125K writes/s of short-lived data to the critical store
  • Assigning the closest courier the instant an order is placed, ignoring prep time, so couriers wait idle at restaurants
  • Assigning without an atomic compare-and-set, letting one courier receive conflicting orders or two couriers accept the same order
  • Charging the card on order placement without an idempotency key, so retries on flaky mobile networks double-charge
  • Treating menus as static, so customers order sold-out items or order from restaurants that are already overloaded

Likely follow-ups

  • How would you batch two orders from nearby restaurants onto one courier?
  • What happens if the assigned courier goes offline mid-delivery?
  • How would you handle a surge where orders far exceed available couriers in one area?
  • How would you estimate food preparation time for each restaurant?
  • How would you partition dispatch by geography, and handle orders near a region boundary?
  • How would you keep ETAs accurate as traffic and restaurant delays change?

No community solutions yet

Be the first to publish your solution

Practice ‘Design Food Delivery (DoorDash)’ with an AI Interviewer

Get scored feedback on your diagram, scalability approach, and trade-offs. Free while we grow — up to 3 full interviews a day.