Introduction

At 02:14 the queue depth alert fires. Order workers are running, every Pod is healthy, CPU sits near eight percent, and the Horizontal Pod Autoscaler reports that it is satisfied. This is the KEDA vs HPA problem in miniature: the backlog climbs from two thousand messages to forty thousand, and the oldest message age crosses the service level objective. Nothing has crashed. The autoscaler is simply watching the wrong signal: the workers spend most of their time waiting on a downstream payment API, so CPU stays flat while work piles up in the queue. This opening is an illustrative composite drawn from a common production pattern, not a report about one named company.

That mismatch is exactly where KEDA vs HPA stops being a trivia question. HPA, the built-in Horizontal Pod Autoscaler, scales a workload between one and many replicas using metrics such as CPU, memory, or a custom metric you wire up yourself. KEDA, Kubernetes Event-Driven Autoscaling, watches an event source outside the Pod — queue depth, Kafka consumer lag, a Prometheus query, a schedule — and drives scaling from that backlog, including scaling to zero when there is no work at all. The two are related more closely than most comparisons admit, because KEDA normally creates and manages an HPA under the hood.

This article explains the KEDA vs HPA decision the way a senior SRE would make it on call: which signal actually represents demand, whether zero replicas are safe, what the cold start costs, which failure modes each option adds, and how to prove the choice with numbers instead of preference. If you already run a CPU-based HPA and want the mechanics of requests, targets and behaviour policies, start with the Kubernetes HPA v2 tutorial on CPU, memory and custom metrics. If your question is whether to scale replicas out or resize Pods up, the HPA vs VPA guide covers that separate decision.


1. KEDA vs HPA: the short decision

The short KEDA vs HPA decision is this: use plain HPA when the load on a Pod rises and falls with the resource you can measure on that Pod. A synchronous HTTP API whose CPU climbs with request rate is the classic case. CPU utilisation against requests is a decent proxy for demand, the built-in controller already exists in every cluster, and there is no extra operator to upgrade, secure or debug at 3 a.m. Adding KEDA to such a service buys complexity without buying a better signal.

Choose KEDA when demand lives outside the Pod. Queue depth, stream lag, the number of pending jobs, or a business metric in Prometheus tells you how much work is waiting even when each worker is mostly idle. KEDA also matters when idle replicas are pure cost: a report generator that runs for twenty minutes a day, a staging worker, or a bursty webhook processor does not need a warm replica at midnight. Scale to zero is the feature HPA structurally cannot offer on ordinary clusters, because a Pod that does not exist cannot report CPU for the autoscaler to act on.

The framing that prevents most mistakes is that KEDA vs HPA is really a question about the scaling signal and the minimum replica count, not about which tool is more modern. KEDA does not replace the HPA controller; it feeds it. Once a workload is at one replica or more, the same HPA maths decides how far to scale. So the honest comparison is HPA alone versus HPA plus an event-driven front end that can also take you to zero. Keep that picture in mind and the rest of the trade-offs — cold starts, metric plumbing, cost — fall into place without vendor slogans.


2. How KEDA vs HPA works under the hood

Understanding KEDA vs HPA mechanics saves hours of confused debugging later. A plain HPA is a control loop in the kube-controller-manager. Every sync period it reads metrics, compares the current value with the target, and computes a desired replica count using the ratio between the two, clamped by your minimum, maximum and behaviour policies. Resource metrics come from metrics-server. Anything else — requests per second, queue length, a custom application metric — needs a metrics adapter that serves the custom or external metrics APIs. Without that adapter, HPA simply cannot see your signal, no matter how good the signal is.

KEDA installs three pieces: an operator that watches ScaledObject and ScaledJob resources, a metrics API server that presents event-source values as external metrics, and admission webhooks that validate what you apply. When you create a ScaledObject for a Deployment, KEDA creates an HPA named after it and points that HPA at the external metric. From one replica upward, the stock HPA controller does the scaling exactly as it would for a hand-written HPA. The operator's special job is the boundary HPA cannot cross: when every trigger reports no work, KEDA scales the target to zero, and when work appears, it brings the first replica back so the HPA has something to scale.

Two consequences follow. First, never create your own HPA for a workload that already has a ScaledObject; the two controllers will fight over the replica count and the loser is your on-call engineer. Second, a cluster effectively has one external metrics provider, so KEDA and a Prometheus adapter serving external metrics can conflict; decide which component owns that API before you install both. When replicas look stuck, inspect the KEDA-managed HPA first with kubectl describe hpa — its conditions tell you whether the problem is metric retrieval, scaling limits, or the workload itself.


3. KEDA vs HPA signals: CPU, queues, lag and schedules

The KEDA vs HPA signal question deserves more care than it usually gets, because a bad signal scaled efficiently is still a bad signal. CPU works when each request burns roughly predictable compute and the Pod is the bottleneck. Memory is a weaker scaling signal: many runtimes hold memory after a spike, garbage collection makes usage lumpy, and scaling on memory often reacts after the damage. HPA can combine metrics and takes the largest desired count, which helps, but it cannot invent a signal that reflects waiting work. A worker blocked on a slow database at ten percent CPU looks idle to HPA while its queue grows without bound.

Event signals measure the backlog directly. For SQS, RabbitMQ or Azure Service Bus, queue depth divided by a per-replica target gives a replica estimate that tracks the work waiting, not the effort spent. For Kafka, consumer group lag does the same job, with one hard ceiling: extra consumers beyond the partition count sit idle, so max replicas should respect partitioning. A Prometheus trigger lets you scale on almost any PromQL result — pending jobs in a table, p95 latency, an error budget burn — which is powerful and also an invitation to scale on noisy queries. The cron trigger handles predictable shape: hold a floor of replicas during business hours, allow zero overnight.

Whichever side of KEDA vs HPA you land on, validate the signal against history before you trust it. Plot the metric next to the moments users felt pain. If the metric rose before the pain, it is a leading indicator worth scaling on. If it rose afterwards, you are automating a lagging reaction. Also decide what the signal means per replica: "ten messages per Pod" is a capacity statement you should be able to defend with a load test, not a number copied from a tutorial. Autoscaling quality is mostly signal quality plus honest per-replica capacity.


4. KEDA vs HPA scale to zero and the cold start bill

Scale to zero is the headline KEDA vs HPA difference, and it is also where teams get surprised. HPA on a normal cluster stops at one replica. That floor is deliberate: resource metrics need a running Pod to measure. KEDA removes the floor by watching the event source itself, so an empty queue can mean zero Pods and the first message can wake the workload. For sporadic batch work, internal tools, and consumers with long idle stretches, that is real money and real cluster headroom returned.

The bill arrives as latency. Going from zero to one means the operator notices work on its polling interval, Kubernetes schedules a Pod, the node may pull an image, the process starts, warms caches, opens connections, and only then begins draining the backlog. For a queue consumer, a thirty to ninety second wake-up is usually acceptable because the queue absorbs the delay. For a latency-sensitive HTTP path, the same delay is an outage-shaped experience for the first caller, which is why HTTP services rarely belong at zero replicas without a request-buffering layer in front of them.

You can soften the trade-off rather than choosing blindly. Set a minimum of one during business hours with a cron trigger and zero at night. Keep images small and pre-pulled on likely nodes so the cold start is process start, not image download. Tune pollingInterval and cooldownPeriod so the workload wakes promptly but does not flap between zero and one on a trickle of messages. Measure the actual zero-to-processing time in staging and put that number in the design doc; "scale to zero" as a slogan hides the only number users will feel. The KEDA vs HPA choice is often really a choice about who waits: your budget, or your first request after an idle period.


5. KEDA vs HPA in YAML: one workload, two ways

Concrete YAML makes the KEDA vs HPA contrast obvious. Here is a plain HPA for an API whose CPU tracks traffic. Note the requests on the container matter: utilisation is measured against requests, so a Deployment without CPU requests gives HPA nothing meaningful to compute.

yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: checkout-api
  namespace: production
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: checkout-api
  minReplicas: 2
  maxReplicas: 12
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 65
  behavior:
    scaleDown:
      stabilizationWindowSeconds: 300

Now the same organisation's order worker, scaled by KEDA on queue depth. The ScaledObject names the target, the replica bounds, and the trigger. KEDA turns this into an HPA plus the zero-to-one handling. Authentication for the queue belongs in a TriggerAuthentication referencing a secret or workload identity, never as credentials pasted into the ScaledObject.

yaml
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: order-processor
  namespace: production
spec:
  scaleTargetRef:
    name: order-processor
  pollingInterval: 15
  cooldownPeriod: 300
  minReplicaCount: 0
  maxReplicaCount: 20
  triggers:
    - type: aws-sqs-queue
      authenticationRef:
        name: order-processor-aws
      metadata:
        queueURL: https://sqs.eu-west-1.amazonaws.com/123456789012/orders
        queueLength: "25"
        awsRegion: eu-west-1

Read the two files side by side and the KEDA vs HPA story tells itself. The HPA file talks about the Pod's own resource use and can never go below two replicas. The ScaledObject talks about work waiting outside the Pod and treats zero as a normal state. For batch-shaped work where each event should spawn a Job rather than feed a long-running Deployment, KEDA's ScaledJob is the sibling resource; compare that shape with ordinary Kubernetes Jobs and CronJobs before you force a consumer pattern onto one-shot work.


6. KEDA vs HPA comparison and decision table

A decision table helps when the KEDA vs HPA debate is happening in a design review rather than in your head. Use it as a checklist against your workload, not as a scorecard where more rows automatically win. The most important rows are the signal and the minimum replica count; the rest are consequences that follow from those two.

Decision point HPA alone KEDA driving an HPA
Scaling signal CPU, memory, or custom metrics you adapt yourself Queue depth, Kafka lag, Prometheus queries, cron, 60+ built-in scalers
Minimum replicas 1 on ordinary clusters 0, with operator-managed activation
Zero to one step Not available for resource metrics Handled by the KEDA operator on trigger activity
One to N step HPA controller maths Same HPA controller maths, fed external metrics
Extra components None beyond metrics-server Operator, metrics API server, admission webhooks
Best fit Synchronous APIs where CPU tracks demand Workers, consumers, sporadic and batch-shaped workloads
Main risk Blind to backlog when Pods wait on I/O Cold starts, extra control plane to run and upgrade
Metric plumbing You build or install an adapter for non-resource metrics Scalers included, but KEDA owns the external metrics API

Notice what the table does not say. It does not say KEDA scales better once replicas exist; the HPA underneath is identical, including its tolerance band and behaviour policies. It also does not say HPA is outdated. For a large share of services — anything request-driven with CPU proportional to load — HPA alone remains the correct, boring answer. Reach for KEDA when a row in the left column is the reason your current autoscaling fails, and be able to name that row out loud. "We need scale to zero for the nightly report worker" is a reason. "KEDA is more advanced" is not.


7. KEDA vs HPA troubleshooting matrix

When autoscaling misbehaves, the KEDA vs HPA architecture tells you where to look. Work from the metric inward: is the signal right, can the controller read it, is the maths clamped, and only then blame the workload. The matrix below covers the failures that recur in production, with the first check that separates each cause from its neighbours.

Symptom Likely cause First check
Replicas stuck at minimum while backlog grows HPA cannot read the metric kubectl describe hpa and look for failed metric retrieval events
Worker idle at low CPU, queue age rising Scaling on CPU for an I/O-bound consumer Compare queue depth or lag with CPU; move the signal to the backlog
Workload never reaches zero Minimum replicas set above zero, or a trigger never reports inactive Inspect ScaledObject minReplicaCount and trigger activity in operator logs
Flapping between zero and one replica Cooldown too short for a trickle of messages Raise cooldownPeriod and check pollingInterval against message rate
Scale-out stops below the needed count maxReplicaCount, partition count, or namespace quota is the ceiling Check HPA max, Kafka partitions, and ResourceQuota headroom
Two controllers fight over replicas A hand-written HPA exists beside a ScaledObject List HPAs in the namespace and remove the one KEDA does not own
First request after idle is very slow Cold start: scheduling, image pull, process warm-up Time zero-to-ready in staging; shrink image, pre-pull, or raise the floor
HPA reports unknown metrics after install External metrics API conflict with another adapter Check the v1beta1.external.metrics.k8s.io APIService owner

Two habits prevent most of these incidents. First, alert on the user-visible quantity — oldest message age, consumer lag, request latency — rather than on replica count, so a wrong signal still pages you. Second, keep the autoscaling objects in Git with the same review discipline as the workload, because a queueLength typo is a capacity change. Namespace guardrails matter here too: an enthusiastic maxReplicaCount can exhaust a quota and starve neighbours, which is why ResourceQuota and LimitRange guardrails belong in the same conversation as any autoscaler.


8. KEDA vs HPA cost: replicas, nodes and honest arithmetic

Cost claims dominate KEDA vs HPA discussions, so do the arithmetic honestly. Scaling a worker to zero saves money only when the removed Pods free capacity someone else can use or allow nodes to leave the cluster. If the node stays because three other services pin it, you saved requests on paper and nothing on the bill. Real savings appear when idle workers held whole nodes, when the cluster autoscaler or Karpenter can consolidate and terminate empty nodes, or when you pay per Pod in a serverless-style environment. Pairing event-driven scaling with node provisioning that actually shrinks is what turns replica savings into invoice savings; the node side of that story is covered in Karpenter vs Cluster Autoscaler.

Count the costs on the other side too. KEDA runs its own operator, metrics server and webhooks, each with resource requests and an upgrade cadence. Cold starts may force you to keep a warm floor during peak windows, erasing the headline saving. Over-scaling on a noisy Prometheus trigger can cost more than the idle replicas you removed. None of this argues against KEDA; it argues for measuring. Record replica-hours and node-hours for a representative week before and after, including the KEDA control plane, and present that number rather than a percentage from a blog post.

There is also a reliability budget hidden in the cost line. A worker at zero replicas has no warm connection pool, no loaded model, no JIT-compiled hot path. If the business cost of a ninety-second delay on the first job exceeds the compute saved, the correct minimum is one, and HPA alone may be all you need. Senior engineers state the trade in those terms — money per month against seconds of delay and failure modes added — instead of treating scale to zero as an unquestioned good. The KEDA vs HPA answer that survives a finance review is the one with both numbers attached.


9. KEDA vs HPA production guardrails

Guardrails are where KEDA vs HPA stops being a demo and becomes a platform feature. Start with bounds you can defend: a maximum replica count derived from downstream capacity, not from optimism. If the database accepts two hundred connections and each worker opens ten, twenty workers is a ceiling with a reason. Add HPA behaviour policies to damp flapping: a scale-down stabilisation window of a few minutes prevents replica churn when the metric oscillates, and scale-up policies can cap how fast you add Pods so a metric spike does not stampede a recovering dependency.

For KEDA specifically, use the fallback and activation features deliberately. A fallback replica count protects you when the metric source is unreachable, so a queue API outage does not scale your consumers to zero mid-incident. Activation thresholds let a trigger wake the workload at a different point than the steady-state target, which avoids waking a Pod for a single stray message. Treat TriggerAuthentication as a secret-bearing object with the same handling as any credential, and prefer workload identity over static keys where the cloud allows it.

On the HPA side, the guardrails are older but no less important: set resource requests honestly, because utilisation targets are meaningless against missing or inflated requests; test behaviour under load before trusting it; and remember that autoscaling cannot fix a Pod that cannot start. A crash-looping worker scaled to twenty replicas is twenty crash loops. Keep readiness probes truthful so new replicas only receive work when they can do it, and keep the Pod disruption budget and termination grace period aligned with how long a message takes to process, so scale-in does not drop in-flight work. Autoscaling amplifies whatever your workload already does, including its bugs.


10. KEDA vs HPA use cases from real workload shapes

Workload shape decides KEDA vs HPA faster than any feature list. Consider four shapes that cover most clusters. A public API with CPU proportional to requests: HPA alone, minimum two or three for availability, behaviour policies tuned, done. Adding KEDA here introduces a control plane to watch a signal you already have. A queue consumer whose Pods wait on third-party APIs: KEDA on queue depth, because the backlog is the demand and CPU is nearly decoration. A Kafka consumer group: KEDA on lag, with max replicas capped near the partition count and a lag threshold derived from how many messages one consumer clears per minute at acceptable latency.

The fourth shape is time-shaped work: nightly reports, hourly reconciliation, a webhook processor that only matters during business hours. Here the cron trigger or a plain CronJob may beat both autoscalers. If the work is a finite batch with a clear start and end, a Job is simpler than a Deployment scaled by events; if it is a long-running consumer with predictable quiet hours, KEDA with a scheduled floor gives you warm capacity when it matters and zero when it does not. The honest engineer asks whether the workload needs autoscaling at all before asking which autoscaler.

Mixed estates are normal. The same platform team often runs HPA on the request path, KEDA on the workers behind it, and Karpenter underneath both, removing nodes when the workers vanish. That combination is not indecision; it is matching each control loop to the signal that represents its demand. Document the choice per workload in the service's runbook — signal, bounds, cold-start expectation, and the alert that fires when the signal lies — so the next engineer inherits reasoning, not just YAML. KEDA vs HPA answered per workload, in writing, is a sign of a mature platform rather than a team that could not commit.


11. KEDA vs HPA limits and senior takeaways

Every autoscaling story has limits, and naming them is part of the KEDA vs HPA answer. Neither tool fixes a downstream bottleneck: scaling consumers against a saturated database converts queue delay into database overload. Neither tool understands cost, fairness between tenants, or the business priority of one queue over another; those policies live in your platform design, not in a ScaledObject. KEDA's external metrics ownership can collide with an existing adapter, its operator is one more thing to upgrade across Kubernetes versions, and scale to zero remains the wrong default for anything a human is synchronously waiting on.

HPA's limits are the mirror image. It cannot see work that has not reached a Pod, it cannot start from zero on resource metrics, and its ratio maths assumes replicas are interchangeable and the metric scales linearly with them. When those assumptions break — a single hot partition, a leader-elected worker, a cache that takes ten minutes to warm — autoscaling of either flavour needs rethinking, not tuning. The senior move is to state the assumption, test it under load, and write down what would make you revisit the choice.

So the takeaways to carry into your next design review are compact. KEDA vs HPA is a signal-and-floor decision, not a tooling fashion choice. KEDA wraps HPA and adds event triggers plus the zero-to-one step; HPA alone is correct when Pod resource use tracks demand. Price scale to zero in seconds of cold start and node-hours actually released, not in slogans. Guard the bounds, alert on the user-visible backlog, and keep the reasoning beside the YAML. Do that, and whichever side you pick, you will be able to defend it at 3 a.m. — which is the only review that really counts.

Frequently Asked Questions

What is the difference in KEDA vs HPA?

HPA scales a workload between one and many replicas using CPU, memory or custom metrics. KEDA watches event sources such as queue depth or Kafka lag, feeds that metric to an HPA it creates, and additionally handles scaling to zero and back to one. In short, KEDA extends HPA rather than replacing it.

Can HPA scale to zero in KEDA vs HPA setups?

On ordinary clusters, no. HPA needs a running Pod to measure resource use, so it stops at one replica. KEDA can scale to zero because it watches the event source itself, and it activates the first replica when work appears, after which the HPA takes over.

When should I choose KEDA vs HPA for a queue worker?

Choose KEDA when the backlog is the real demand signal and workers spend time waiting on I/O, so CPU stays low while messages pile up. Scale on queue depth or consumer lag with a per-replica target you validated under load, and cap replicas by downstream capacity and, for Kafka, partition count.

Does KEDA vs HPA change how scaling works above one replica?

No. Above one replica, the same HPA controller maths applies in both cases, including targets, tolerance and behaviour policies. KEDA's contribution is supplying external metrics and managing the zero-to-one boundary; the one-to-many scaling is stock HPA behaviour.

What are the risks in KEDA vs HPA scale to zero?

The main risk is cold start latency: scheduling, image pull and process warm-up delay the first unit of work after idle. Flapping between zero and one, metric source outages scaling you down, and savings that never release nodes are the other common surprises. Measure zero-to-processing time and set cooldowns and fallbacks deliberately.

Can I run KEDA vs HPA together on one workload?

Not as two independent controllers. A ScaledObject makes KEDA create and own an HPA for the workload, so a hand-written HPA for the same target will fight it over replica count. Run HPA alone on some workloads and KEDA-managed HPAs on others; that mix across a cluster is normal.

How do I troubleshoot KEDA vs HPA when replicas are stuck?

Start with kubectl describe hpa on the KEDA-managed HPA to see whether metric retrieval is failing. Then check the signal itself, replica bounds, namespace quotas, and KEDA operator logs for trigger activity. Alert on backlog age or lag rather than replica count so a wrong signal still pages you.