Autoscaling#
Autoscaling is crucial for deploying Large Language Model (LLM) services on Kubernetes (K8s), as timely scaling up handles peaks in request traffic, and scaling down conserves resources when demand wanes.
AIBrix ships one custom resource for this, PodAutoscaler in the autoscaling.aibrix.ai/v1alpha1
API group, and several algorithms behind it. This page explains how the pieces fit together and
which page to read next. The two child pages hold the full configuration and examples.
How it works#
graph LR
PA["PodAutoscaler CR"] --> C["PodAutoscaler controller"]
C -->|"pod source"| P["Engine pods<br/>/metrics"]
C -->|"external source"| O["GPU optimizer<br/>/metrics/ns/deployment"]
C -->|"HPA / KPA / APA"| D["desired replicas"]
D -->|updates| T["scaleTargetRef<br/>Deployment, StormService role,<br/>RayClusterFleet"]
You create a
PodAutoscalerthat points at a workload throughscaleTargetRef. The target can be aDeployment, aStormService(optionally one role of it, throughsubTargetSelector.roleName), or aRayClusterFleet.The controller collects the metric named in
metricsSources. WithmetricSourceType: podit scrapes every pod of the target at the givenportandpath. WithmetricSourceType: externalit reads a single HTTP endpoint instead, which is how the GPU optimizer hands its recommendation to the autoscaler.The algorithm selected by
scalingStrategy(HPA,KPAorAPA) turns the observed value andtargetValueinto a desired replica count, usingobserveWindowSecondsand, for KPA,panicWindowSecondsas its windows.The result is clamped to
minReplicasandmaxReplicas, or to the bounds of a matching entry inscheduleswhen one is active, and written to the target.
Choosing a strategy#
Strategy |
How it decides |
Use it when |
|---|---|---|
|
Same algorithm as the Kubernetes HorizontalPodAutoscaler, applied to the metric you choose. |
Traffic is steady and you want the most familiar behaviour. |
|
Knative-style: a long stable window plus a short panic window that scales up fast when the panic window crosses the threshold. Metrics are fetched by AIBrix directly rather than through Prometheus, which shortens reaction time. |
Bursty or unpredictable traffic where scale-up latency matters most. |
|
AIBrix’s own algorithm. Like HPA but with a fluctuation tolerance that must be exceeded before any scaling happens, which suppresses oscillation. |
Latency-sensitive services that must not thrash between replica counts. |
Optimizer-based |
Not a |
You have benchmark data per GPU type, an explicit latency SLO, or a mix of GPU types to balance for cost. See Optimizer-based Autoscaler and Heterogeneous GPU Inference (Experimental). |
Metric sources#
metricSourceType accepts pod, external, resource and custom. domain is
a deprecated alias of external kept for manifests written before the rename. The two the
documentation and samples use are:
pod: scrape each target pod. Validation requiresport,pathandprotocolType, but onlyportshapes the request: the controller always scrapes plain HTTP at the path implied by the pod’smodel.aibrix.ai/enginelabel (/metrics, or/prometheus/metricsfortrtllm), andpathdoes not override it. SettargetMetricto one of AIBrix’s engine-neutral metric names, such asnum_requests_waitingorgpu_cache_usage_perc. AIBrix translates the name to what the pod’s engine actually exports (vllm:num_requests_waitingfor vLLM,sglang:num_queue_reqsfor SGLang), so do not use the raw engine names here.external: read one HTTP endpoint instead of the pods.endpointis the host and port, andpathandprotocolTypeare required alongside it. The fetcher requests<protocolType>://<endpoint>/<path>and readstargetMetricfrom the response by its literal Prometheus name, with no registry translation. This is the shape the GPU optimizer sample uses; see Optimizer-based Autoscaler. Ifendpointis left empty, the controller queries the Kubernetesexternal.metricsAPI fortargetMetricinstead.
For the engine-neutral names and what each engine exports for them, see the table in Multi-Engine Support.
PodAutoscaler spec at a glance#
Field |
Meaning |
|---|---|
|
|
|
When the target is a |
|
|
|
Hard bounds on the result. |
|
One or more of |
|
Metric windows. |
|
Time-boxed overrides of |
Algorithm tunables that are not part of the spec, such as KPA’s scale-down delay or APA’s
tolerance, are set through annotations on the PodAutoscaler. The full annotation list and
worked YAML examples for every strategy live in Metric-based Autoscaling.
See also
- AIBrix Autoscaler
Internal design of the AIBrix autoscaler.