Endpoints
Routing policy, doors and admission
How a leader picks a worker, admits and ranks requests, falls back, and how front doors and the cell door put endpoints behind one URL.
The leader routes; the control plane only sets its policy. Each endpoint's policy is a JSON document the control plane writes as policy.json beside the auth snapshot in the endpoint's Secret. The leader applies it live, with no restart.
In short
Each endpoint has a policy: a small JSON document that tells its leader how to pick a worker, how long a request may wait for a free slot, which requests go first when the endpoint is full, and where to send requests when no worker can serve. You read the document, change it, and send it back whole. The leader applies it within seconds, with no restart. Front doors and the cell door are set in the plan and the chart, not in the policy.
When you need it
- Requests get
503at busy moments: raiseadmission.holdMs, or add workers. - Live traffic must win over a batch: list
admission.classes, and give batch keysclass: sheddable. - Long shared prompts (RAG, agents) should hit a worker that already holds them:
prefixAffinity,kvWeight. - A cloud API should answer when your GPUs cannot: set a fallback.
- A leader restart must cost no requests: turn on front doors.
- Clients should call one URL for every model: the cell door.
Do it
Read the policy and its revision
curl -s -H "$H" https://cp.example.com/api/v1/endpoints/<id>/policy > policy.json jq -r .revision policy.json # the same value the ETag header carriesChange only what you need
This example lets a request wait up to 5 s for a slot and keeps a batch class from taking more than a quarter of the slots:
jq '.admission.holdMs = 5000 | .admission.classes = [{"name":"sheddable","maxShare":0.25}]' policy.json > new.jsonpolicy.jsonhas no fallback key in it (theGETnever returns one). LeavingfallbackUrlas it is keeps the stored key.Send it back with If-Match
curl -s -H "$H" -H 'Content-Type: application/json' -H 'If-Match: "<revision>"' -X PUT \ https://cp.example.com/api/v1/endpoints/<id>/policy -d @new.json | jq .admission200with the stored policy means it is applied.409means someone changed it since your read: read it again and repeat.
Check it worked
curl -s -H "$H" https://cp.example.com/api/v1/endpoints/<id>/policy | jq '{admission, fallbackKeySet: .routing.fallbackKeySet}'A good answer shows your values and a new revision. Under load, the leader's metrics opod_admission_held and opod_admission_shed_total move by class. In the console, Routing policies shows the same document for the endpoint.
If it fails
| Symptom | Cause | Fix |
|---|---|---|
409 on PUT | the stored policy changed after your GET | read it again, re-apply your change, send the new revision |
400 naming a field | a value is out of range, a class name is unknown, or a class is listed twice | use the ranges in the tables below |
400 on a fallback change | the URL changed and the key was not resent | resend fallbackKey, or "" for none |
The fallback stopped working after a PUT | on 0.2.1, the body left out routing.fallbackUrl, which clears the fallback | on 0.2.1, send fallbackUrl and fallbackModel on every PUT; from 0.3.0 a field left out is kept |
E-KV-EVENTS | prefixBlockWeight needs plan.kvEvents: true on vLLM or SGLang | turn kvEvents on by a rollout, or leave the weight at 0 |
E-DOOR-ALIAS | the alias is taken, is auto, or names an auto route | another alias |
E-DOORS-NODES (0.3.0) | a pinned gateways.replicas above the nodes that may hold a door | a lower count, or leave it derived |
E-GATEWAY-UNSUPPORTED | the leader image cannot stand behind doors | roll onto a newer leader image |
The policy document
curl -s -H "$H" https://cp.example.com/api/v1/endpoints/<id>/policy # carries a revision and an ETag
curl -s -H "$H" -H 'Content-Type: application/json' -H 'If-Match: "<revision>"' -X PUT \
https://cp.example.com/api/v1/endpoints/<id>/policy -d @policy.jsonThe PUT (operator) replaces the whole document. With If-Match it is applied only while the stored document still has that revision, and otherwise answers 409 having written nothing. Without If-Match it is unconditional. It answers 200 with the stored policy and its new ETag.
What a field left out of the PUT (or sent as null) does. From 0.3.0, every field left out is kept, and an explicit value replaces it: "fallbackUrl": "" clears the fallback (and with it the model and the key), "accessLog": false turns the log off.
| Left out | 0.2.1 | 0.3.0 |
|---|---|---|
routing.fallbackUrl, routing.fallbackModel | cleared — send them back on every PUT | kept |
routing.fallbackKey | kept, when fallbackUrl is unchanged | kept, when fallbackUrl is unchanged |
the routing knobs (kvWeight, kvSaturationPct, prefixAffinity, prefixBlockWeight, speedRank, from 0.3.0 prefixBlockTier and stickyTtlSeconds, and from 0.3.3 loadRefreshMs) | kept | kept |
auth.maxSnapshotAgeSec, admission.holdMs, admission.maxHeld, admission.classes | kept; "classes": [] clears the list | kept; "classes": [] clears the list |
logging.accessLog | turned on | kept |
On 0.2.1, read the document, change it, and send it whole. A GET never returns the fallback key: it answers fallbackKeySet instead. GET /api/v1/policies lists every endpoint's policy you may see.
{
"routing": { "fallbackUrl": "https://api.example.com", "fallbackModel": "gpt-small", "fallbackKey": "…",
"kvWeight": 50, "kvSaturationPct": 90, "prefixAffinity": true, "prefixBlockWeight": 0 },
"logging": { "accessLog": true },
"auth": { "maxSnapshotAgeSec": 0 },
"admission": { "holdMs": 2000, "maxHeld": 64,
"classes": [ { "name": "critical", "holdMs": 10000 }, { "name": "sheddable", "maxShare": 0.25 } ] }
}The console's Routing policies page edits the same document per endpoint. In 0.3.0, opodcp endpoint policy --kv-weight 2 --prefix-affinity on chat changes the named knobs and keeps the rest.
| Section | Fields |
|---|---|
routing | the fallback (below), the worker-choice knobs (below) and speedRank |
logging | accessLog: the leader's access log, on by default |
auth | maxSnapshotAgeSec; see API keys → The snapshot's age |
admission | holdMs, maxHeld, classes[] (below) |
The control plane writes two more parts that no PUT sets. routing.revisions is the traffic split by plan revision while a canary holds; the GET shows it. wake.noResumeInPlace names sleepCard: free sleepers the leader must not resume on their card (0.3.0). Before 0.3.0 the policy also carried a guardrails list; it is gone, and a PUT ignores the key.
How the leader picks a worker
The leader reads each worker's KV-cache use and queue depth from its heartbeat (every 5 s) and ranks the workers. From core v0.4.3, the leader and every front door instead pull each worker's sample every 500 ms (GET /v1/load on the worker; a front door ranked on its own in-flight count before). A pulled sample older than three intervals is not ranked on (the worker is scored on what is in flight), and requests sent after a sample count toward the worker's score. A worker on an older core keeps its heartbeat's sample. /gatewayz lists each worker's sample age under load_samples; /loadz carries the same map from core v0.4.4, and from 0.3.4 the endpoint page shows it under Load: the oldest pulled sample and any worker the leader no longer ranks. It is the leader's view; each front door pulls its own samples. 0.3.4 also shows, under Load, how many requests named a session in the last minute and how often a conversation's pin held, and warns when an endpoint with front doors has traffic and no caller sends X-Opod-Session.
- A worker whose slots are all in flight, or whose KV use is at or above
kvSaturationPct, goes behind every worker with headroom. - Among the rest, the lowest score wins: in-flight + queue depth +
kvWeight× KV used % / 100 −prefixBlockWeight× leading blocks of the request the worker holds. - With
prefixAffinityon, and only when no worker reported holding any block of the request, the worker that last served the longest matching part of the prompt moves to the front, unless it is saturated.
| Knob | Range | Default | Effect |
|---|---|---|---|
loadRefreshMs | 0–60000 | 0 (= 500 ms) | from 0.3.3, with a leader from the core v0.4.3: how often the leader and every front door pull each worker's load; a sample older than three intervals is not ranked on. CLI opodcp endpoint policy --load-refresh 500ms |
tokenWeight | 0–100 | 0 (off) | arrives in the release after 0.3.6, with a leader from the core release after v0.4.8: what 1,000 uncached prompt tokens still in prefill weigh against one request in flight, so a burst of long prompts spreads over the workers; held until the first streamed token, or until the request fails. CLI opodcp endpoint policy --token-weight 0.5 |
prefixDepthKiB | 0, or 4–1024 | 0 (= 256 KiB) | arrives in the release after 0.3.6, with a leader from the core release after v0.4.8: how much of a prompt's leading text the prefix match reads; 4 = the 4 KiB chain from before; a leader without prefix_depth stops at 4 KiB. CLI --prefix-depth 256 |
slowFactor | 0, or above 1 | 0 (off) | arrives in the release after 0.3.6, with a leader from the core release after v0.4.8: a worker whose median time to first token per 1,000 uncached tokens, or median gap between tokens, is more than this many times its siblings' over their last 20 answers ranks down — fewer requests, never none; a model with one worker is never judged; the endpoint page names it under Load, Activity shows "Worker slower than its siblings", and the alert endpoint.worker-slow is open while it lasts. CLI --slow-factor 2 |
kvWeight | 0–100 | 0 (off) | switches the KV term on: how many in-flight requests a full KV cache counts as |
kvSaturationPct | 0–100 | 0 (off) | a worker at or above this KV use goes behind every worker with headroom |
prefixAffinity | true / false | false | pin a prompt prefix to the worker that last served it: a hash chain over the system prompt and every message, in 256-byte links to 4 KiB, then one link at 8, 16, 32 … KiB up to 256 KiB (arrives in the core release after v0.4.8; until then the first 4 KiB only), never the text; pins live 10 minutes, or stickyTtlSeconds |
prefixBlockTier | gpu / cpu-lower | gpu | from 0.3.0: with cpu-lower, a leading block the worker's CPU tier holds beyond its card's counts too, at 0.8 of a card block (a CPU-tier hit measured 0.94–0.96 of a card hit's saving on vLLM); needs kvEvents and a CPU tier |
stickyTtlSeconds | 0–86,400 | 0 (the leader's) | how long a session and a prompt prefix stay on the worker that last served them, in seconds. See Sticky sessions |
prefixBlockWeight | 0–10 | 0 (off) | credit a worker for the leading KV blocks of the request its engine reports holding (16 tokens a block); needs the plan's kvEvents: true (vLLM or SGLang; E-KV-EVENTS otherwise) |
The policy knobs apply live. kvEvents is an engine launch flag, so turning it on or off rides a rollout.
Routing by reported KV blocks is partly proven: on vLLM, on a pool that fits both caches, it tied the prefix pin, so both stay off by default. A choice between two SGLang workers has not been run yet.
The formula, where each worker's KV use comes from, what is hashed, a worked example with four workers and when to use each knob are on KV cache: Routing.
Cache isolation is a plan field, not a policy knob: plan.routing.cacheIsolation is team (default: keys of one team share the prefix cache, teams never do), key or none. The leader salts each request to vLLM, SGLang and TensorRT-LLM with an HMAC of the caller's team or key under the endpoint's admin token, never the id. llama.cpp shares its cache whatever the mode, and the plan says so. A remote endpoint is always none (E-CACHE-REMOTE otherwise). See KV cache: Isolation.
KV-cache strategies
One tab per strategy · interactive
score = in-flight + queue depth + kvWeight × KV used / 100 — lowest wins
kvWeight 0 (the default) only in-flight and queue count: w3 wins. Raise it and a worker with a full cache scores worse. Routing by reported KV blocks (prefixBlockWeight with kvEvents: true, vLLM and SGLang) credits each worker for the leading blocks it reports holding; the prefix pin applies only when no worker is warm. Partly proven.Sticky sessions
From 0.3.0, routing.stickyTtlSeconds keeps an API key's turns on the worker that served its last turn, so the engine reuses that conversation's prefix cache. It also sets how long a prefix pin (prefixAffinity) lives.
- When you need it: multi-turn chat or agents, where each turn resends the conversation so far.
- Default
0: the leader's own value. A control-plane leader has none, so session pins are off and prefix pins live 10 minutes. - Live: no rollout. A pin placed after the policy lands expires by the new value; a pin already placed keeps the expiry it had.
- Soft: a pinned worker that is saturated or drained loses the pin, and the request goes elsewhere.
- A leader without the
sticky_ttl_policyfeature ignores the field. Roll the endpoint onto a newer leader image first. - A conversation, not a key (core v0.4.3). Send
X-Opod-Session: <conversation id>(or the OpenAIuserfield) and the pin belongs to that conversation, so two conversations under one key each keep their own worker. With the core policy'srouting.session.signedRoute, every answer carriesX-Opod-Session-Route; echo it and any front door routes the next turn to the same worker. Withrouting.session.turnPriority, a later turn of an active conversation leaves the hold before a first turn of the same flow, capped so a first turn that waited 8 s still goes first. A pin never lands a request on a saturated worker or one with no free slot. From core v0.4.7 the same pins hold a conversation on its gang when a model has several: the route token then names the gang and its head worker, and is ignored once that head restarted or the gang re-formed on another head. - Session pins need a leader from core v0.4.1 (control plane 0.3.2 pins core v0.4.2). A key the control plane issues has no user id, and core v0.4.0 (the leader 0.3.0 pins) pins only by user id, so on it the field moves prefix pins and no session is pinned.
Set 15 minutes on the endpoint chat
opodcp endpoint policy --sticky-ttl 15m chat # or 900; 0 hands it back to the leaderOr send
"routing": { "stickyTtlSeconds": 900 }in the policyPUT, or set Sticky TTL on the console's Routing policies page.Check it worked
The command prints
sticky ttl 15m0s, and the leader'sopod_router_sticky_hits_total{outcome="hit"}grows as a key's turns return.
| If it fails | Cause | Fix |
|---|---|---|
400 naming routing.stickyTtlSeconds | below 0 or above 86,400 | a value in range |
hit never grows | the requests carry no API key, the leader lacks the feature, or the leader is core v0.4.0, which pins no control-plane key | send a key; roll onto a leader from core v0.4.1 |
Speed rank
routing.speedRank: true (default false) ranks each worker or gang that is not saturated by (its load score + 1) × its own measured seconds per token, so a fast card takes the next request on a quiet fleet. A worker with fewer than 10 answers takes its peers' median, and 1 pick in 20 goes to the least-sampled worker. It needs a leader with the routing_speed_rank feature, and is new in 0.3.0. Set it with the policy PUT.
Admission
The leader dispatches a request to a worker only while that worker has a free slot (llama.cpp's slots, SGLang's running-request limit, vLLM's max_num_seqs, default 256). The rest wait in the leader.
| Knob | Range | Effect |
|---|---|---|
admission.holdMs | 0–60,000 | how long a request waits for a slot before 503 with Retry-After. 0: shed at once when no worker can serve; wait with no deadline when every slot is busy |
admission.maxHeld | 0–10,000 (0 = 64) | how many requests may wait at once |
admission.classes[] | up to three, one per class | per class: name (critical, standard or sheddable), holdMs (0–60,000), maxHeld (0–10,000; 0 = no cap of its own), maxShare (0 = the class default, else a fraction in (0, 1]) |
A value out of range, an unknown class name, or a class listed twice is refused 400 with the rule. A class not listed takes admission.holdMs and no cap of its own. With classes, maxHeld caps every class together. A plan with floor: 0 runs with every hold raised to at least 60 s while it may sleep, from 0.3.0; a longer hold you set stands, and the stored document does not change.
Request classes. With classes listed, waiting requests are served critical before standard before sheddable, and inside a class round the flows (a key's team, else the key) so no flow starves another. A class may hold at most max(1, floor(maxShare × slots)) slots; default shares are 1, 1 and 0.25. That keeps a free slot for a critical request while a batch saturates the endpoint. A key's class is set when it is minted; a caller may lower its class per request with the X-Opod-Class header, never raise it. Overflow and expiry shed the lowest class first.
Per-class leader metrics: opod_admission_held, opod_admission_shed_total (reasons deadline, cap, evicted, unavailable), opod_admission_wait_seconds, opod_admission_in_flight against opod_admission_slots.
Fallback
When the leader has no serving capacity, it forwards the request to fallbackUrl/v1/chat/completions (with fallbackModel and fallbackKey) instead of answering 503, and marks the answer with X-Opod-Fallback.
| Field | Rule |
|---|---|
fallbackUrl | an http(s) URL with a host; required when fallbackModel or fallbackKey is set |
fallbackModel | the model name sent to the fallback |
fallbackKey | write-only; the GET answers fallbackKeySet. "" sends no key |
Example: send overflow to a cloud model when no worker can serve.
jq '.routing += {fallbackUrl: "https://api.example.com", fallbackModel: "gpt-small", fallbackKey: "<vendor key>"}' policy.json > new.json
curl -s -H "$H" -H 'Content-Type: application/json' -X PUT https://cp.example.com/api/v1/endpoints/<id>/policy -d @new.json \
| jq '.routing | {fallbackUrl, fallbackModel, fallbackKeySet}'
# {"fallbackUrl":"https://api.example.com","fallbackModel":"gpt-small","fallbackKeySet":true}A stored fallbackKey is never sent to a different host: a PUT that changes the URL without resending the key is refused 400; resend the key, or "" for none. A PUT with no fallbackUrl clears the whole fallback.
Front doors
Front doors are stateless copies of the leader's request path in front of one endpoint. With doors on, clients call the doors, and a leader restart (about 10 s) costs no requests: the doors keep serving from their mirrored worker list.
gateways: { enabled: true } # count = max(2, ⌈units / 4⌉), capped by max (default 8)A unit is one worker or one gang. A gang counts once however many GPUs it spans, because a door sends each request to the gang's head and the head drives the other parts. So one 12-part gang gets 2 doors, two 4-part gangs get 2, and 12 single-GPU workers get 3. Until the release after 0.3.6 the count reads every gang part as a worker (that 12-part gang gets 3 doors). Pin the count with replicas if you need a different one.
opodcp endpoint doors --max 4 chat on
opodcp endpoint placement chat # where the leader and each door run, and whygateways field | Default | Meaning |
|---|---|---|
enabled | false | turn the doors on |
replicas | 0 (derived) | pin the count; you then own it |
max | 8 | cap the derived count |
An endpoint parked at zero keeps its doors: they answer the first request and wake it. Doors cost cluster CPU, never the ledger, the licence or the team quota. The status carries gateways[], doorsWanted and doorsAsked.
opodcp endpoint doors and opodcp endpoint placement are new in 0.3.0, as do the per-node cap below and its refusal. One endpoint's doors stay on different nodes, so no more doors run than nodes that may hold one: the count is capped and the plan says so (doors.capped); a pinned replicas above it is refused E-DOORS-NODES. Doors need a leader that supports them (E-GATEWAY-UNSUPPORTED otherwise). As a rule: one node that may hold a front — doors off; two — doors if a leader restart must cost nothing; three or more — doors on for production.
The cell door
The cell door is one URL for every endpoint of the cell that names an alias. The request's model chooses the endpoint.
helm upgrade opodcp … --reset-then-reuse-values --set door.enabled=truedoor: { alias: chat } # in each endpoint's plan; unique in the cell (E-DOOR-ALIAS)An alias is a name a client can send as model: letters, digits and . _ : / -, at most 128 characters, starting with a letter or digit. It may be the model's own id. E-DOOR-ALIAS refuses an alias another endpoint holds (two endpoints of one model are two names), the name auto, and the name of an auto route.
Clients call Service <release>-door (port 8080) with model: chat. GET /api/v1/cell carries doorUrl. The door is the leader image run as opod up --role door: a name lookup that forwards each request unchanged to that endpoint's leader. It holds no credential; the endpoint's leader checks the key, and the door's GET /v1/models lists only the aliases whose endpoint accepts the caller's key. The control plane writes the routes into ConfigMap <release>-door-routes on every plan change; the door re-reads it every 10 s and keeps the last good routes while the control plane is down.
| Value | Default | Meaning |
|---|---|---|
door.enabled | false | run the cell door |
door.replicas | 2 | one per node, never more than nodes that may hold a front; from 0.3.0 the door is placed by the same rule as leaders |
door.image | the chart's leader image | must be a leader that knows the door role |
door.service.type, .port, .nodePort | ClusterIP, 8080 | NodePort to reach it from a LAN |
For example, two doors reached on a node port from your LAN:
helm upgrade opodcp … --reset-then-reuse-values --set door.enabled=true --set door.replicas=2 \
--set door.service.type=NodePort --set door.service.nodePort=30090Auto routes
Auto routes are new in 0.3.0. An auto route is a name (for example auto) that the door resolves to several endpoints in your order, falling back down the list when one cannot take the request. A request that carries tools goes only to endpoints whose model can call tools.
curl -s -H "$H" -H 'Content-Type: application/json' -X PUT https://cp.example.com/api/v1/door/auto-routes \
-d '{"routes":[{"name":"auto","endpoints":["chat-large","chat-small"],"pick":"first","maxHops":1}]}'| Field | Meaning |
|---|---|
name | what a client sends as model |
endpoints[] | the candidates' door aliases, the first tried first |
pick | first (the order as written, the default) or least-loaded (each candidate leader's own /loadz) |
maxHops | fallbacks one request may take: 0 means the door's default of 1, at most the number of endpoints minus one |
The PUT (admin) replaces the whole list and answers {"routes": [ … ]}; GET /api/v1/door/auto-routes reads it. Invalid routes are refused E-DOOR-AUTO, and so is any route on an install with no cell door. In 0.3.0, opodcp door routes prints the list and opodcp door routes -f routes.yaml replaces it. Give clients a route key so every endpoint on the route accepts them; see API keys.
Last updated · Source: content/docs/control-plane-endpoints/routing.mdx · View as Markdown