Skip to content
Calcrivo

HPA Target Calculator

Calculate the desired replica count a Horizontal Pod Autoscaler will converge to given current utilization, target utilization and current replicas.

Inputs

%

Average CPU utilization currently observed across pods.

%

Target average utilization configured on the HPA.

pods

Number of replicas currently running.

pods

HPA minReplicas floor.

pods

HPA maxReplicas ceiling.

Desired Replicas

6pods

Change from Current

2pods

Projected Utilization at Desired

56.7%

Clamped by Max Replicas

false

Clamped by Min Replicas

false

Step by step

  1. Desired replicas: current × (current% / target%)

    4 × (85/60)

    = 5.67

  2. Round up to whole pods

    ceil(5.67)

    = 6

  3. Clamp to [min, max] replicas

    clamp(6, 2, 20)

    = 6

How it works

The Horizontal Pod Autoscaler computes desired replicas as desiredReplicas = ceil(currentReplicas × (currentMetricValue / desiredMetricValue)), then clamps the result to the configured minReplicas/maxReplicas range. This mirrors the exact formula the Kubernetes HPA controller uses for the resource-metric algorithm, letting you predict scaling behavior before it happens in the cluster.

Formula

desiredReplicas = clamp(ceil(currentReplicas × (currentCPU% / targetCPU%)), min, max)

R_c
Current replica count
U_c
Current CPU utilization percentage
U_t
Target CPU utilization percentage
R_{min}
HPA minimum replicas
R_{max}
HPA maximum replicas
D
Desired replica count

Frequently Asked Questions

Why did my HPA not scale even though utilization is above target?

The HPA has built-in stabilization windows and tolerance (default ±10%) to avoid thrashing — small deviations from target within that tolerance band do not trigger a scaling event.

What happens when the calculated replicas exceed maxReplicas?

The HPA clamps the desired count to maxReplicas and the pods will remain under-provisioned relative to the target utilization until you raise the ceiling or the load decreases.

Does this work for custom or external metrics?

The same ratio formula applies to any metric type the HPA supports (CPU, memory, custom metrics via adapters), as long as you're using the average utilization (Value) metric target type.

How do I choose a good target utilization?

Target below the level where response times start degrading, typically 50-70% for CPU, to leave headroom for scale-up delay while new pods start and pass readiness checks.

You might also need