Design Uber Eats (food delivery)
A three-sided marketplace: eaters, restaurants and couriers, each with their own app. The interesting parts are geo search over restaurants, an order state machine shared by three parties, and dispatching couriers so they arrive exactly when the food is ready.
Builds on these concepts
In one sentence
Search restaurants with geo filters, keep each order in a state machine that publishes events, and dispatch couriers by predicted readiness, not just distance.
A reference design: it covers what an app like this needs and follows how these companies have described their systems publicly, simplified to be learnable.
Requirements
Functional
- Find open restaurants that deliver to me
- Order, pay, track in real time
- Restaurants accept and mark orders ready
- Couriers get offers and deliver
Non-functional
- Menus and search: very read-heavy
- Orders and payments: correct and durable
- Updates in near real time for 3 parties
- Peaks at lunch and dinner
Back-of-the-envelope estimates
| Metric | Estimate |
|---|---|
| Orders | ~10M / day, with dinner peaks ≈ 400 orders/s |
| Menu views | ~50 per order → 20K reads/s: cache them |
| Order events | ~10 state changes per order → 4K events/s |
| Courier pings | 1M couriers every 5 s → 200K location writes/s |
API and data model
GET /restaurants?lat=…&lng=…&cuisine=… → [ restaurantCard ]
GET /restaurants/:id/menu → menu (cached)
POST /orders { restaurantId, items, address } → { orderId, eta }
POST /orders/:id/accept | /ready (restaurant)
POST /deliveries/:id/pickup | /dropoff (courier)
restaurants(id, name, location, delivery_radius, hours)
menu_items(id, restaurant_id, name, price, available)
orders(id, eater_id, restaurant_id, courier_id, status, total, city)Architecture
Step by step · Place an order
- 01Opens the app at home
- 02GET /restaurants?near=…
- 03Geo + open-now + cuisine filters
- 04Menu from cache
- 05Creates the order: placed
- 06Authorizes the card (not charged yet)
- 07Order and items saved in one transaction
- 08OrderPlaced published
- 09New order rings on the tablet
At this scale · 1M users
An event-driven order pipeline
- ▸Order service owns the state machine and publishes events
- ▸Search with geo filters (Elasticsearch): open restaurants that deliver to you
- ▸Courier dispatch times the pickup with the food being ready
Tap any box to see what it does.
Deep dive: dispatch is a timing problem
In ride hailing you want the closest driver now. In food delivery, a courier who arrives 10 minutes before the food is ready is wasted, and one who arrives late lets the food go cold. Dispatch combines predicted preparation time for that restaurant with predicted travel time and assigns the courier whose arrival matches.
- Events, not calls: the order service publishes
OrderPlaced,OrderReady,PickedUp; dispatch, notifications and analytics subscribe. Adding a new reaction doesn't touch the order service. - Batching: at scale, one courier picks up two orders from nearby restaurants going in the same direction.
- Payments: authorize at checkout, capture after delivery (tips and adjustments change the amount).
How it changes with scale
Step by step · Assign a courier
- 01Accepts: ready in ~15 min
- 02Assigns the nearest free courier
- 03Offer: pick up at 20:15
At this scale · 100 users
One app, three kinds of users
- ▸Eaters, restaurants (a tablet web app) and couriers use the same backend
- ▸Restaurants, menus and orders in PostgreSQL
- ▸Courier assignment: the nearest available one
Tap any box to see what it does.
| Users | What you run | Why it changes |
|---|---|---|
| 100 | Monolith + PostgreSQL, manual or nearest-courier assignment | One city, a handful of restaurants |
| 10K | Redis for menus, CDN for photos, push notifications worker | Menu reads dominate; status must update without refreshing |
| 1M | Search, order, dispatch services + Kafka events | Three apps and many teams need independent services |
| 100M+ | Sharded by city, ML ETAs, batched deliveries | Cities are independent; efficiency per delivery is the business |
Key takeaways
- 01Menus and search are read-heavy: cache and use a geo-aware search index.
- 02One service owns the order state machine; everyone else reacts to its events.
- 03Dispatch by predicted readiness and travel time, not distance alone.
- 04Shard by city: deliveries never cross cities.
Check your understanding
1 of 3
In a food delivery app like Uber Eats, who owns the order state machine?