Home › Blog › Handling traffic spikes

Handling traffic spikes

The short answer: you cannot scale fast enough for a genuine spike, so the design question is not how to serve all of it but which part to serve and how to reject the rest cheaply. Systems that try to queue everything fail worse than systems that shed deliberately.

Why autoscaling is not the answer on its own

Autoscaling reacts on a loop measured in tens of seconds to minutes: metrics have to be scraped, a threshold crossed, instances provisioned, containers pulled, applications started, health checks passed. A spike that arrives in ten seconds is over, or has already taken the service down, before capacity arrives. Autoscaling handles growth and diurnal load well; it does not handle spikes.

Queueing versus shedding

A queue converts a load problem into a latency problem - which is right for work that can be done later, and wrong for work nobody will want by then. If requests arrive faster than you can serve them, an unbounded queue grows until every response is past the client's timeout: you then do the full amount of work and nobody receives any of it. This is the failure mode worth naming explicitly.

The sentence that signals experience: "rejecting a request has to be much cheaper than serving one, otherwise shedding becomes its own overload."

How to shed well

Degrading on purpose

The best spike responses reduce the cost of a request rather than refusing it. Serve a cached or slightly stale response instead of a fresh one. Drop personalisation and serve the generic page. Disable the expensive recommendation module and keep checkout. Each of these is a decision made calmly in advance and toggled under load - which is why a feature flag for the expensive path is worth more during an incident than another replica.

The caching mechanics are in Redis interview questions, and the rate-limiting primitive in design a rate limiter.

Where CoPilot Interview fits

Disclosure: we build an interview assistant, so treat this as a disclosed pitch. CoPilot Interview is a native Windows and macOS app that puts suggested answers on your own screen in about two seconds, across coding, system design and behavioral rounds, with a permanent free tier that needs no credit card.

Frequently asked questions

Why is autoscaling not enough for traffic spikes?

Its control loop takes tens of seconds to minutes - scrape metrics, cross a threshold, provision, pull images, start, pass health checks. A spike arriving in ten seconds is over or has already caused an outage before capacity appears. Autoscaling handles growth and daily cycles; headroom and shedding handle spikes.

Should you queue or shed excess traffic?

Queue work that is still valuable later and bound the queue; shed work that will be stale by the time you serve it. An unbounded queue is the worst outcome - you do all the work and every response arrives after the client's timeout, so nobody is served.

How do you shed load correctly?

Reject at the edge before the request consumes a worker or database connection, return 429 with Retry-After, prioritise so critical paths survive, and shed per tenant so one customer cannot exhaust the shared budget. Rejection must be far cheaper than service, or shedding becomes its own overload.

What does graceful degradation look like under load?

Reducing the cost of a request rather than refusing it: serving cached or slightly stale responses, dropping personalisation, and disabling expensive non-essential modules while preserving critical paths such as checkout. These are pre-planned toggles, which is why a feature flag is often worth more mid-incident than another replica.

Walk into the round with a second pair of eyes

CoPilot Interview is a native Windows and macOS app that puts suggested answers on your own screen in about two seconds, across coding, system design and behavioral rounds. The free tier is permanent: 15 minutes a day, no credit card.

Try it free