
The most expensive line item in a small Kubernetes bill is not the big node — it is the fleet of workers sitting at three percent CPU for 22 hours a day. Message consumers, report generators, webhook processors: they burst for minutes, then idle. The Horizontal Pod Autoscaler reacts to CPU, which stays flat while the queue backs up, and it can never scale below one replica. KEDA fixes both problems. It is a CNCF-graduated, Kubernetes-native event-driven autoscaler that scales workloads on queue depth, stream lag, or any external signal — and it scales all the way to zero. This is the highest-leverage cost move most SMB clusters can make this quarter.
The idle-resource problem, in numbers
Say you run three RabbitMQ consumer Deployments at one replica each on a three-node cluster, plus a cron-style PDF renderer that only works 9 a.m. to 5 p.m. Each idle replica reserves 500m CPU and 1 GiB memory. That is roughly 55 to 65 percent of paid compute doing nothing on a typical week. The fix is not smaller nodes — it is matching capacity to demand. KEDA inserts itself between your Deployment and the Horizontal Pod Autoscaler: it reads event sources (Kafka lag, RabbitMQ queue length, Prometheus queries, cloud queue depth, cron schedules) and sets the replica count directly. When the queue is empty, replicas go to zero and the pods stop consuming requests, limits, and node capacity.
Installing KEDA in five minutes
KEDA is a single lightweight Helm chart that runs alongside your existing autoscalers:
helm repo add kedacore https://kedacore.github.io/charts
helm repo update
helm install keda kedacore/keda --namespace keda --create-namespace \
--set metricsServer.logLevel=0
Verify the operators are live, then point KEDA at your queue. For a RabbitMQ worker, you need a TriggerAuthentication secret and a ScaledObject:
kubectl create secret generic rabbitmq-secret \
--from-literal=amqpHost=rabbitmq.default.svc.cluster.local \
--from-literal=amqpUser=worker --from-literal=amqpPassword=CHANGE_ME
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: invoice-worker
namespace: billing
spec:
scaleTargetRef:
name: invoice-worker
minReplicaCount: 0
maxReplicaCount: 10
cooldownPeriod: 300
pollingInterval: 30
triggers:
- type: rabbitmq
metadata:
queueName: invoices
queueLength: "5"
hostFromEnv: RABBITMQ_HOST
authenticationRef:
name: keda-rabbitmq-auth
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-rabbitmq-auth
namespace: billing
spec:
secretTargetRef:
- parameter: host
name: rabbitmq-secret
key: amqpHost
- parameter: username
name: rabbitmq-secret
key: amqpUser
- parameter: password
name: rabbitmq-secret
key: amqpPassword
queueLength: "5" means one replica per five pending messages. With minReplicaCount: 0, a five-minute cooldownPeriod, and a 30-second pollingInterval, the worker disappears when the queue drains and reappears in seconds when backlog arrives.
More triggers: Prometheus, Kafka, and cron
Queues are the common case, but the same ScaledObject pattern covers latency and schedule signals. Scale an API on p95 latency from Prometheus:
triggers:
- type: prometheus
metadata:
serverAddress: http://prometheus.monitoring:9090
metricName: http_request_duration_seconds
threshold: "0.5"
query: |
histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket{job="api"}[2m])) by (le))
Or run the PDF renderer only during business hours with a cron trigger, and add a fallback so a broken metrics pipeline never leaves production at zero replicas:
minReplicaCount: 0
maxReplicaCount: 4
fallback:
failureThreshold: 3
replicas: 1
triggers:
- type: cron
metadata:
timezone: Europe/Madrid
start: 0 9 * * *
end: 0 18 * * *
desiredReplicas: "2"
Guardrails that keep scale-to-zero safe
Three settings prevent the classic failures. Set maxReplicaCount to what your downstream database can actually handle — KEDA will happily scale to 50 workers and melt your Postgres pool otherwise (see our connection pool guide). Set the fallback block so KEDA returns to a safe replica count if the event source goes dark. And for anything latency-sensitive, keep minReplicaCount: 1 during business hours and zero overnight via a cron trigger.
Prove the savings with real numbers. Watch replicas and queue depth together:
kubectl get scaledobject invoice-worker -n billing -w
Then compare node hours before and after in OpenCost. Three idle workers at 500m CPU each, 22 hours a day, 30 days a month, at roughly $0.05 per vCPU-hour is about $100 a month reclaimed from one small fleet — before counting the memory and node-bin-packing savings. In our OpenCost FinOps walkthrough we show the exact dashboard; KEDA fleets typically reclaim 30 to 50 percent of worker spend. The pattern also composes with the architecture choices in serverless vs. Kubernetes — KEDA gives you serverless-style scaling without leaving your cluster.
Want your cluster audited for idle spend, with KEDA scalers sized to your real traffic? Book a free 30-minute DevOps consultation and we will map your first scale-to-zero workload together.