Skip to content
IT glossary
DevOps and cloudUpdated December 3, 2026

Autoscaling

Автомасштабирование

A service can automatically add capacity when demand rises and remove it when demand falls. This helps it handle busy periods without paying for peak capacity all the time.

Also known as: HPA

What changes when a service scales?

A video processing service might need only two workers overnight but ten after a batch of uploads arrives. Instead of having someone watch the queue and change the worker count, an autoscaler makes that adjustment according to a policy. Policies can react to measurements or add capacity ahead of predictable peaks on a schedule.

Horizontal scaling changes the number of instances. Vertical scaling changes the resources available to each instance, such as CPU or memory. Kubernetes' Horizontal Pod Autoscaler (HPA) is one implementation: it adjusts the desired replica count of a workload such as a Deployment. It does not resize the Pods or provision nodes to run them. If the cluster is out of room, node autoscaling is a separate job.

How an HPA makes a decision

The controller periodically reads a metric and compares it with a target. Suppose five ready replicas average 80% CPU utilization and the target is 50%. With complete metrics and no policy constraints, the proportional calculation gives ceil(5 × 80 / 50) = 8 desired replicas. In this configuration, utilization is measured relative to the containers' CPU requests, not their limits or the node's total CPU. The containers need CPU requests, and Kubernetes needs a source for resource metrics, such as Metrics Server.

The HPA updates the workload's desired replica count. That is not the same as adding serving capacity: the new Pods still need to be scheduled, start up, and pass readiness checks. A minimum replica count keeps some capacity ready for bursts; a maximum caps how far scaling can go. A scale-down stabilization window prevents a brief dip from triggering an immediate reduction.

Pick a signal that tracks the bottleneck

CPU is a useful signal for compute-heavy workers. For a job queue, backlog per worker or the age of the oldest waiting job may be more informative: CPU can stay low while workers wait on network calls and the backlog grows. Extra workers help only if the rest of the system can handle the added concurrency. If the database is already at its connection limit, adding workers may make the problem worse. Use a load test to check both the metric and how long new replicas take to become useful.

In an interview

A common follow-up is: "Traffic doubled, but latency stayed high even after the HPA scaled up. Why?" Distinguish desired replicas from ready replicas first. If Pods are pending, check scheduling events and node capacity. If the new replicas are ready and serving traffic, look for a bottleneck they cannot relieve, such as a saturated database. For a burst that ends before new Pods can start, keeping spare capacity or scaling ahead of time may work better than tuning the target.