Cloud

Kubernetes Autoscaling Explained: HPA, VPA and Cluster Autoscaler Without the Guesswork

Understand pod and node autoscaling, resource requests, metrics and safe rollout practices for Kubernetes workloads.

Sunil Kumar5 min read
Cloud data network visualization representing Kubernetes infrastructure

Kubernetes autoscaling is not one feature. It is a set of controllers that respond to different signals: Horizontal Pod Autoscaler (HPA) changes replica counts, Vertical Pod Autoscaler (VPA) recommends or adjusts resource requests, and Cluster Autoscaler changes the number of nodes when pods cannot be scheduled or nodes are underused.

Start with accurate resource requests

HPA commonly uses CPU or memory utilization relative to pod requests. If requests are missing or unrealistic, the utilization signal becomes misleading. Profile the application under representative load, set requests from observed usage and define limits carefully. A container that is throttled by an overly low CPU limit may scale for the wrong reason.

Use HPA for changing demand

HPA is a good fit for stateless web services and queue workers. CPU is a useful starting signal, but request rate, queue depth or custom business metrics may better reflect demand. Set minimum and maximum replicas, stabilization windows and scale-up policies to avoid oscillation. Confirm that downstream databases and APIs can handle the extra concurrency.

Use VPA with an intentional update mode

VPA helps right-size requests based on observed resource consumption. Begin in recommendation mode and compare its suggestions with load-test data. Automatic updates may restart pods, so evaluate disruption budgets and application restart behavior before enabling them in production.

Connect pod scaling to node capacity

HPA can request more pods, but those pods still need schedulable capacity. Cluster Autoscaler can add nodes when pods remain pending due to resource constraints. Check node-pool limits, cloud quotas, topology spread, taints and persistent-volume constraints. Scale-down also needs care: workloads with local state or restrictive disruption budgets can prevent nodes from being removed.

Test the full chain

Run a load test that increases traffic gradually, observe HPA decisions, pending pods, node provisioning time and application latency. Then reduce load and verify that scale-down does not interrupt active work. Alert on pending pods, repeated restarts, exhausted node quotas and sustained throttling.

Takeaway: autoscaling works when application metrics, resource requests, scheduling and infrastructure capacity are designed together. Tune the complete feedback loop, not just the replica count.

Documentation: Kubernetes autoscaling — https://kubernetes.io/docs/concepts/workloads/autoscaling/

Establish requests and limits from observed behavior

Autoscaling decisions are only as useful as the resource data behind them. Measure the application under normal traffic, peak traffic and recovery conditions before setting CPU and memory requests. Requests influence scheduling and CPU-based HPA utilization, while limits can throttle or terminate workloads when configured poorly. A container with an unrealistically small request may appear permanently overloaded; an oversized request can prevent the scheduler from packing pods efficiently. Review metrics by workload and avoid copying resource values from a different service simply because it uses the same language or framework.

Select the metric that represents demand

CPU utilization is a reasonable starting point for compute-heavy services, but it may be a poor signal for queue consumers, event-driven jobs or services waiting on external APIs. A worker may need to scale on queue depth or oldest-message age, while an API may need request rate and latency. Custom metrics should be stable, documented and available to the autoscaling controller. Avoid scaling on a noisy metric that reacts to every short spike; use appropriate windows and stabilization behavior so the system responds to sustained demand without oscillating.

Coordinate pod and node capacity

HPA can increase the desired replica count, but additional pods still need nodes with enough allocatable CPU, memory and compatible topology. Cluster Autoscaler can request nodes when pods remain unschedulable, yet cloud quotas, subnet capacity, node-group limits and provisioning delays can prevent immediate scale-out. Set realistic maximum replica counts and make sure the cluster has a path to obtain capacity before traffic reaches its peak. Monitor pending pods and node provisioning time as first-class service signals rather than assuming a higher replica count means more running capacity.

Use disruption controls for safe scale-down

Scale-down can be as disruptive as scale-up. Configure readiness probes so traffic is removed from a pod before termination, and use termination grace periods that allow in-flight requests to finish. PodDisruptionBudgets can protect availability during voluntary disruptions, but overly strict budgets may prevent node drain and block cluster scale-down. Stateful workloads need additional care around volume attachment, leader election and quorum. Test node replacement and maintenance in a staging cluster to see how the application behaves when pods are moved under load.

Understand VPA operating modes

Vertical Pod Autoscaler can provide recommendations that help teams right-size resource requests. Begin by observing recommendations over a representative period, including peak and batch workloads. Automatic update modes may evict or restart pods to apply new values, so confirm that the deployment has enough replicas, disruption budgets and startup capacity. Do not allow a recommendation based on a brief low-traffic interval to reduce memory below the application’s real working set. Treat VPA as a data-driven advisor and introduce automatic changes only when restart behavior and rollback are understood.

Run load tests that exercise the full loop

Test a gradual increase in requests, a sudden burst, a slow dependency and a period of falling demand. Record how long HPA takes to add replicas, how long the cluster takes to add nodes and when latency returns to normal. Verify that the service does not overload its database as concurrency rises. Then test scale-down and confirm that capacity is removed without disrupting active users. These tests reveal whether the configured thresholds match the application’s startup time, cloud provisioning time and downstream limits.

Operate autoscaling with clear alerts

Alert on pods pending for too long, repeated restarts, sustained CPU throttling, memory pressure, node quota exhaustion and replica counts stuck at their maximum. Review HPA events and scheduler messages during incidents. Keep dashboards that show desired versus ready replicas, node capacity and application-level latency together. A scaling controller can be functioning correctly while the service remains unhealthy because the bottleneck is a database, cache or external API. Operational dashboards should help engineers identify that distinction quickly.

Document the scaling envelope

For each workload, record minimum and maximum replicas, target metrics, resource requests, node-pool limits, expected scale-up time and dependencies that may become bottlenecks. Revisit the envelope after major releases or traffic changes. A service that was stateless may acquire local caches or background state that changes how safely it can be moved. Autoscaling is a feedback-control system; reliable operation requires measured signals, bounded actions and a clear understanding of what the application can sustain.

Share this article

Written by

Sunil Kumar

Founder of FutureTechie and BoltPane. Writes clear explainers on AI, cybersecurity, gadgets and developer tools for curious readers who want signal over hype.

106 articles View profile

Get the tech briefing

AI, gadgets, software and cybersecurity — distilled into one short briefing every weekday.

Leave a Reply

Your email address will not be published. Required fields are marked *