Medium · 12 steps · ~75 min
Design a food delivery app
Browse, order, track, all at dinner-time peak.
Restaurant lists are read constantly while orders are comparatively rare but must never be lost. Everything spikes at dinner.
Same problem as SwiggyZomatoDoorDash
How it works
- Browse: search and read restaurant menus.
- Order: record the order and notify the restaurant.
What you'll build
- The API and the data model for restaurants, orders and deliveries
- A system that answers 600 requests a second
- Cached menus within a budget
- A queue and workers that take orders through the dinner rush
- A CDN for a nationwide promotion and a limiter against scrapers
- A design that survives a cold cache, a lost worker and a lost primary
Steps
- 1Design the API
- 2Design the data model
- 3Handle 600 requests/sec
- 4Cache the menus for $900 a month
- 5Dinner rush: queue the orders at 25,000 requests/sec
- 6Friday night at 80,000 requests/sec for $2,200
- 7How do people find 'pizza near me'?
- 8Survive menu scrapers on $1,400
- 9Survive a cold menu cache
- 10Lose an order worker
- 11Lose the primary database
- 12Deep dive: tracking the courier live