System design walkthrough · 11 min
Dinner rush: capacity for every peak
Every city orders dinner at once, and rain can double it in minutes. Start with a fixed fleet, try autoscaling, and end with capacity planned ahead plus a cache that protects checkout.
Seen in food delivery, grocery, ticketing and any app with daily or seasonal peaks.
The ask
What we are building
Orders arrive in waves: a lunch bump, a dinner peak in every city at once, and sudden spikes when it rains or a match ends. Keep ordering and checkout fast through all of it, without paying for dinner-sized capacity at 4 a.m.
- Checkout stays fast at the dinner peak.
- A sudden spike (rain, a match ending, a promotion) does not take checkout down.
- Capacity follows demand, so quiet hours stay cheap.
- When something has to give, it is the least important feature, not payments.
- Dinner peak vs quietest hour
- ~5×
- Rain or match spike
- +80% in 10 min
- New server ready in
- 3–5 min
- Checkout share of requests
- ~30%
Back of the envelope
How big is it?
Illustrative numbers. One food-ordering write-up (Caviar's) reports a dinner peak about 5 times its quietest load; the rest are round numbers to reason with.
| What | Working | Result |
|---|---|---|
| Lunch load | the baseline | 40,000 req/s |
| Dinner peak | 40,000 × 5 | 200,000 req/s |
| Rain on top of dinner | 200,000 × 1.8 | 360,000 req/s |
| Servers at dinner | 200,000 ÷ 500 req/s each, + 30% headroom | ~520 |
| Running that all day | 520 servers × 24 h, needed for ~3 h | idle ~21 h a day |
| Spike arrives in | rain starts → orders jump | ~10 minutes |
Build it, then break it
Your turn: design it first
Make the two calls yourself before reading on. The simulator runs your design at lunch, dinner, in the rain, and in a spike bigger than rain (the end of a big match while it pours).
Answer every question to run it.
Version 1
A fixed fleet, sized for an average day
Breaks · at the first dinner peak
Run enough servers for a normal lunch, all day. It is simple and cheap, and it works until the first dinner.
At 5× the servers cannot keep up. Requests queue, wait longer than the app will, and fail, checkout included, because nothing says which requests matter more. Sizing for dinner instead fixes it, at about five times the bill for the 21 hours it is not dinner, and still breaks the first time rain lands on top.
- Capacity
- lunch-sized
- Dinner load
- 5×
Try each load. Numbers are illustrative: a small simulation, not a measurement.
Why not…
Size it for the busiest dinner instead?
It survives an ordinary dinner and costs about five times as much, since the peak lasts a few hours. And the first rainy Friday is bigger than the busiest dinner you planned for.
Bigger servers instead of more of them?
One big machine has a hard ceiling and no spare when it fails. Peaks are better met by many small servers you can add and remove.
Go deeper:Queueing and utilisation
Version 2
Autoscale when the queue grows
Breaks · every sudden jump fails until new servers are up
Let the fleet follow demand: when requests start queuing, start more servers; when the queue stays empty, stop some. Scaling on the queue (how much work is waiting) reacts to the real problem, where CPU alone can look fine while requests wait.
The queue has to grow before anything happens, then new servers need 3 to 5 minutes to boot, load code and warm caches. Over an hour-long dinner ramp that delay hardly shows. When rain adds 80% within ten minutes, the queue overflows for most of the time it takes to notice and boot, and requests fail. Try each load button: every jump starts with a burst of red.
- Quiet hours
- cheap
- Reacts after
- queue + boot
- Sudden spike
- minutes of errors
Try each load. Numbers are illustrative: a small simulation, not a measurement.
Why not…
Scale on CPU instead of the queue?
CPU says how busy servers are, not how long requests wait. A fleet blocked on a slow database can show low CPU while every request times out.
Scale faster, with a lower trigger?
Helps, and costs more, since a hair trigger adds servers for every blip. It cannot beat boot time: a spike that lands in one minute still outruns servers that take three.
Go deeper:Autoscaling lag
Version 3
Scale ahead for dinner, shed what can wait
Holds · at 9× lunch, with checkout untouched
Dinner comes every evening. Forecast it from past weeks and start the capacity before it arrives, at 6:30 p.m. for a 7 p.m. peak. Keep autoscaling on top for what the forecast missed.
For real surprises, decide in advance what gives first. Split traffic by importance: checkout and payments first, live tracking next, then menus, search and recommendations. When servers are busy, browsing gets a cached or simpler answer (a menu a few minutes old, fewer recommendations) and checkout always finds a free slot.
The fleet now costs what each hour needs, the known peak is ready before it starts, and an unknown spike costs some freshness on menus instead of failed payments.
- Dinner capacity
- ready at 6:30
- Checkout in a spike
- protected
- Browsing in a spike
- from cache
Try each load. Numbers are illustrative: a small simulation, not a measurement.
Why not…
Queue every request and serve them in order?
A long queue serves requests whose users have already given up, so all of them fail late. Bounded queues, and shedding the work that matters least, keep the important requests fast.
Return errors for browsing instead of a cache?
Works, but an empty menu screen loses the order too. A slightly stale menu keeps people ordering while checkout stays fast.
Go deeper:Prioritised load sheddingBulkheads
Harden it
Rehearse the peak, and keep headroom for failure
Holds · through a lost zone and a retrying crowd
Load test in production, before the big days: drive more than the forecast through the real system and find which dependency gives first (often the database or a third party, not the servers you can add).
Rank every service by how critical it is and give each one its own pool of capacity, so a flood of recommendation requests cannot starve payments.
Keep headroom for losing a whole zone at the peak: if one of three data centres fails at 8 p.m., the other two must carry dinner. Cap retries, because a slow peak plus clients retrying is how a busy evening becomes an outage.
Go deeper:Retry storms across layersService won't recover after an outage
Putting it together
The final design
Three layers, from slowest to fastest: a forecast that starts known peaks early, autoscaling that follows what the forecast missed, and load shedding that protects checkout during the minutes nothing else can react.
Demand forecast
Predicts each hour's load per city from past weeks, holidays and weather.
Watch out: Misses surprises; it is the first layer, never the only one.
Scheduled scaling
Starts dinner capacity before dinner, from the forecast.
Watch out: Cloud capacity or quotas can run out on the biggest days: reserve or raise them early.
Autoscaler
Adds and removes servers as queues grow and shrink.
Watch out: Always minutes late for a sudden spike; scaling down too eagerly sets up the next spike.
Priority tiers
Checkout and payments first, then tracking, then menus, search and recommendations.
Watch out: If everything is marked critical, nothing is.
Load shedding
When busy, low-priority requests get a cached or simpler answer, or are refused quickly.
Watch out: Shedding too late (after the queue is full) protects nothing.
Bounded queues
Keep waiting work short so requests fail fast instead of late.
Watch out: An unbounded queue turns a short overload into a long outage.
Load tests
Push past the forecast before big days to find the real bottleneck.
Watch out: Testing a copy of production misses the shared database and third parties.
From boxes to an API
API and data model
Capacity planning shows up in the API as priorities and cacheability: which calls must always work, which can be served stale, and which can be refused quickly at the peak.
Endpoints
GET/v1/restaurants/{id}/menuCalled by Customer appCacheable for minutes with a version tag; under load it is served from the cache or a CDN, never queued behind checkout.GET/v1/homeCalled by Customer appOne screen-shaped call for the home feed; recommendations can be dropped or served stale when busy.POST/v1/ordersCalled by Customer appTop priority: checkout. Requires an Idempotency-Key header, so a retry at the peak never creates a second order.GET/v1/orders/{id}Called by Customer appOrder status; second priority, served from a replica or cache when the primary is busy.
Data
menus
Key:
(restaurant_id, menu_version)restaurant_id, menu_version, items, prices, updated_at
A new version on every change, so caches key on (restaurant, version) and never serve a half-updated menu.
orders
Key:
order_idorder_id, customer_id, restaurant_id, items, total, status, created_at
Checkout writes here; kept on the primary with headroom reserved for it at dinner.
idempotency_keys
Key:
(customer_id, key)customer_id, key, order_id, response, expires_at
Returns the first response to a repeated checkout instead of creating a second order.
capacity_plan
Key:
(city, hour)city, hour, forecast_orders, servers_scheduled
The forecast the scheduled scaling acts on, kept so each evening can be compared with what actually happened.
From their own write-ups
How real companies did it
Caviar's engineers describe lunch and dinner as their peaks, with peak load about 5 times their minimum, which made provisioning for the peak wasteful. They moved from scaling on response time to scaling on request queuing, polled every 30 seconds, adding servers when the queue stays backed up and always keeping at least three.
Square Engineering: Autoscaling based on request queuing (2017) ↗Wolt plans for two kinds of event: high-volume days such as New Year's Day, estimated from past years per customer, merchant and courier, and local flash crowds such as football matches. It load tests services in production with an in-house tool, ranks services in tiers by how critical they are, and builds in graceful degradation.
Wolt: How our engineering teams prepare for scalability events (2024) ↗AWS forecasts capacity and prefers to be over-provisioned as a buffer, because autoscaling alone does not react fast enough when a spike arrives faster than it can detect and respond. It uses load shedding, per service, API or resource, to keep a bad situation from getting worse.
AWS Builders' Library: Resilience lessons from the lunch rush (2025) ↗
In the interview
Follow-up questions
- The forecast said 200,000 requests a second and 300,000 arrive. Walk through the first ten minutes.
- Minute 0: queues grow and the autoscaler starts servers. Until they are ready, load shedding carries it: browsing falls back to cached menus and recommendations switch off, so checkout keeps its capacity. Minutes 3 to 5: new servers take traffic and shedding eases. Afterwards: find out why the forecast missed, and add that signal (weather, a match) to it.
- Why not just keep enough servers for the worst day all year?
- It costs several times as much for a peak that lasts hours, and you still do not know the worst day until it happens. Planned capacity for known peaks, autoscaling for drift and shedding for surprises cover more cases for less money.
- You can add servers in minutes, but the database cannot grow that fast. Now what?
- Protect it: cap connections per server so new servers do not open thousands more, cache reads, and move work that can wait (emails, analytics) onto queues processed later. Shedding has to happen before the database, since adding servers in front of a saturated database only makes it worse.
Your turn
Check yourself
Dinner arrives every evening at the same time. What is the best way to have capacity for it?
Rain doubles traffic in ten minutes and new servers take five to boot. What keeps checkout working meanwhile?
Why scale on the request queue rather than on CPU?
Related
Sources: Square Engineering: Autoscaling based on request queuing (2017) ↗ · Wolt: How our engineering teams prepare for scalability events (2024) ↗ · AWS Builders' Library: Resilience lessons from the lunch rush (2025) ↗ · Report a problem
A typical design, informed by public write-ups, not any one company's exact system. Diagrams are our own. Numbers are illustrative. All wording is original and paraphrases the linked sources.