How to use it
- Enter the current replicas and the metric’s current value, in the same unit as the target (percent for CPU utilisation, requests per second for a custom metric, and so on).
- Enter the target from the HPA spec, and its minReplicas and maxReplicas.
- Keep the tolerance at 10 % unless your cluster sets a different horizontal-pod-autoscaler-tolerance.
Formula
- ratio = current metric ÷ target
- If |ratio − 1| ≤ tolerance: desired = current (no scaling)
- Otherwise: desired = ceil(current replicas × ratio)
- Then desired is clamped to minReplicas … maxReplicas
Worked example
A deployment runs 4 pods at 90 % average CPU, the target is 60 %, limits 2…10:
- Ratio: 90 ÷ 60 = 1.5, outside the 10 % band.
- Unrounded: 4 × 1.5 = 6; desired replicas 6.
- Decision: Scale up; limit applied: None.
Tips
- Set maxReplicas with headroom. If the result often shows “Capped at maxReplicas”, pods stay overloaded; raise the limit or the node capacity.
- A lower target scales earlier. A 50 % CPU target leaves room for traffic spikes while new pods start; 80 % runs leaner but reacts later.
- Check requests first. If CPU requests are far from real use, utilisation figures mislead the autoscaler.