The available gate types, at a glance:
| Gate | Kind | Purpose |
|---|---|---|
constant |
budget | Always fully open (budget 1.0) — no throttling. |
redis |
budget | Reads the dispatch budget from a Redis key managed by an external system. |
redis-leased-rate |
admission | Enforces a leased, pool-wide dispatch-attempt rate from Redis. Missing, invalid, unreadable, or expired commands fail closed. |
prometheus-saturation |
budget | Closes when a pool saturation metric reaches a threshold. |
prometheus-budget |
budget | Computes a dispatch budget from a cascade of EPP/vLLM metrics. |
prometheus-query |
budget | Evaluates a user-supplied PromQL expression as the budget. |
inference-pool-ready |
budget | Holds requests while an InferencePool has fewer ready endpoints than required (e.g. scaled to zero). |
endpoint-scrape |
budget | Scrapes a raw /metrics endpoint directly — no Prometheus server required. |
local-max-concurrency |
admission | Caps concurrent in-flight requests per queue using in-process state. |
redis-quota |
admission | Per-attribute quota (rate limit or concurrency) via Redis. |
sql-quota |
admission | redis-quota counted in the sql transport's Postgres database (experimental). |
tier-priority-admission |
admission | Three-way verdict from saturation × tier × classification. |
composite |
combinator | Combines multiple gates: minimum budget across all inner dispatch gates, all-or-nothing quota acquisition across inner attribute gates. |
wait-on-refuse |
combinator | Wraps an inner gate and converts ActionRefuse into ActionWait (parking in-memory instead of broker redelivery). |
Note: An unrecognized
gate_typedoes not fail startup — it resolves to the always-open constant gate.
Example configuration with per-queue gates:
[
{
"queue_name": "critical_queue",
"inference_objective": "critical-task",
"request_path_url": "/v1/completions",
"igw_base_url": "http://localhost:80/",
"worker_pool_id": "inference_pool_1",
"gate_type": "constant"
},
{
"queue_name": "batch_queue",
"inference_objective": "batch-task",
"request_path_url": "/v1/completions",
"igw_base_url": "http://localhost:80/",
"worker_pool_id": "inference_pool_1",
"gate_type": "prometheus-saturation",
"gate_params": {
"pool": "inference_pool_1",
"threshold": "0.8"
}
},
{
"queue_name": "batch_budget_queue",
"inference_objective": "batch-task",
"request_path_url": "/v1/completions",
"igw_base_url": "http://localhost:80/",
"worker_pool_id": "inference_pool_1",
"gate_type": "prometheus-budget",
"gate_params": {
"pool": "inference_pool_1",
"max_concurrency": "100",
"baseline": "0.05"
}
},
{
"queue_name": "redis_gated_queue",
"inference_objective": "gated-task",
"request_path_url": "/v1/completions",
"igw_base_url": "http://localhost:8000/",
"worker_pool_id": "inference_pool_2",
"gate_type": "redis",
"gate_params": {
"address": "localhost:6379",
"budget_key": "my-budget-key"
}
},
{
"queue_name": "custom_metric_queue",
"inference_objective": "custom-task",
"request_path_url": "/v1/completions",
"igw_base_url": "http://localhost:8000/",
"worker_pool_id": "inference_pool_2",
"gate_type": "prometheus-query",
"gate_params": {
"query": "1 - (sum(rate(http_requests_total{job=\"inference\"}[5m])) / 100)",
"fallback": "0.0"
}
},
{
"queue_name": "composite_gated_queue",
"inference_objective": "composite-task",
"request_path_url": "/v1/completions",
"igw_base_url": "http://localhost:80/",
"worker_pool_id": "inference_pool_1",
"gate_type": "composite",
"gate_params": {
"gates": "[{\"gate_type\":\"prometheus-saturation\",\"gate_params\":{\"pool\":\"inference_pool_1\"}},{\"gate_type\":\"redis-quota\",\"gate_params\":{\"address\":\"localhost:6379\",\"limit\":\"100\"}}]"
}
},
{
"queue_name": "scrape_gated_queue",
"inference_objective": "batch-task",
"request_path_url": "/v1/completions",
"igw_base_url": "http://localhost:80/",
"gate_type": "endpoint-scrape",
"gate_params": {
"url": "http://vllm-sim:8000/metrics",
"metric": "vllm:num_requests_waiting",
"max_count_per_pod": "5",
"fallback": "1.0"
}
}
]-
constant: Always returns budget 1.0 (fully open). No parameters. -
redis: Queries Redis for the dispatch budget (managed by an external system).address(required): Redis server address for the dispatch gate (e.g.,localhost:6379). When it exactly matches theredis-sortedsettransport's address, the gate reuses the transport's client, including its credentials, TLS settings and database (the/Nin the transport URL). Otherwise it opens a standalone connection without credentials on DB 0, shared by gates with the same address.budget_key(optional): Redis key to read the dispatch budget from. Default isdispatch-gate-budget.
-
redis-leased-rate:address(required): Redis server address. Reuses theredis-sortedsettransport's client when it matches, as described for theredisgate; otherwise gates with the same address share a standalone client.control_key(required): Redis hash containing the controller's leased rate command.pool_id(optional): Worker-pool ID the command must match. Defaults to the owning worker pool and is required when no owner is available.state_key(optional): Redis hash used by the shared token bucket. Defaults to<control_key>:state.burst_seconds(optional): Token-bucket burst window in seconds. Must be finite and positive; defaults to1.
Configure this as a pool-level gate inside
wait-on-refuse, so a closed lease parks workers in memory and rechecks with bounded jittered backoff instead of repeatedly returning requests to the broker. Ifgate-wait-timeoutelapses, the held request is recoverably re-enqueued rather than completed with an error:[ { "id": "batch-pool", "workers": 64, "gate_type": "wait-on-refuse", "gate_params": { "gate": { "gate_type": "redis-leased-rate", "gate_params": { "address": "batch-gateway-valkey:6379", "control_key": "llm-d-async:drain-limit:batch-pool", "burst_seconds": "0.25" } } } } ]The controller writes the command as one Redis transaction. The field names and values are the public
llm-d.ai/v1alpha1wire contract:MULTI HSET llm-d-async:drain-limit:batch-pool \ api_version llm-d.ai/v1alpha1 \ pool_id batch-pool \ max_admission_rps 12.5 \ valid_until_unix_ms 1787928000000 \ decision_id planner-tick-000042 PEXPIREAT llm-d-async:drain-limit:batch-pool 1787928000000 EXECmax_admission_rpsis a ceiling on attempts sent to the downstream inference endpoint, including retries; it is not a promised completion rate. A value of0is an explicit pause. The lease timestamp is authoritative even if a Redis deployment retains the key longer than requested. The gate fails closed when the key cannot be read or validated, so controllers should renew leases well before expiry. All Async replicas using the samecontrol_keyandstate_keyshare one aggregate token bucket. -
prometheus-saturation: Queries Prometheus for a pool saturation metric. The gate closes (returns0.0) when saturation ≥ threshold; when open it returns(1 - saturation) - (1 - threshold), i.e. the margin below the threshold.pool(required): The inference pool name to filter metrics by.namespace(optional): Kubernetes namespace to scope metric queries. Required when multiple namespaces share the same pool name with a shared Prometheus instance.threshold(optional): Saturation threshold (0.0-1.0). When saturation >= threshold, budget is 0.0. Default is0.8.fallback(optional): Fallback saturation value (0.0-1.0) used when the metric source returns an error or empty data. Default is0.0— i.e. the gate fails open (full budget) by default; setfallbackto1.0to fail closed.
Metric prerequisites: The primary metric source requires llm-d's flow control plugin to be enabled: without it, the EPP flow control metrics will be missing and the gate will always use the fallback value.
-
prometheus-budget: Cascades three Prometheus metric sources to compute a dispatch budget D, using the first that returns a sample:# Metric Budget Available when 0 llm_d_epp_flow_control_queue_sizeD = 1 − (queue_size / max_SYS)EPP runs the flow control plugin 1 llm_d_epp_per_endpoint_queue_sizeD = 1 − (mean per-pod **waiting** requests / max_concurrency)Always — part of EPP's base metric set 2 vllm:num_requests_runningD = 1 − (running_requests / max_SYS)vLLM metrics carry an inference_poollabelSources 0 and 2 compute
max_SYS = ready_pods × max_concurrencydynamically from thellm_d_epp_ready_endpointsmetric. Source 1 averages over pods, so theready_podsfactor cancels and no join is needed. That also keeps it honest when the pool drains: EPP's metrics refresh returns early when the pool has no pods, sollm_d_epp_average_queue_sizeand the other pool averages freeze at their last values and a scaled-to-zero pool would read as idle capacity. Since llm-d-router v0.9.0,llm_d_epp_ready_endpointsis recorded before that early return and drops to0.llm_d_epp_per_endpoint_queue_sizecomes from a scrape-time collector that simply stops reporting, so the source yields no sample and the cascade moves on instead. The gate closes whenD ≤ baseline; when open it returnsD − baseline, so callers computeN = max_SYS × (D − B). See docs/dispatch-budget.md for the full derivation.[!WARNING] Source 1 measures the model server's waiting queue, not in-flight load. The router fills
llm_d_epp_per_endpoint_queue_sizefromvllm:num_requests_waiting: requests the model server has accepted but not yet scheduled. Running requests do not count. vLLM runs up tomax_num_seqs(256 by default) requests per pod before anything waits, so on a stock llm-d router, where source 1 is the one that resolves, the gate closes only once a pod holds aboutmax_num_seqs + max_concurrency × (1 − baseline)requests — roughly 350 with the defaults, not 95. The saturation detector'sMaxConcurrency, whichmax_concurrencyis documented to mirror, counts running plus waiting. Tracked in #501.For in-flight semantics today, use
prometheus-saturationonllm_d_epp_flow_control_pool_saturationwhere the router runs flow control, orprometheus-querywith the EPP's pool averages (no cascade or vLLM fallback, threshold pinned at 0):{"gate_type":"prometheus-query","gate_params":{"pool":"<pool>","fallback":"0", "query":"clamp((1 - (avg by(name)(llm_d_epp_average_running_requests{name=\"<pool>\"} + llm_d_epp_average_queue_size{name=\"<pool>\"}) / 100)) and on() (llm_d_epp_ready_endpoints{name=\"<pool>\"} > 0), 0, 1)"}}100is the per-pod capacity; theready_endpoints > 0guard makes a drained pool yield no sample (the fallback) instead of the frozen averages. Needs llm-d-router v0.11.0 or later.The PromQL each source resolved to is logged at startup (
prometheus-budget metric source), andllm_d_async_async_gate_metric_source_availablereports whether the last evaluation got a reading from any of them or fell back tofallback.pool(required): The InferencePool name. This must match thenamefield inllm_d_epp_ready_endpoints{name="<pool>"}andllm_d_epp_per_endpoint_queue_size{name="<pool>"}(EPP metrics) and, for the vLLM source, theinference_poollabel on scraped vLLM metrics (added via relabeling from pod labels).namespace(optional): Kubernetes namespace to scope metric queries. When omitted, each source requires its matching metrics to identify a single namespace. An ambiguous source returns no samples, so the cascade tries the next source; if none resolve, the configuredfallbackapplies (default0). Set this explicitly when a shared Prometheus instance contains same-named pools in multiple namespaces.max_concurrency(optional): Per-endpoint request capacity (MaxConcurrencyin the inference scheduler's saturation detector). Default is100(matching the inference scheduler default). See sizingmax_concurrencybelow — this is a per-pod number, and setting it above what a pod actually serves makes the gate inert.baseline(optional): Reserved baseline B. The gate closes when D ≤ B. Default is0.05.fallback(optional): Fallback budget value (0.0-1.0) returned when all metric sources are unavailable. Default is0.0(fail closed).
Sizing
max_concurrency. Every source in the cascade divides bymax_concurrencyper pod — sources 0 and 2 divide pool-wide load bymax_SYS = ready_pods × max_concurrency, source 1 averages per pod first — so whichever one resolves, the gate closes only once load reaches:max_concurrency × (1 − baseline) concurrent requests per ready podAt the defaults that is 95 concurrent requests per ready pod. A pool that never gets near that — a large model on a few replicas, for instance — leaves the gate permanently open, so every batch request dispatches regardless of live traffic. The gate logs its resolved closing point at startup so you can compare it against reality:
"prometheus-budget gate configured" pool=... maxConcurrency=100 baseline=0.05 closesAtLoadPerReadyPod=95Two ways to pick a value:
-
Match the EPP.
max_concurrencymirrorsMaxConcurrencyin the inference scheduler's saturation detector. Using the same number keeps the async gate and the EPP's own admission control in agreement about when the pool is full. If you have not configured the saturation detector, both defaults are100. This holds for sources 0 and 2; source 1 compares the value against the waiting queue alone (see the warning above), so on a stock router the pool is well pastMaxConcurrencybefore the gate reacts. -
Measure it. Drive your pool to the load you consider saturated and read the per-pod peak:
max_over_time( (sum(vllm:num_requests_running{inference_pool="<pool>",namespace="<namespace>"}) / on() max(llm_d_epp_ready_endpoints{name="<pool>",namespace="<namespace>"}))[1h:] )Set
max_concurrencyto that peak. Values well above it mean the gate never closes; values well below it mean the gate sheds while the pool still has room.
Metric prerequisites: none for source 1, which is why it is in the cascade — the llm-d router's EPP does not enable the flow control plugin source 0 needs, and source 2 filters by the
inference_poollabel, which vLLM does not emit natively. To use source 2, configure Prometheus relabeling to propagate that label from model server pod labels (the helm chart handles this):relabelings: - sourceLabels: [__meta_kubernetes_pod_label_inference_pool] targetLabel: inference_pool
-
prometheus-query: Evaluates a user-supplied PromQL expression directly as the dispatch budget. The expression must resolve to a Prometheus instant vector with a single sample whose value is in [0, 1]. Values outside this range are clamped. Unlikeprometheus-saturationandprometheus-budget, this gate does not construct queries internally — the user provides the complete PromQL expression.query(required): The PromQL expression to evaluate. This is sent to Prometheus exactly as provided. The result is used directly as the dispatch budget (no transformation is applied).fallback(optional): Fallback budget value (0.0-1.0) returned when the query fails or returns no data. Default is0.0(fail closed).pool(optional): The InferencePool the query is about. Purely descriptive — it does not affect the query, it only sets theinference_poollabel onasync_gate_metric_valueandasync_gate_metric_thresholdso you can tell which pool a gauge is reporting on.
-
inference-pool-ready: Holds requests while an InferencePool has fewer ready endpoints thanmin_ready_endpoints, for example while its model servers are scaled to zero. It builds this query from its parameters and runs it likeprometheus-query:max(llm_d_epp_ready_endpoints{name="<pool>",namespace="<namespace>"}) >= bool <min_ready_endpoints>The budget is
1when the pool has enough ready endpoints and0otherwise.maxkeeps an HA EPP (several replicas reporting the same pool) behaving like a single one. The metric is absent until the EPP has an InferencePool and absent when the EPP is down; both take the fallback. Withoutnamespace, the pool name must match a single namespace: when the same name is found in several namespaces, the query returns no samples and also takes the fallback, so a ready pool elsewhere cannot open the gate for one that is scaled to zero.pool(required): The InferencePool name, matched against thenamelabel.namespace(optional): Adds anamespacelabel match. Set it whenever the Prometheus holds pools with the same name in several namespaces; without it, such a name takes the fallback.min_ready_endpoints(optional): Ready endpoints needed to open the gate. Must be>= 1. Default is1.fail_open(optional): Whentrue, a failed query, a missing metric, or an ambiguous pool name lets requests through. Default isfalse(fail closed).
Configure it as a pool-level gate inside
wait-on-refuseso held requests park in memory instead of returning to the broker, and combine it with a saturation or budget gate in acompositeso "is anything there?" and "is there room?" are checked together:{ "gate_type": "wait-on-refuse", "gate_params": { "gate": { "gate_type": "composite", "gate_params": { "gates": [ {"gate_type": "inference-pool-ready", "gate_params": {"pool": "my-pool"}}, {"gate_type": "prometheus-budget", "gate_params": {"pool": "my-pool"}} ] } } } }The gate lags the pool by roughly the EPP metrics refresh (5s by default), the Prometheus scrape interval and the gate cache TTL. Requests dispatched inside that window take the normal retry path. Held requests still expire at their deadline.
-
endpoint-scrape: Scrapes a raw Prometheus text-format/metricsendpoint directly. Normalizes the metric to[0, 1], then interprets it as saturation by default or as a direct budget whenvalue_typeisbudget. The final budget isclamp(interpreted_budget - baseline, 0, 1). Saturation metrics use1 - normalized_value; budget metrics usenormalized_value.url(required): Full URL to scrape (e.g.,http://vllm-sim:8000/metrics).metric(required): Metric name to extract (e.g.,vllm:num_requests_waiting).labels(optional): JSON object of label filters (e.g.,{"model_name":"my-model"}). Only samples matching all labels are used.value_type(optional): How to interpret the normalized metric.saturationcomputes budget as1 - normalized_value;budgetusesnormalized_valuedirectly. Default issaturation.max_count_per_pod(optional): Per-pod capacity. When > 0, the normalized value isvalue / max_count. When 0, the metric value is assumed to already be in [0, 1]. Default is0.baseline(optional): Reserved headroom subtracted from budget. Default is0.0.fallback(optional): Budget returned when scrape fails or metric is missing. Default is0.0(fail closed).absent_value(optional): Raw metric value assumed when the scrape succeeds but no series matches, for gauges that exist only while there is something to count. EPP drops an idle priority band'sllm_d_epp_flow_control_queue_sizeseries, so a gate on that series needsabsent_value: 0, or it falls back closed and never sends the traffic that would bring the series back. A failed scrape still usesfallback. A misspelled metric name or label reads the same as an idle series, so the first scrape that appliesabsent_valueto a series the gate has never matched is logged. Unset by default.admission(optional):budget(default) admits every request while the latest reading's budget is abovebaseline.countedadmits at most the reading's free slots (max_count - value, in the metric's units) until the next reading, one reading per--prometheus-cache-ttl; it needsmax_count_per_podwithvalue_type: saturationand takes neitherbaselinenorfallback(a failed scrape admits nothing), and--prometheus-cache-ttlmust be greater than 0. A request that finishes, is retried or loses its claim to another replica returns its slot to the reading that admitted it. Usecountedto bound how much a fast dispatcher can send into a queue between readings.pods_url(optional): URL to scrape for dynamic pod count (e.g.,http://epp-svc:9090/metrics). When set withpods_metric,max_count = ready_pods * max_count_per_pod.pods_metric(optional): Metric name for ready pods (e.g.,llm_d_epp_ready_endpoints).pods_labels(optional): JSON label filters for the pods metric (e.g.,{"name":"my-pool"}).
No Prometheus server required. This gate scrapes endpoints directly, making it suitable for deployments without a dedicated Prometheus instance. Use
max_count_per_podwithpods_url/pods_metricfor dynamic scaling, or setmax_count_per_podto a static value for single-pod setups. For a readiness metric where1means ready and0means unavailable, setvalue_typetobudget.With
admission: counted:- Each dispatcher replica keeps its own count, so N replicas together admit up to N times the free slots per reading.
async_gate_metric_valuereports the free-slot count of the last reading, not a value in[0, 1].- The budget is
1while the reading has a free slot and0otherwise.gcp-pubsubrestarts its receiver whenever the budget changes, so a counted gate restarts it on most readings; use it withredis-sortedsetorsql.
-
local-max-concurrency: Limits the number of concurrent in-flight requests processed from a queue locally using thread-safe, in-process state.limit(required): The maximum number of concurrent requests allowed in-flight for this queue. Must be a positive integer.gating_mode(optional):blockingorclassifying. Inblockingmode the worker blocks until capacity frees up; inclassifying(non-blocking) mode a request over the limit is refused (returned to the broker for redelivery). Default isclassifying.
-
redis-quota: Per-attribute quota management via Redis.address(required): Redis server address. Reuses theredis-sortedsettransport's client when it matches, as described for theredisgate.attribute(optional): The message attribute to use for quota (e.g.,userid). Default isuserid.mode(optional):rate-limitorconcurrency. Default israte-limit. Inconcurrencymode each admitted acquire and each release also writes aquota-call:<counter key>:<token>guard that expires after 2 minutes. These keys sit outsideprefix, so a Redis ACL scoped by key pattern must allow them.limit(required): The quota limit. Must be positive.window(optional): The time window for rate limiting (e.g.,1m,10s). Default is1m.prefix(optional): Redis key prefix. Default isquota:.gating_mode(optional):blockingorclassifying. Inclassifyingmode, the gate never blocks but tags the message with its quota status (reservedoroverflow) in the internal metadata — see Reserved and Overflow. Default isblocking.
-
sql-quota(experimental): The same quota asredis-quota, counted in the database of thesqltransport, so it needs no Redis and works only with--transport sql. It takes the same parameters exceptaddress;prefixnamespaces keys in the quota tables, andwindowapplies only torate-limitmode. Limits are exact across every processor sharing the database: each processor sends one query per quota key at a time, and requests that arrive meanwhile share the next query. A rate limit admits at mostlimitrequests in anywindow; gates on the same key with different windows count separately. Concurrency slots belong to the processor that took them and stop counting once it stops heartbeating forlease_ttl_seconds, so a crashed processor's slots come back without a TTL on the counter. -
tier-priority-admission: Implements a three-way admission verdict based on saturation, queue tier, and reservation classification. Saturation is determined by evaluating an inner gate: if the inner gate returnsActionRefuse, the pool is considered saturated. If the pool is saturated: (1) returnsActionWaitif classification isreserved(parking worker threads cleanly); (2) drops immediately with a429status payload if tier isinteractiveand classification isoverflow; (3) otherwise — includingasync/batchoverflow and unclassified requests — returnsActionRefuseto place the request back in the queue. If not saturated, returnsActionContinue.saturation_gate(required): The type string of the inner gate used to evaluate pool saturation (e.g."prometheus-query").saturation_gate_params(optional): JSON-serialized string of parameters for the inner saturation gate.tier_label(optional): The label key to check the queue's SLA tier. Default is"tier".
-
composite: Combines multiple gates. Returns the minimum budget across all inner dispatch gates and acquires quota across all inner attribute gates (all or nothing).gates(required): A JSON array of gate configurations. Each configuration is an object withgate_typeandgate_params.
-
wait-on-refuse: Decorator that wraps a single inner gate and converts anyActionRefuseverdict intoActionWait(parking/polling in-memory instead of immediate broker redelivery).gate(required): A JSON string containing a single gate configuration (withgate_typeandgate_params) to wrap. This can be used to wrap prometheus gates in pool configuration so that they park requests instead of redelivering them to the message broker when the gate is saturated.