kubernetes
Kubernetes Autoscaler Threshold Calculator
Calculate the right HPA (Horizontal Pod Autoscaler) CPU and memory thresholds for your Kubernetes workloads. Get absolute target values in millicores and MiB.
Related tool
K8s Cluster Cost
Calculate the monthly cost of running a self-managed Kubernetes cluster on Hetzner Cloud, Vultr, or DigitalOcean. Choose server types for control planes, workers, and load balancers with HA mode.
Kubernetes HPA Configuration Guide
The Horizontal Pod Autoscaler (HPA) automatically scales Deployment replicas based on CPU, memory, or custom metrics. Correct threshold configuration is critical — wrong values cause either constant scale-flapping or under-utilized pods.
HPA v2 Spec Example
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: my-app-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: my-app
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: AverageValue
averageValue: 350m # 70% of 500m limit
behavior:
scaleDown:
stabilizationWindowSeconds: 300Scaling Algorithm
desired_replicas = ceil(current_replicas × (current_metric / target_metric))If 3 pods average 700m CPU with a 350m target: ceil(3 × (700/350)) = 6 replicas.
Common Mistakes
- 1.Target on limits not requests: HPA
type: Utilizationtargets a % of _requests_, not limits. If your requests are lower than limits, you'll scale out sooner than expected. - 2.No stabilization window: Default scale-down is immediate — configure a stabilization window to prevent yo-yo scaling.
- 3.CPU limits too low: If your app regularly hits CPU limits (throttling), it will never trigger HPA scale-out — it just runs slow instead.
- 4.Max replicas too low: If maxReplicas is too small, HPA can't scale to meet demand. Monitor
kube_horizontalpodautoscaler_status_current_replicas == kube_horizontalpodautoscaler_spec_max_replicasfor this condition.
Worked example: HPA Thresholds
What the calculator returns for its default inputs — change any value in the form above to recalculate.
| Input | Value |
|---|---|
| CPU Request per Pod | 500 m |
| Target CPU Utilization | 70 % |
| Memory Request per Pod | 512 Mi |
| Target Memory Utilization | 80 % |
| Minimum Replicas | 2 |
| Maximum Replicas | 10 |
| Result | Value |
|---|---|
| HPA CPU target (absolute) | 350m |
| HPA memory target | 409 Mi |
| Scale-out threshold | > 385m CPU / pod |
| Scale-in threshold | < 315m CPU / pod |
| Replica range | 2 – 10 |
| Target utilization | 70% CPU / 80% RAM |
| CPU request per pod | 500m |
| Memory request per pod | 512 Mi |
How the calculation works
The Horizontal Pod Autoscaler compares the average usage of the pods with a target expressed as a percentage of the resource request (not the limit).
- ›CPU target (absolute) = CPU request × target utilization (500m × 70% = 350m).
- ›Memory target = memory request × target utilization.
- ›Scaling decision: desired replicas = ceil(current replicas × current usage ÷ target). With the default 10% tolerance, the HPA scales out when usage is above ~110% of the target and scales in below ~90%; in between nothing changes.
- ›Replicas always stay between the minimum and maximum you set.
Pods without a CPU request cannot be scaled on CPU utilization — the HPA reports the metric as unknown.
Key Terms
Full glossary →kubeadm
A tool for bootstrapping Kubernetes clusters. It automates the setup of control plane components and joining worker nodes, following Kubernetes best practices.
etcd
A distributed key-value store used by Kubernetes to store all cluster state and configuration. etcd is the single source of truth for the entire cluster.
cert-manager
A Kubernetes controller for automating TLS certificate management. cert-manager can issue certificates from Let's Encrypt, Vault, or internal CAs, and automatically renews them.
Helm
A package manager for Kubernetes. Helm charts bundle Kubernetes manifests into reusable packages with configurable values, versioned and published to chart repositories.
Frequently Asked Questions
What is the right CPU target for HPA?
70% is the standard production default. This gives 30% headroom between scale-out triggers, preventing constant flapping. If your app has very spiky load, use 60%. If load is predictable and gradual, 80% is acceptable.
Why does HPA use absolute millicores instead of percentage?
HPA v2 supports both: `type: Utilization` (percentage of request, not limit) and `type: AverageValue` (absolute millicores). The calculator outputs absolute values because they're more predictable — `type: Utilization` depends on your requests being set accurately.
Why is memory-based autoscaling less reliable than CPU-based?
Memory is not compressible — a pod using 400 Mi of a 512 Mi limit isn't 'using too much CPU', it's just holding memory. Many apps never release memory to the OS even when idle. This causes HPA to scale out unnecessarily. Use memory-based HPA only for apps with predictable memory growth patterns.
How do I prevent HPA scale flapping?
Set a stabilization window: `behavior.scaleDown.stabilizationWindowSeconds: 300` (5 minutes). This prevents rapid scale-in after a brief traffic drop. Also ensure your --horizontal-pod-autoscaler-sync-period (default 15s) and --horizontal-pod-autoscaler-downscale-stabilization (default 5m) are appropriate.
Related Tools
K8s Node Sizing
Calculate the right number and size of Kubernetes worker nodes for your workloads. Supports Hetzner Cloud and Vultr with verified pricing.
K8s Cluster Cost
Calculate the monthly cost of running a self-managed Kubernetes cluster on Hetzner Cloud, Vultr, or DigitalOcean. Choose server types for control planes, workers, and load balancers with HA mode.
Uptime SLA
Convert SLA percentages to real downtime. See exactly how many minutes of downtime 99.9%, 99.95%, and 99.99% actually allow per year, month, week, and day.
Resource Quota
Calculate namespace ResourceQuota values for your Kubernetes cluster. Set CPU and memory limits per namespace based on team size, pod count, and a safety buffer.
Related Guides
kubernetes
Kubernetes Cost Optimization: 12 Ways to Cut Your Cloud Bill
Twelve concrete techniques to reduce Kubernetes infrastructure costs — from right-sizing nodes and enabling HPA, to switching storage backends and choosing the right cloud provider.
kubernetes
CI/CD for Kubernetes with GitHub Actions: A Complete Guide (2026)
A practical walkthrough of building a full GitHub Actions pipeline that builds a container image, pushes it to a registry, and deploys to Kubernetes — with secrets handling, rollback, and Helm support.
kubernetes
ArgoCD vs Flux: Choosing a GitOps Tool for Kubernetes in 2026
A no-fluff comparison of ArgoCD and Flux for GitOps on Kubernetes — covering architecture, UI, Helm support, multi-tenancy, and when to pick each one.