"Autoscaling handles traffic spikes"
The claim
Section titled “The claim”“We’re on the cloud with autoscaling. If traffic spikes, we’ll just scale out.”
The counterexample
Section titled “The counterexample”A service runs 10 instances, each handling 100 requests per second, serving a normal 1,000 requests per second. A marketing push notification goes out at 7:00 p.m., and within a minute traffic reaches 5,000 requests per second. Autoscaling is configured on CPU.
| Assumption | Value |
|---|---|
| Normal load | 1,000 requests per second on 10 instances |
| Spike | 5,000 requests per second, reached in under a minute |
| Detection | Scaling reacts to the average CPU over the last 60 seconds |
| Provisioning | 90 seconds to start a new instance |
| Warm-up | 60 seconds before an instance passes health checks and runs at full speed |
| Database | Accepts at most 500 connections; each instance opens a pool of 20 |
The capacity gap. From the spike to new capacity serving traffic takes about 60 + 90 + 60 = 210 seconds. During that time demand exceeds capacity by 4,000 requests a second: about 840,000 requests that queue, time out or fail. For users, the spike is the outage. Autoscaling restores service afterward, which is little comfort if the push notification’s whole audience arrived in those three and a half minutes.
The moved bottleneck. To serve 5,000 requests a second, autoscaling grows the fleet to 50 instances. Each opens 20 database connections: 1,000 connections, against a database limit of 500. New instances can’t connect, fail their health checks and are replaced, while existing instances lose connections under the churn. Autoscaling turned a capacity problem in a stateless tier into an outage in the stateful one.
- Demand quintuples in under a minute; capacity stays the same.
- The autoscaler needs about 210 seconds to detect, start and warm up new instances.
- The scaled-out fleet asks for 1,000 database connections; the database allows 500.
Try it yourself
Section titled “Try it yourself”Change the spike, the instances kept running and the reaction time. The chart shows capacity catching up with demand; the gap between the lines is the requests that went unserved. The first scenario reproduces the example above.
The mechanism
Section titled “The mechanism”Autoscaling is a control loop with delay: measure, decide, provision, warm up. It works when demand changes more slowly than the loop reacts. When demand rises faster than the loop’s delay, the difference becomes queued or failed work, and no setting removes the delay entirely.
And autoscaling scales one tier. Every scaled tier still depends on tiers that don’t scale the same way: databases, connection limits, third-party rate limits, licenses. Scaling out a stateless tier pushes the load onto whatever stateful thing sits behind it.
When the claim holds
Section titled “When the claim holds”- Demand changes gradually, over many minutes, as with daily traffic curves.
- There’s enough headroom to absorb the first minutes of a rise while new capacity arrives.
- Known events are scaled in advance: scheduled scaling before a campaign, a sale or a television slot.
- Downstream limits scale too, or are protected: connection poolers, per-instance connection limits sized for the maximum fleet, quotas agreed with third parties.
- The service sheds load gracefully when demand exceeds capacity, instead of failing everything.
The better rule
Section titled “The better rule”Autoscaling follows demand; it can’t lead it. Keep headroom for the reaction time, pre-scale for known events, size downstream limits for the maximum fleet, and shed load when demand outruns capacity.
For educators
Section titled “For educators”Discussion question. Marketing tells you about the push notification the morning it goes out. What would you change today, in the next hour, and in the architecture over the next quarter?
Exercise. Keep the same spike. You’re allowed one change: either keep 20 instances running at all times, or cut the reaction time to 90 seconds with pre-warmed images. Which leaves fewer requests unserved in the first minutes? Ignore the database for this exercise.
Worked answer
20 instances always on: capacity is 2,000 requests a second, so the shortfall is 3,000 a second. With the original 210-second reaction, that’s about 630,000 requests. 90-second reaction from 10 instances: the shortfall is 4,000 a second for 90 seconds, about 360,000 requests. Faster reaction wins here. But the always-on headroom also helps against spikes nobody warned you about, and costs money every hour. Most teams combine both, plus load shedding, and revisit the database limit before either.
Seen in the real world
Section titled “Seen in the real world”- Google’s SRE book explains why overload must be handled by shedding load and degrading gracefully, not just by adding capacity: Handling overload (opens in a new tab).
- Amazon’s Builders’ Library describes load shedding to keep a service healthy when demand exceeds capacity: Using load shedding to avoid overload (opens in a new tab).
Related pages
Section titled “Related pages”Written and edited by Abhinav Taduka, enterprise software architect.
New pages are added regularly. Follow Abhinav on LinkedIn to see them first.