The site falls over at peak
At a glance
Section titled “At a glance”| Aspect | Aspect |
|---|---|
| Typical organization | A retailer on sale days, a ticketing site, a tax or benefits portal near its deadline, or any product launch |
| Symptoms | Slow pages, then errors, at exactly the moment demand is highest |
| Root cause | Capacity sized for normal days, untested limits, and every request doing expensive work synchronously |
| Usual fix | Load test to find the limits, serve what you can from cache, queue what can wait, and protect the core with admission control |
| Patterns | Caching and CDN, queue-based load leveling, autoscaling, circuit breakers, a waiting room |
Sound familiar?
Section titled “Sound familiar?”- The biggest outage of the year happened on the biggest sales day of the year.
- Autoscaling added servers, but the database fell over anyway.
- One slow downstream service made every page slow.
- Nobody knows how many users the system can actually handle.
- Load tests, if any, ran against an environment much smaller than production.
Why it happens
Section titled “Why it happens”Systems are usually sized for an average day and tested, if at all, at a fraction of real peak. Under load, the weakest shared component, often the database, a payment provider or a session store, saturates first. Then retries and timeouts pile up, and the whole system slows together. Adding web servers rarely helps when the bottleneck is behind them.
Your options
Section titled “Your options”| Option | Helps with | Watch out for |
|---|---|---|
| Load testing at expected peak and beyond | Finding the real bottleneck before customers do | Needs production-like data and environment |
| CDN and caching | Pages and data that many users read | Stale data; cache invalidation |
| Queue-based load leveling | Work that doesn’t need to finish during the request, such as confirmation emails and order processing | The user needs a clear “we’re processing it” state |
| Autoscaling | Stateless tiers | Doesn’t fix the database or third parties; scaling takes minutes |
| Admission control and a waiting room | Demand far above capacity | Users wait, but the site stays up |
| Graceful degradation | Non-essential features under pressure | Needs feature flags and clear priorities |
A proven approach
Section titled “A proven approach”- Agree the peak. Use history and business forecasts to set a target, such as three times last year’s busiest hour.
- Load test until something breaks, and fix the first bottleneck, then test again. Repeat until you exceed the target with margin.
- Serve reads from the edge: static content and cacheable pages from a CDN, hot data from a cache.
- Move non-urgent work to queues, so the request path does only what the user must wait for.
- Protect the core: rate limits, circuit breakers on slow dependencies, and a waiting room for when demand still exceeds capacity.
- Rehearse the day, with dashboards, an incident plan and a list of features to switch off first.
- Static content and cacheable pages are served by the CDN.
- Requests that need the application pass through a waiting room.
- The waiting room admits only as many users as the system can handle.
- Hot data is read from a cache instead of the database.
- Work that can wait, such as emails and fulfillment, goes onto a queue.
- Workers drain the queue at a steady pace the database can sustain.
Trade-offs and what to watch
Section titled “Trade-offs and what to watch”- Caches serve stale data. Decide per page how stale is acceptable.
- Queues delay work. Users need to see that an order is accepted even if it isn’t processed yet.
- Waiting rooms frustrate people, but much less than errors and lost orders.
How you’ll know it worked
Section titled “How you’ll know it worked”The next peak passes with error rates and response times close to a normal day, and the load test results match what you saw in production.
Seen in the real world
Section titled “Seen in the real world”- HealthCare.gov launched without verifying that it met its performance requirements.
- Prime Video found its first design reached only about 5% of the expected load when measured.
- The failure library has several outages triggered by load.
Related on ArchitectureCompass
Section titled “Related on ArchitectureCompass”Written and edited by Abhinav Taduka, enterprise software architect.
New pages are added regularly. Follow Abhinav on LinkedIn to see them first.