Kubernetes Autoscaling Guide: Choose and Tune HPA, VPA, and KEDA for Production Workloads
KubernetesAutoscalingHPAVPAKEDAPerformance

Kubernetes Autoscaling Guide: Choose and Tune HPA, VPA, and KEDA for Production Workloads

DDeployed Cloud Editorial Team
2026-11-16
9 min read

Compare HPA, VPA, and KEDA, then use a production checklist to configure metrics, limits, load tests, and safer Kubernetes scaling.

Kubernetes autoscaling is safest when it starts with workload behavior, not a favorite tool. This guide compares HPA, VPA, and KEDA, then provides a reusable production checklist for selecting metrics, setting resource requests, testing scale behavior, and diagnosing slow or unstable scaling.

Overview

Kubernetes autoscaling changes compute capacity in response to observed demand. The objective is not simply to add replicas or increase CPU and memory. A useful autoscaling design keeps service-level objectives within their target while avoiding unnecessary cost, queue buildup, resource contention, and rapid oscillation.

The three common approaches solve different problems:

  • Horizontal Pod Autoscaler (HPA) changes the number of pod replicas. It is a strong default for stateless services whose demand can be represented by CPU, memory, or a custom metric such as requests per second.
  • Vertical Pod Autoscaler (VPA) recommends or changes the CPU and memory requests and limits assigned to pods. It is useful when workload sizing is difficult to estimate or when each replica needs more resources rather than more copies.
  • KEDA scales workloads from event-driven signals, such as queue depth, stream lag, scheduled activity, or an external metric. It can also scale workloads down to zero when the event source supports that operating model.

These tools are not interchangeable. HPA answers, “How many instances should run?” VPA answers, “How much resource should each instance receive?” KEDA answers, “How many instances are needed to process the current event workload?” Some combinations are appropriate, but overlapping controllers must be designed carefully. For example, independently allowing HPA and VPA to react to the same CPU pressure can produce conflicting behavior.

Decision matrix

Workload signal or needPreferred methodWhyImportant caution
CPU or memory pressure varies across identical web replicasHPAAdd or remove replicas as demand changes.Requests must be realistic, and CPU utilization alone may not reflect user-facing latency.
Queue depth, event count, or consumer lag drives workKEDAScale from the signal that represents unfinished work.Define authentication, polling, cooldown, and failure behavior for the event source.
One replica needs more or less CPU and memory over timeVPAAdjust sizing based on observed resource consumption.Updates may restart pods depending on the selected update mode.
Workload is idle between eventsKEDA, potentially with scale-to-zeroReduce idle capacity while retaining event-driven activation.Account for cold-start time and the availability requirements of the consumer.
Stateful or tightly coupled applicationCase-specific; start with a manual baselineScaling may require partitioning, leader election, or storage coordination.Validate application semantics before changing replica counts automatically.

Checklist by scenario

Scenario 1: A stateless HTTP service needs more capacity

  1. Define the outcome to protect: latency, error rate, request throughput, or another service objective.
  2. Confirm that the deployment has accurate CPU and memory requests. HPA utilization is interpreted relative to requests, so an inflated request can make utilization look low and delay scaling.
  3. Verify that the cluster exposes the metrics required by the selected HPA configuration. A metrics server commonly supplies resource metrics; custom and external metrics require an additional metrics pipeline.
  4. Set a sensible minimum replica count for availability and a maximum that the downstream systems can tolerate.
  5. Choose a target that leaves enough headroom for traffic bursts. Treat the target as a starting point, then validate it with a representative load test.
  6. Configure scale-up and scale-down behavior separately. Fast scale-up can protect latency, while a stabilization window or slower scale-down can reduce churn.

A minimal HPA using a resource metric may look like this. Confirm the supported API version and fields against the Kubernetes version running in the target cluster before applying it.

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: web
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: web
  minReplicas: 3
  maxReplicas: 20
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 65
  behavior:
    scaleUp:
      stabilizationWindowSeconds: 0
    scaleDown:
      stabilizationWindowSeconds: 300

Scenario 2: A queue consumer must keep lag under control

  1. Use queue depth, oldest-message age, or consumer lag rather than CPU unless CPU is genuinely the limiting signal.
  2. Measure how much work one replica completes during normal and peak conditions.
  3. Set a minimum replica count based on availability and a maximum based on broker limits, database capacity, downstream rate limits, and the cost of concurrent work.
  4. Decide whether a zero-replica idle state is acceptable. If activation takes longer than the queue’s tolerance, retain a warm minimum.
  5. Configure polling intervals, cooldown behavior, failure handling, and trigger authentication. Keep credentials in a supported secret mechanism rather than embedding them in application manifests.
  6. Test what happens when the event source is unavailable. A scaler should not silently interpret a metrics failure as an empty queue.

KEDA is often a good fit for this pattern because it connects a workload to an event source through a scaler and can create or manage an HPA-like scaling path. The exact trigger fields and supported integrations vary by KEDA release and event source, so pin and review the version used by the platform team.

Scenario 3: Resource requests are uncertain

  1. Collect CPU, memory, restart, throttling, and out-of-memory data across representative traffic periods.
  2. Separate normal usage from initialization, batch processing, cache warming, and unusual incident behavior.
  3. Use VPA in recommendation mode first when the team needs sizing advice without automatic pod updates.
  4. Review recommendations against node sizes, disruption budgets, startup time, and application limits.
  5. If automatic updates are enabled, test eviction and restart behavior. Ensure the workload can tolerate a pod being replaced and that its rollout strategy preserves availability.

VPA and HPA can coexist when they act on different dimensions and use compatible signals. A common pattern is to let VPA recommend CPU and memory requests while HPA scales replicas from a workload metric such as requests per second. Avoid using both controllers to make independent decisions from the same resource pressure without testing the feedback loop.

Scenario 4: A batch or scheduled workload has predictable bursts

  1. Establish the arrival schedule and the maximum acceptable completion time.
  2. Compare scheduled pre-scaling with reactive scaling. Pre-scaling may be more reliable when the demand window is known.
  3. Use a queue or job metric when work can accumulate, and ensure retries are idempotent.
  4. Set a maximum that protects shared cluster and service capacity.
  5. Load-test the complete path, including job creation, scheduling delay, image pulls, application startup, processing, and shutdown.

Implementation and load-test workflow

Use the following sequence whenever a workload is onboarded or its traffic pattern changes:

  1. Describe the demand. Record whether demand is request-based, resource-based, event-based, scheduled, or a mixture. Identify the metric closest to unfinished work or user impact.
  2. Set resource requests and limits. Requests influence scheduling and resource-utilization calculations. Limits can protect the node, but overly restrictive CPU limits may introduce throttling that distorts test results.
  3. Verify the metrics path. Check that the metrics provider, adapter, permissions, custom resource, and scaler are healthy. Confirm that the metric has recent samples and the expected label dimensions.
  4. Choose bounds. Select minimum and maximum replicas from availability, capacity, and dependency constraints—not from an arbitrary round number.
  5. Apply conservative behavior. Prefer predictable scale-up and a stabilized scale-down until real traffic confirms the settings. Include a pod disruption budget where appropriate, but do not use one that makes legitimate scaling or maintenance impossible.
  6. Run a baseline test. Measure latency, errors, throughput, queue lag, replica count, pod startup time, CPU, memory, throttling, and node pressure without autoscaling changes.
  7. Run a step test. Increase load in stages, hold each stage long enough for metrics and scheduling to respond, then reduce load gradually. Record the time from threshold crossing to new capacity becoming ready.
  8. Run a burst and recovery test. Send a short spike followed by normal traffic. Confirm that scale-up protects the service and scale-down does not remove capacity before the workload has recovered.
  9. Test failure paths. Temporarily simulate missing metrics, a slow dependency, an unavailable queue, pending pods, and node pressure in a non-production environment. Verify alerts and the controller’s resulting behavior.

Keep the test workload representative. A synthetic CPU loop can validate a basic HPA reaction, but it cannot prove that request rate, queue lag, database connections, or application latency will scale correctly.

What to double-check

  • API and component compatibility: Confirm the autoscaling API, Kubernetes release, metrics server, custom metrics adapter, VPA components, and KEDA release are compatible. Recheck this after a cluster or operator upgrade.
  • Metric meaning: Determine whether a metric is an average, sum, rate, instantaneous value, or lag measurement. A mathematically valid metric can still be a poor scaling signal.
  • Startup delay: Include image-pull time, initialization, readiness checks, cache warming, and connection establishment in scale-up expectations.
  • Dependency capacity: More replicas can increase database connections, cache traffic, API calls, and message consumption. Set limits or use a metric that prevents the scaler from overwhelming a dependency.
  • Requests versus limits: A request that is too low can cause noisy utilization and scheduling pressure. A request that is too high can suppress HPA utilization and waste capacity.
  • Observability: Alert on sustained maximum replicas, unavailable metrics, pending pods, queue age, failed activations, repeated evictions, and a mismatch between desired and ready replicas. An OpenTelemetry-based observability design can help connect scaling events with application latency and errors; see the OpenTelemetry setup guide.
  • Deployment interaction: Rolling updates, canary releases, and autoscaling may temporarily increase total pods. Review surge settings and capacity headroom using the Kubernetes deployment best practices checklist.

Common mistakes

SymptomLikely causesChecks and corrective actions
Scale-up is slowLong sampling interval, missing metrics, slow pod startup, low maximum replicas, or insufficient node capacity.Inspect controller events and metric timestamps, measure readiness time, check pending pods and cluster capacity, then adjust the bottleneck rather than only lowering the target.
Replicas flap up and downTarget is too close to normal variation, the metric is noisy, scale-down has no stabilization, or multiple controllers are competing.Use a steadier metric, add scale-down stabilization, review rate limits, and ensure only one controller owns each scaling decision.
Metrics are unsatisfied or unavailableProvider failure, incorrect labels, missing permissions, unsupported metric type, or a stale external integration.Inspect the autoscaler status and events, query the metric directly, verify adapters and credentials, and confirm the metric contract after upgrades.
HPA stays at minimum replicas during high trafficCPU requests are inflated, CPU is not the bottleneck, or the selected metric does not represent demand.Compare utilization with latency, throughput, and queue data. Consider a custom or external metric and revisit requests.
VPA causes disruptionAutomatic updates require pod replacement, or recommendations exceed available node capacity.Start with recommendation mode, review update policy, use disruption controls carefully, and test node-fit before enabling automatic changes.
KEDA does not activate a workloadTrigger authentication, event-source connectivity, threshold, polling, or scaler configuration is incorrect.Check scaler and operator logs, inspect trigger status, validate the event source independently, and test a known signal value.

When to revisit

Autoscaling configuration is part of the workload’s operating contract. Revisit it before seasonal planning cycles, after a major application or dependency change, when traffic patterns change, and whenever an incident exposes slow recovery or excessive capacity. Repeat load tests after changing resource requests, metrics, replica limits, startup behavior, container images, or cluster capacity.

Use this final review checklist:

  • Confirm the selected controller matches the workload’s real demand signal.
  • Record the metric definition, target, minimum, maximum, and expected response time.
  • Verify metrics-provider and autoscaler compatibility after upgrades.
  • Test normal load, bursts, recovery, missing metrics, dependency pressure, and node constraints.
  • Review alerts, dashboards, runbooks, and ownership so responders can distinguish application failure from scaling failure.
  • Recheck cost and capacity impact when replica limits or resource recommendations change.

For related operational work, pair this checklist with the Kubernetes upgrade runbook when changing cluster versions and the Helm chart maintenance guide when packaging autoscaling configuration. Treat every autoscaler change as a testable production change, not a one-time YAML edit.

Related Topics

#Kubernetes#Autoscaling#HPA#VPA#KEDA#Performance
D

Deployed Cloud Editorial Team

Cloud-Native Technology Editors

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.