Skip to content

Serve runtime, scaling, and scale to zero

A deployed model serves from a runtime the control plane sizes. Replica counts are control-plane desired state rather than a node-side decision, and scaling to zero is a separate reconciliation with its own safety check.

Replicas are desired state

The default scaling mode is cp_desired_replicas: the control plane records what should be running and the node reconciles toward it.

The defaults are deliberately unambitious:

min replicas       1
max replicas       1
desired replicas   1
idle timeout       0 seconds

An idle timeout of zero means scale to zero is off until it is configured. A model deployed without a scaling spec serves from one replica and stays there, which is a predictable starting point rather than an inferred one.

The scaling spec is normalised, then projected

flowchart LR
  SPEC["Authored scaling spec<br/>possibly partial"]
  subgraph CP["CONTROL PLANE"]
    direction TB
    subgraph PRJ["RUNTIME SCALING PROJECTION, complete"]
      direction TB
      P1["enabled"]
      P2["min, max, desired replicas"]
      P3["idle timeout"]
    end
    AS{{"Autoscale controller<br/>scale-to-zero check"}}
    SP[("Storage profile")]
    AS -.-> SP
    AS --> PRJ
  end
  subgraph YI["YOUR INFRASTRUCTURE"]
    direction TB
    SR["Serve runtime replicas"]
    W[("Weights<br/>pvc or bucket")]
    SR --- W
  end
  SPEC -->|"normalised"| PRJ
  PRJ -->|"desired state"| SR

The projection is always complete, whatever the author wrote, and it is the only thing the node reconciles toward. The autoscale controller writes to the same projection, and it reads the storage profile first, because the weights on the right have to survive a scale to zero.

Normalising first means an absent or partial spec resolves to the defaults rather than to an error, and the projection the node receives is complete whatever the author wrote.

Scale to zero has its own safety check

Scaling to zero is not simply the lower bound reaching zero. It is evaluated separately, and the evaluation can refuse.

The reason is storage. A model that scaled to zero must be able to come back, and coming back means its weights are still reachable. Scale to zero therefore resolves a storage profile as part of the decision: a runtime whose storage would not survive the scale-down is not scaled down.

The controller reports each cycle what it decided:

model_autoscale_scanned_count
model_autoscale_state_writes_count
model_autoscale_decision_writes_count
model_autoscale_scaled_to_zero_count
model_autoscale_wake_count
model_autoscale_blocked_count

blocked is the count that answers "why has this never scaled down", and wake is the count that shows cold starts happening.

Waking is a control-plane gate, not a race

A run that targets a model at zero replicas does not fail and does not busy wait. The dispatch path holds it while the model wakes, and releases it when the endpoint reports healthy.

That hold is applied by the dispatch guard, and it is the same mechanism that holds a run whose model is unhealthy for any other reason. See Dispatch guard.

Decisions are recorded separately from state

Autoscale writes both a state and a decision: the state is what the runtime should be, and the decision is why. Keeping them apart means a scale-down that did not happen still leaves a record explaining the refusal, rather than only an unchanged replica count.

Serving reaches nodes on the ordinary path

A serve runtime is reconciled through an assignment like any other work. There is one dispatch path, and models use it. See The three-plane contract.