Services

Resources

Company

/

Horizontal Pod Autoscaler

HPA (Horizontal Pod Autoscaler)

A Horizontal Pod Autoscaler (HPA) is a Kubernetes controller that changes the number of pod replicas in a Deployment or StatefulSet based on a metric. You set a target, such as 60% average CPU utilization, and the HPA adds pods when load rises and removes them when it falls. It scales out, not up.

How it works

Every 15 seconds by default, the controller reads the metric and computes desiredReplicas = ceil(currentReplicas x currentValue / targetValue). With 4 pods at 90% CPU and a 60% target, it asks for ceil(4 x 90 / 60) = 6 pods. CPU utilization is measured against each pod's resource request, so pods without requests cannot scale on CPU. Scale down waits through a 5 minute stabilization window by default to avoid flapping. Custom and external metrics, such as queue depth, work through a metrics adapter.

Why it matters in production

The HPA turns traffic peaks into extra replicas without a human in the loop. It only works if new pods start fast and the cluster has room for them, so it is usually paired with a cluster autoscaler. Wrong requests or a slow image make it react late.

See also

On the One2N blog

Further reading

Diagram of the Horizontal Pod Autoscaler formula: desired = ceil(pods x CPU ÷ target), worked as ceil(4 x 90% ÷ 60%) = 6. On the left, four pods are filled to 90% CPU; every 15 seconds the controller checks, and on the right six pods sit at the 60% target line. In red, a pod with no CPU request is marked with a question mark: the HPA cannot scale it on CPU.

Putting this into practice?

Talk to One2N about our platform engineering services

Talk to One2N about our platform engineering services