Uploaded October 2026 | Updated November 2026, 5 days ago
Friday night, eight PM, dinner rush. Ten times the orders, and riders everywhere. Design a food delivery app like Swiggy or Zomato: where do you start?
System Design Interview, Day 004. Most candidates say "a restaurant service, an order service, a delivery service, and Kafka in the middle". That answer is where most candidates lose this round. Naming boxes isn't a design: the interviewer wants to hear which parts are hard and how you'll handle them.
Three hard parts: finding nearby restaurants, the order's state, and assigning the right rider.
- Fix 1: search by location. Split the city into cells (geohash), look at the user's cell and the cells around it, then filter by distance and delivery time. Menus are read a lot and change rarely, so cache them
- Fix 2: the order is a state machine: placed, confirmed, preparing, ready, picked up, delivered. Every update is check-and-set, the new state only if the old one is right. Payment carries an idempotency key, and the order is confirmed only when the payment succeeds
- Fix 3: rider locations live in memory. Say a ping every 4 seconds: not database rows, just the latest point in an in-memory geo index (like Redis GEO), history goes to a separate stream
- Fix 4: assignment. Free riders near the restaurant, ranked by distance and by when the food is ready, the offer goes to one rider with a timeout (say 15 seconds), and accepting marks the rider busy with check-and-set, so one rider never gets two orders
- Fix 5: live tracking. Push the rider's location to the customer over a WebSocket every few seconds; ETA = remaining cooking time + travel time
- The follow-up: Friday 8 PM, ten times the orders, what breaks first? Location writes. One lakh riders pinging every 4 seconds is 25,000 writes per second, so locations live in memory, split by city. Partition the orders database by city too (a Bengaluru order never meets a Delhi rider), and degrade gracefully: busy mode, longer ETAs, a smaller delivery radius, but the app never goes down
That's the answer that takes you to the next round: cell-based search, cached menus, an order state machine with check-and-set, rider locations in memory, assignment with timeouts, partition by city.
Next System Design Interview episode: design BookMyShow seat booking. Comment: what's the longest ETA you've seen in a dinner rush?
kgptalkie.com
#shorts #SystemDesign #SystemDesignInterview #FoodDelivery #Geohash #StateMachine #Idempotency #WebSocket #BackendInterview #InterviewPrep #SoftwareEngineering #KGPTalkie
Friday night, eight PM, dinner rush. Ten times the orders, and riders everywhere. Design a food delivery app like Swiggy or Zomato: where do you start?
System Design Interview, Day 004. Most candidates say "a restaurant service, an order service, a delivery service, and Kafka in the middle". That answer is where most candidates lose this round. Naming boxes isn't a design: the interviewer wants to hear which parts are hard and how you'll handle them.
Three hard parts: finding nearby restaurants, the order's state, and assigning the right rider.
- Fix 1: search by location. Split the city into cells (geohash), look at the user's cell and the cells around it, then filter by distance and delivery time. Menus are read a lot and change rarely, so cache them
- Fix 2: the order is a state machine: placed, confirmed, preparing, ready, picked up, delivered. Every update is check-and-set, the new state only if the old one is right. Payment carries an idempotency key, and the order is confirmed only when the payment succeeds
- Fix 3: rider locations live in memory. Say a ping every 4 seconds: not database rows, just the latest point in an in-memory geo index (like Redis GEO), history goes to a separate stream
- Fix 4: assignment. Free riders near the restaurant, ranked by distance and by when the food is ready, the offer goes to one rider with a timeout (say 15 seconds), and accepting marks the rider busy with check-and-set, so one rider never gets two orders
- Fix 5: live tracking. Push the rider's location to the customer over a WebSocket every few seconds; ETA = remaining cooking time + travel time
- The follow-up: Friday 8 PM, ten times the orders, what breaks first? Location writes. One lakh riders pinging every 4 seconds is 25,000 writes per second, so locations live in memory, split by city. Partition the orders database by city too (a Bengaluru order never meets a Delhi rider), and degrade gracefully: busy mode, longer ETAs, a smaller delivery radius, but the app never goes down
That's the answer that takes you to the next round: cell-based search, cached menus, an order state machine with check-and-set, rider locations in memory, assignment with timeouts, partition by city.
Next System Design Interview episode: design BookMyShow seat booking. Comment: what's the longest ETA you've seen in a dinner rush?
kgptalkie.com
#shorts #SystemDesign #SystemDesignInterview #FoodDelivery #Geohash #StateMachine #Idempotency #WebSocket #BackendInterview #InterviewPrep #SoftwareEngineering #KGPTalkie










