Load support
OpenGateLLM routes requests to self-hosted models. Under heavy load, an inference engine can crash. Load support exists to prevent that. The gateway measures how busy each provider is, and a limit tells it when to stop sending that provider new requests. A request that cannot be admitted waits in the gateway instead of being forwarded to a saturated engine.
Measuring load
Section titled “Measuring load”The load of a provider is the number of requests OpenGateLLM is currently forwarding to it. The gateway measures it only for providers with a qos_limit, and counts those requests itself. It does not ask the inference engine, so the same measure applies to every such provider, including one that is already failing and can no longer report its own state.
The count also has to stay correct when the process that owns the request disappears:
- A FastAPI worker can be killed while a request is still in flight. A counter that lives only in that process would never be decremented.
- The client can cancel the request. The load must drop even when the handler does not reach its usual cleanup.
Each admitted request is an entry in Redis. For the whole forward, the worker refreshes that entry with a heartbeat. The entry dies when the heartbeat stops. When forwarding ends — the provider responds, or the client cancels — the gateway removes the entry. If the worker is killed first, nothing removes it: the heartbeat is no longer refreshed, so the entry expires on its own. The next admission also drops entries that have already expired.
That count is what a limit is compared to.
If Redis is unreachable, the gateway does not reject the request: it forwards it to a random provider that is not closed, without enforcing the limits and without counting it. Closed providers (qos_limit = 0) stay excluded. The same happens when the Redis user is denied a command the limits need, but since that is a configuration error, which does not go away by itself, the API logs an error at startup and on every request instead of once. See the Redis permissions.
Quality of Service
Section titled “Quality of Service”Quality of Service (QoS) is the load-support mechanism available today. It uses the Redis load above to cap each provider and to choose which provider receives the next request.
Provider limit
Section titled “Provider limit”Configure the cap with qos_limit on the provider. OpenGateLLM does not compute this number.
Choose it by load-testing the deployed model: raise concurrency until the engine fails, or until the quality you require is no longer held — time to first token (TTFT) and throughput.
null(default): no cap. The provider stays eligible, and its load is not recorded. Health staysgreenwhile the provider is live.0: closed. The provider cannot receive requests, and health isred.- Positive integer: maximum number of concurrent requests. The cap is enforced only when the router asks for it.
Waiting for capacity
Section titled “Waiting for capacity”Configure what a saturated request does with qos_retries_before_reject on the router:
null(default): do not enforce positive caps. Load is still recorded, so provider selection and health can use it. A closed provider (qos_limit = 0) stays ineligible.0: return 503 as soon as no provider has capacity.- Positive integer
n: retry admissionntimes, every 0.5 seconds, then return 503. The request waits in the gateway. It is sent on only when a provider is under its limit.
When every provider of the router is closed, the request gets a 503 at once, without waiting for retries: no provider could ever accept it.
Choosing a provider
Section titled “Choosing a provider”The router does not take a strategy: OpenGateLLM infers it from the qos_limit of its eligible providers (closed providers excluded).
- Every eligible provider has a limit: the request goes to the provider with the lowest load rate, its active requests divided by its
qos_limit. When two providers have the same load rate, the one with the most free slots (qos_limitminus its active requests) comes first. When they also have the same number of free slots, one of them is picked at random. - At least one eligible provider has no limit: load rates cannot be compared, so the request goes to a provider picked at random, without looking at its load.
The open providers of a router must all have a qos_limit, or none of them. Creating or updating a provider that would break this rule is rejected with a 400, and so is a model of the configuration file that breaks it when the routers are created at startup. A closed provider counts on neither side, so closing one is always accepted.
To switch a router from one mode to the other, close (qos_limit: 0) or delete its other providers, change the last open one, then reopen the others in the new mode. A router that already mixed both before this rule keeps working, with its providers picked at random. Updating one of its providers is accepted only when the provider ends up closed, or in the same mode as every other open provider: close the providers of the other mode first.