Articles

What Is Autoscaling? Cloud Scaling Policies Explained

Autoscaling adds or removes compute capacity automatically as demand changes. How target tracking, step, scheduled, and predictive policies work.

Chisato Chisato · · 4 min read
Rows of server racks in a data center

Autoscaling is the practice of automatically adding or removing compute capacity — virtual machines, containers, or function instances — based on demand. Instead of provisioning enough servers for your busiest hour and paying for them all day, you define rules that grow the fleet when load rises and shrink it when load falls. Done well, autoscaling keeps an application responsive during spikes and cuts costs during quiet periods. Done poorly, it oscillates, scales too late, or quietly runs up a bill.

What gets scaled

Autoscaling almost always means horizontal scaling: changing the number of instances rather than the size of each one. Horizontal scaling can happen without downtime, while resizing a single machine usually requires a restart. Horizontal vs vertical scaling covers that distinction in depth.

Common targets include:

  • Groups of virtual machines behind a load balancer.
  • Container replicas in an orchestrator such as Kubernetes, where the Horizontal Pod Autoscaler adjusts replica counts and a separate cluster autoscaler adds nodes when pods don’t fit. See Kubernetes HPA vs VPA.
  • Serverless functions, where the platform scales instances per request with no configuration — but with trade-offs like cold starts.
  • Managed databases and queues that offer read-replica or throughput autoscaling.

The control loop

Every autoscaler runs the same basic loop:

  1. Measure a metric — CPU utilization, requests per second, queue depth, response latency.
  2. Compare it to a target or threshold.
  3. Decide how many instances are needed.
  4. Act by launching or terminating instances.
  5. Wait for the change to take effect, then repeat.

The details of steps 3 and 5 are where policies differ.

Types of scaling policies

PolicyHow it decidesStrengthsWeaknesses
Target trackingKeeps a metric near a set value (for example, 50% average CPU)Simple to configure; self-adjustingReactive; assumes the metric scales roughly linearly with load
Step scalingAdds or removes a set amount when a metric crosses thresholdsFine-grained control over large vs small spikesMore tuning; easy to misconfigure
ScheduledChanges capacity at fixed timesIdeal for known daily or weekly patternsDoesn’t react to unexpected load
PredictiveForecasts load from historical patterns and scales aheadCapacity is ready before the spike arrivesNeeds consistent history; can be wrong on unusual days

Many production setups combine them: scheduled or predictive scaling raises the baseline before expected peaks, and target tracking handles whatever the forecast missed.

Choosing the right metric

The metric should track the resource that actually limits your service.

  • CPU utilization works for compute-heavy services but misleads for I/O-bound ones, which can be overloaded while CPU sits low.
  • Requests per instance maps directly to load for stateless web services.
  • Queue depth or backlog per worker is usually best for background job processors: if the queue grows, add workers.
  • Latency is closest to what users feel, but it reacts late and can be driven by a slow dependency that more instances won’t fix.

A useful check: if doubling instances wouldn’t halve the metric, it’s probably the wrong one to scale on.

Cooldowns, warm-up, and flapping

New instances aren’t useful the moment they launch. They need to boot, pull code or images, warm caches, and pass health checks — the liveness and readiness probes in Kubernetes terms. If the autoscaler measures again before the new capacity is serving, it sees the same high metric and adds even more instances.

Cooldown or stabilization windows prevent that by pausing further scaling decisions for a period after each action. They also prevent flapping, where the fleet repeatedly scales up and down around a threshold. A common pattern is to scale out quickly and scale in slowly: adding capacity late hurts users, while removing it late only costs a little money.

Minimums, maximums, and safety rails

Every autoscaling group should define:

  • A minimum that keeps enough capacity for baseline traffic and survives the loss of an instance or availability zone.
  • A maximum that caps cost and protects downstream systems. If your service scales to hundreds of instances but your database can only accept a fixed number of connections, unlimited scaling turns a traffic spike into a database outage.
  • Graceful scale-in. Instances chosen for termination should stop accepting new work and finish in-flight requests first — see graceful shutdown explained.

Requirements for scaling well

Autoscaling only works if the application can tolerate instances appearing and disappearing:

  • Stateless instances. Sessions, uploads, and caches that must survive belong in shared stores, not on local disk.
  • Fast startup. Smaller images and lighter initialization shorten the gap between a spike and new capacity.
  • Health checks that mean something. An instance that passes checks but can’t serve requests will receive traffic anyway.
  • Observability. You can’t tune a policy you can’t see; scaling events, metric values, and latency belong on the same dashboard. What is observability covers the foundations.

Cost considerations

Autoscaling saves money mainly when demand varies. A flat workload gains little. Scaling on interruptible capacity such as spot instances can cut costs further for fault-tolerant workloads — see the AWS spot instances tutorial. Tracking the results belongs to the broader discipline of FinOps.

The takeaway

Autoscaling is a feedback loop that adjusts instance counts to match demand. Target tracking is the simplest starting point, scheduled and predictive policies get ahead of known peaks, and step scaling offers fine control. Pick a metric that truly reflects your bottleneck, scale out fast and in slowly, set sane minimums and maximums, and make sure your application is stateless and starts quickly enough for new capacity to matter.

Chisato Chisato · · 5 min read

What Is an Error Budget? SLOs Turned Into a Policy

An error budget is the unreliability an SLO allows, such as 0.1% of requests for a 99.9% target. How to calculate it, track burn rate, and act on it.

#DevOps #Cloud #Infrastructure
Chisato Chisato · · 4 min read

What Is a Cloud Landing Zone?

A cloud landing zone is a pre-configured, secure baseline environment for provisioning new cloud accounts and workloads at scale. How it works.

#Cloud #DevOps #Infrastructure