Designing a Food Delivery Service Like Zomato / Uber Eats / DoorDash

Difficulty: Intermediate–Advanced · Prerequisites: Geospatial Indexing, Message Queues, and WebSockets


TL;DR

A food delivery platform connects customers, restaurants, and riders. The system handles search (Elasticsearch), ordering (Postgres), live rider tracking (Redis Geo + WebSocket), and dispatch matching (Temporal workflow).

💡 Elasticsearch is a search engine optimized for full-text search, filtering, and faceted queries. It indexes data in inverted indexes for sub-100ms search across millions of documents.

flowchart LR
    CUST["Customer App"]
    RIDER["Rider App"]
    SEARCH["Search<br/>Elasticsearch"]
    ORDER["Order Service"]
    LOC["Location<br/>Redis Geo"]
    MATCH["Dispatch<br/>Temporal"]
    WS["WebSocket<br/>live tracking"]

    CUST -->|"1. search"| SEARCH
    CUST -->|"2. place order"| ORDER
    RIDER -->|"3. GPS pings"| LOC
    ORDER -->|"4. assign rider"| MATCH
    MATCH -->|"5. write assignment"| LOC
    LOC -->|"6. stream position"| WS
    WS -->|"7. live map"| CUST

New components:

  • Search (Elasticsearch): Answers “biryani near me, pure veg, 4+ stars” in one query. It exists because the catalog question is text plus location plus filters, which a plain SQL WHERE cannot rank.
  • Order Service: Owns the order’s lifecycle and its money. Separate from search because it needs transactional correctness, not throughput.
  • Location (Redis Geo): Holds every rider’s current coordinates in memory. It exists because 200K riders pinging every few seconds is too much write traffic for the orders database.
  • Dispatch (Temporal): Runs the multi-step “offer to a rider, wait, try the next one” process. It exists because that process has to survive a server restart halfway through.
  • WebSocket gateway: Keeps one open connection per watching customer so rider positions can be pushed, not polled.

In 3 sentences: Customer searches for restaurants (Elasticsearch with geo + relevance scoring), places an order (Postgres with idempotency), and the system finds a nearby rider (Redis Geo for proximity, Temporal for the multi-step dispatch workflow). The rider’s live location streams to the customer via WebSocket. Each component is independently scalable.

💡 WebSocket is a persistent two-way connection. Unlike HTTP (ask → answer → done), WebSocket stays open so the server can push updates instantly. Learn more →


Understanding the Problem

🍔 What is Zomato? Zomato (known as Uber Eats or DoorDash in the US) is an on-demand food delivery platform that connects customers with nearby restaurants. Customers browse menus, place orders, pay, and watch their food travel from the restaurant to their door via a delivery partner.


Prior Art We’re Drawing From

  • DoorDash Dispatch - Builds assignment algorithms that balance delivery time, driver earnings, and restaurant readiness. Uses machine learning (ML) models for estimated time of arrival (ETA) prediction and dynamic batching. (DoorDash Engineering)
  • Uber Eats Marketplace - Three-sided marketplace (eaters, restaurants, couriers) with real-time dispatch using geospatial indexing. Open-sourced Cadence for workflow orchestration. (Uber Engineering)
  • Swiggy Search - Elasticsearch-based restaurant discovery with personalized ranking, geolocation filtering, and real-time availability. Handles 50K+ queries per second (QPS) during peak hours. (Swiggy Engineering)
  • Grab GrabNearby - Redis Geo for sub-10ms rider proximity queries across Southeast Asia. Location time to live (TTL) ensures stale drivers auto-expire. (Grab Engineering)
    💡 A TTL is an expiry stamp attached to a stored value. When it elapses the store deletes the value itself, so a rider who stops reporting disappears from the “available now” set with no cleanup job.

Functional Requirements

Core Requirements

  1. Customers should be able to search for nearby restaurants and browse their menus.
  2. Customers should be able to place an order and pay for it.
  3. The system should dispatch the order to an available delivery partner and let the customer track it in real time.

Below the line (out of scope)

  • Ratings and reviews for restaurants and riders
  • Promotions, coupons, loyalty programs
  • Scheduled / group orders
  • Restaurant onboarding and menu management tooling
  • Multi-restaurant carts

Non-Functional Requirements

Core Requirements

  • Low latency for search and order placement: search < 300 ms P95 (the latency 95% of requests beat), order placement < 1 s P95.
  • Strong consistency for order state and payment - no double charges, no two riders assigned to one order.
    💡 Strong consistency means every reader sees the latest write immediately. It matters here because an order’s status and a rider’s assignment are facts two services must never disagree about.
  • High throughput at peak - dinner rush in a metro can generate 100K+ orders/hour and 200K+ live rider GPS streams.
  • Real-time tracking - rider location visible to the customer within 2 seconds of each update.

Below the line

  • Fine-grained access control, General Data Protection Regulation (GDPR) / Digital Personal Data Protection (DPDP) compliance
    💡 GDPR in Europe and DPDP in India are data-protection laws. They constrain which personal fields you may keep and for how long, which in this design mostly bites on the rider location trail.
  • Disaster recovery with multi-region failover
  • Continuous integration / continuous deployment (CI/CD) and zero-downtime deploys
  • Full observability stack

Scale Estimation (Back-of-Envelope)

  • Users: 20M daily active users (DAU), 200K peak concurrent
    💡 Back-of-envelope estimation is rough arithmetic done before any design choice, so that each component is picked against a number rather than a feeling. Learn more →
  • Write QPS: ~50K rider location writes/sec (200K active riders × 1 ping every 4s during peak)
  • Read QPS: 20M DAU × ~10 searches/day ≈ 200M searches/day, which averages only ~2.3K/sec – but food delivery is savagely peaked around lunch and dinner. Assume 50K QPS at the worst minute and design for that.
  • Storage: ~500GB orders DB/year (100K orders/hour peak × order metadata)
  • Bandwidth: ~2 gigabits per second (Gbps) at peak (search responses + tracking WebSocket streams)