Loading...
Kubernetes' built-in mechanism for adding and removing pod copies as load changes.
Quick Definition
The Horizontal Pod Autoscaler (HPA) is a Kubernetes feature that automatically adjusts the number of pod replicas based on metrics like CPU or memory usage. It matches capacity to demand, improving both reliability under load and cost efficiency during quiet periods.
The Horizontal Pod Autoscaler, or HPA, is the Kubernetes component that automatically changes the number of pod replicas for a workload based on observed load, most commonly CPU utilization. Traffic rises, replicas increase; traffic falls, replicas shrink back toward a configured minimum.
HPA handles the application layer of a two-layer scaling story. More pods need somewhere to run, so cluster-level scaling, through a cluster autoscaler or Karpenter, adds and removes nodes underneath. Cost efficiency requires both layers tuned together: HPA alone cannot shrink the bill if nodes never scale down.
Example. A checkout service is set to scale between 3 and 30 replicas at 65 percent CPU. A lunchtime rush pushes it to 22 replicas; by mid-afternoon it is back to 6. Capacity follows customers instead of the worst-case estimate.
The classic mistake is targets so conservative that scaling never engages, leaving permanent peak capacity. Review actual utilization after launch. The Kubernetes Cost Management Guide and Kubernetes best practices cover tuning in detail.
CPU and memory by default, plus custom and external metrics such as queue depth or requests per second with additional setup.
HPA changes the number of pod copies. The Vertical Pod Autoscaler changes the CPU and memory size of each copy.
Pods scaled down but nodes did not. Pair HPA with cluster autoscaling so the machines you pay for shrink too.