System design case study C10 · Saga · Geo

Design a Food Delivery App (Swiggy/Zomato-style)

Three parties, one order: a hungry customer, a busy restaurant and a delivery partner on a scooter. The system's job is to keep all three in sync for forty minutes.

What you'll be able to explain
  • Build restaurant discovery with geo filtering and availability
  • Drive the order lifecycle with a saga across services
  • Assign delivery partners with batching and ETA prediction
  • Handle peak-hour surges (dinner, festivals, cricket finals)
  • Keep menus and availability fresh

Scope

Functional

  • Discover restaurants that deliver to my location; browse menus; search dishes.
  • Cart, checkout, payment; restaurant accepts/rejects; partner assigned; live tracking; delivery.
  • Order history and status notifications.

Non-functional

  • Discovery p99 < 300 ms. Order placement highly available (it's the revenue path).
  • Accurate ETAs; no orders lost or charged twice.
  • 3× traffic spikes at lunch/dinner; 10× on big events.

Size

  • 5M orders/day, 70% within 4 peak hours → ~250 orders/s at peak.
  • Discovery: 50M sessions/day × 10 queries → ~6k/s avg, ~20k/s peak.
  • 300k active delivery partners × location every 5 s → 60k writes/s.

Services

CLIENTCustomer appNETWORKGatewaySERVICEDiscoverysearch + geoDATABASESearch indexrestaurants, dishesSERVICEOrder servicesaga orchestratorSERVICEPaymentsSERVICERestaurant svctablet appSERVICEAssignmentpartner dispatchCACHEPartner locationsgeo index1 authorize2 confirm3 assign partner
Service map for food delivery. Discovery is read-optimised; ordering is a saga.

The 30-second summary

Say it in the interview

"Discovery uses a search index with geo-shaped delivery zones and a fast serviceability cache. Ordering is an orchestrated saga: authorise payment, get restaurant acceptance, assign a partner timed to food readiness, capture on delivery, with compensations and timeouts at every step. Partner assignment batches nearby orders and uses prep-time and ETA predictions. During peaks we pre-scale, throttle overloaded kitchens and shed non-critical features."

Follow-up questions the interviewer may ask

  1. How do you batch two orders for one rider?
  2. How do you estimate delivery time at checkout?
  3. Restaurant menus change constantly. How do you keep search and listings fresh?
  4. How do you handle a dinner rush at 3× capacity?

Model answers to each of these are in the book.