---
title: "Why our own autoscaler, and KEDA"
description: "Why opod scales endpoints with an embedded loop that reads inference signals and the VRAM ledger, what KEDA gives instead, and when to pick each."
url: "https://opod.io/docs/design/autoscaler/"
markdown_url: "https://opod.io/docs/design/autoscaler.md"
section: "Design decisions"
last_updated: "2026-10-31"
---

# Why our own autoscaler, and KEDA

> Why opod scales endpoints with an embedded loop that reads inference signals and the VRAM ledger, what KEDA gives instead, and when to pick each.

opod ships its own autoscaler, and it can hand scaling to KEDA instead. Both read the same signals from the same place: each leader's `/loadz`. They differ in what they may change and in what survives a control-plane outage. This page says why both exist. The fields and the step-by-step setup are on [Autoscaling](https://opod.io/docs/control-plane-endpoints/autoscaling/).

## In short

- **The embedded loop** (the default) changes the **plan**. Every grow is judged against the measured VRAM ledger, the licence and the team quota at the moment it happens. It can sleep an engine, park a whole gang and evict a preemptible job. It needs nothing installed. It stops while the control plane is down.
- **KEDA** (`autoscaler.adapter=keda`) changes one **replica count**. It keeps scaling, and wakes endpoints from zero, while the control plane is down. It can own only endpoints whose replicas are interchangeable, and it holds one spare card per endpoint in reserve so that it never places outside what the control plane approved.
- **Ownership is per endpoint.** Turn KEDA on and the endpoints it can drive go to it; the rest stay on the embedded loop and say why (`scaling.by`, `scaling.detail`).

## Why a generic autoscaler is not enough on its own

A Kubernetes HorizontalPodAutoscaler adds pods when a number crosses a target. For GPU inference, three things are missing from that picture.

**1. The right signals.** CPU use on a worker pod says nothing; the engine runs on the GPU. GPU utilisation is a weak signal too: a card can read 100% while it has room for more requests in its batch, or read low while its KV cache is full and requests queue. The signals that predict a slow answer are inference-specific, and the leader has them:

| Signal (from `/loadz`)     | Grows when                                        | Why it matters                                                       |
| -------------------------- | ------------------------------------------------- | -------------------------------------------------------------------- |
| in-flight requests         | above `targetInflight` per worker                 | the plain measure of demand                                          |
| queue depth                | not empty (every slot busy)                       | a request is waiting now                                             |
| KV-cache pressure          | the busiest worker is at or above `kvPressurePct` | a full cache stops the engine taking more requests, before any error |
| time to first token, p95   | above `ttftBudgetMs`                              | what users feel; may only add workers, never remove them             |
| refused in the last minute | any, with the endpoint at zero                    | the wake signal                                                      |

A shrink waits for `idleSeconds` of low demand and is held off by a queue, a KV cache at half the trigger, a dead engine or a breached TTFT budget. A trigger that could never fire is refused when the plan is written: `E-KV-SIGNAL` for an engine with no KV signal, `E-TTFT-SIGNAL` for embeddings or rerank, which never stream.

**2. Capacity is VRAM, and it is shared.** A new worker needs a card with enough measured free memory, inside the licence and the team's GPU quota. A generic autoscaler adds a pod and lets the scheduler find out: on a full fleet that is a `Pending` pod, or a pod that lands on a card a neighbour needs. The embedded loop asks the placer first. When nothing fits, it does not grow: `scaling.ceiling` drops below `max`, `scaling.blocked` says why, and the alert `autoscale.no-capacity` fires after a minute.

**3. Scaling a model is more than a replica count.** Some steps are not "one more identical pod":

- **Sleep tier.** A vLLM engine on NVIDIA can sleep inside its running pod after `sleepSeconds` and wake in under a second. Its pod and its card stay.
- **Pod-zero.** With `floor: 0`, the last worker's pod parks; the weights stay cached on the node. The leader stays up, so the URL answers and a request wakes the endpoint.
- **Gangs as a unit.** Under `unit: gangs` a whole gang parks and wakes together; half a gang serves nothing.
- **Prefill/decode pairs** grow and shrink by a whole pair.
- **Growth onto other hardware.** From 0.3.0, `autoscale.growth` lists shapes to grow on in order (for example NVIDIA first, then AMD with a smaller budget), each judged when the plan is written. Proven on hardware for one case: a dedicated llama.cpp endpoint on NVIDIA grew onto a second NVIDIA machine, then onto an AMD machine, and parked back in reverse order when idle. A gang that grows onto Intel is not yet proven.
- **Serving wins over preemptible jobs.** When the only free card holds a preemptible training job, the grow evicts that job and the job resumes from its checkpoint.

None of these is a replica count of one Deployment, so none of them can be handed to an HPA as it is.

**Figure: The autoscaler, minute by minute.** Workers running over 20 simulated minutes against the workers the traffic asks for, with the endpoint's awake, asleep, parked and waking states. The interactive figure is on the web page: <https://opod.io/docs/design/autoscaler/>

## Why the loop is embedded

We put the autoscaler inside `opodcp` for a plain reason: the install promise. The chart installs no service pods by default, and KEDA needs an operator and an external-metrics API on the cluster. The control plane already ran a reconcile loop, and every decision it needed read one set of numbers per leader. So scaling became one more controller loop, and **scaling is a plan edit**: it is recorded as a run, judged by the same planner as a human edit, and visible in the plan's history.

The rule "an unreadable `/loadz` makes no decision" keeps it safe: a leader the control plane cannot reach is left at its size, not scaled to zero.

## Why KEDA as well

The embedded loop has one real weakness: **it is part of the control plane**. While every `opodcp` replica is down (an upgrade, a lost node, a database outage), the size of every embedded endpoint freezes. Running workers keep serving, but an endpoint parked at zero stays parked, and its requests get `503` once the leader's hold runs out.

We fixed that by using KEDA rather than writing a second actuator. A bespoke design was drawn first and reviewed; it would have invented a contract KEDA already has. So:

- **KEDA actuates.** One `ScaledObject` per endpoint, with `metrics-api` triggers on the leader's own `/loadz`: `in_flight`, `queue_depth`, `kv_busy_workers`, `ttft_p95_ms`, and `unavailable_1m` and `rpm_1m` to wake and to hold one worker.
- **opod approves the capacity in advance.** KEDA never reads the ledger, the licence or the quota. So the control plane walks the placer for the endpoint and stores a **grant**: one `(node, GPU)` slot per worker, what runs plus `grantHeadroom` more (default 1). `maxReplicaCount` is the number of slots, and a node label pins the replicas to approved nodes. KEDA cannot start a worker on capacity nobody approved.
- **The reservation is real.** The ledger and the team quota count every granted slot, so no other endpoint places there. The licence counts only slots with a worker running, so unused headroom does not spend the free tier. Headroom unused for two hours is given back.
- **A rollout still proves the change.** A verified rollout on an endpoint KEDA parked at zero wakes it for the run with KEDA's own pause annotation, proves it serves, and hands it back.

## Side by side

| Aspect                                                                         | Embedded loop                                                      | KEDA                                                                                                                               |
| ------------------------------------------------------------------------------ | ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------- |
| Survives a control-plane outage                                                | no: sizes freeze                                                   | yes: scale-out, scale-in and wake from zero, inside the last grant                                                                 |
| Needs on the cluster                                                           | nothing                                                            | KEDA's operator and a working external-metrics API. Today you bring your own KEDA; `substrate.keda.enabled` installs it from 0.3.0 |
| Capacity check                                                                 | every grow, against the ledger, licence and quota, when it happens | in advance, as a grant; the headroom card is held idle                                                                             |
| Growth speed                                                                   | one worker at a time, 30 s after the last grow                     | in proportion to load, up to double every 15 s                                                                                     |
| Shrink speed                                                                   | one worker per `idleSeconds`                                       | one pod a minute after a 300 s window                                                                                              |
| Sleep tier, shared cards, several gangs, growth shapes (0.3.0), prefill/decode | yes                                                                | no; those endpoints stay on the embedded loop                                                                                      |
| Node-zero (ask a node autoscaler for a GPU node)                               | no                                                                 | from 0.3.0, opt-in with `cloud.nodeScaling`; built and tested, not yet proven against a real node provisioner                      |
| A standard object your tools already read                                      | the plan, through opod's API                                       | a `ScaledObject` and an HPA, visible to `kubectl` and any KEDA tooling                                                             |

KEDA is a mature, widely used CNCF project, and when it owns an endpoint it does the job better than our loop does in two ways: it keeps working without us, and it answers a burst in proportion. The embedded loop is better where the scaling step is not a replica count, and where you cannot spare a held card.

## What each choice costs

- **Embedded:** an outage of the control plane freezes scaling, and an endpoint at zero cannot wake until it is back. Growth is deliberately slow (one worker per 30 s) so one burst does not climb to `max`.
- **KEDA:** each owned endpoint keeps `grantHeadroom` cards (or VRAM budgets) reserved beside what runs. KEDA becomes a part that must stay up: if its operator stops, nothing grows and a parked endpoint does not wake. opod watches the lease KEDA's operator renews and raises `autoscale.scaler-unhealthy`, but only while the control plane itself runs.
- **Both:** a wake from zero costs a pod start and a model load, often tens of seconds. A sleep tier (vLLM on NVIDIA) or `floor: 1` avoids it, at the price of a held card.

## Which to pick

The short rule: **pick KEDA for endpoints that must wake or grow while the control plane is down; keep the embedded loop for everything that sleeps, shares a card, runs or grows to several gangs, or grows across vendors.** For a gang, KEDA only parks and wakes one (`max: 1`); a second gang needs machines of its own, and only the control plane places them (the release after 0.3.6). Mixed installs are normal. The full checklist is in [Autoscaling → Which should I pick](https://opod.io/docs/control-plane-endpoints/autoscaling/#which-should-i-pick).
