LLM API Concurrency Isolation and Scheduling in Practice

    When public APIs and consumer apps share one inference cluster, bursty API traffic and interactive chat compete for GPUs. This article explains why you need separate resource pools and per-account in-flight limits, which signals the scheduler should use, how to implement three-layer admission control, and how retries, capacity planning, and common pitfalls affect isolation.

    When a public API and a consumer product share the same inference cluster, their traffic looks nothing alike. Client-side requests are short and follow daily usage patterns. Open API traffic is often driven by batch jobs, proxy gateways, or automation, and can spike far above normal concurrency in a short window. If the scheduler does not split the two sides, an API burst raises queue latency and makes chat stall. Conversely, a consumer peak can trigger timeouts and retry storms for API callers. The professional approach is independent API concurrency limits and isolation from the consumer resource pool—not a single global QPS cap.

    Why two resource pools are required

    A concurrency limit answers “how many requests are in flight,” not “how many calls per day.” LLM inference occupies GPU memory, KV cache, and contiguous compute time. A long-context request may hold a worker for tens of seconds. Limiting only calls per minute still allows a burst of concurrent work to fill memory, after which later requests queue or fail.

    Account-level concurrency caps contain blast radius to a single caller. Platforms can set different in-flight limits by model capability, context length, and commercial tier: light, low-latency models allow higher concurrency; heavy, long chain-of-thought models get a tighter per-account cap. Numbers should come from capacity tests and SLOs, not copied from other vendors. In engineering practice, light models often sit in the thousands and heavy models in the hundreds—an order-of-magnitude difference that reflects resource weight, not a fixed standard.

    Pool isolation addresses fairness across product lines. The API pool and the consumer pool use separate worker groups, queues, and quota ledgers. The scheduler applies priority and preemption only inside a pool. Even a high API account cap cannot take consumer GPUs; a consumer peak cannot silently consume sold API quota. Isolation may be physical cards or logical queues with hard reservation. Limits must be enforced at the scheduling ingress, not patched later with alerts.

    Signals the scheduler should use

    A usable admission decision needs at least five kinds of information.

    First, identity and quota subject. After the request hits the gateway, resolve account, sub-account, or application ID to a quota key. In-flight counts must increment and decrement atomically on that key so multi-instance gateways do not oversell.

    Second, model and request cost. The same account hitting different model SKUs should use different limit buckets. Long inputs, high output-token caps, and deep-reasoning requests should count as weighted concurrency, not the same as short requests. Weights can be estimated tokens or historical latency buckets; keep rules simple and explainable.

    Third, pool membership. Routing is decided after auth and before enqueue: open API traffic enters only the API pool; product traffic enters only the consumer pool. Do not use “borrow idle capacity” as the default. If elastic borrowing is required, define water levels, a hard borrow cap, and immediate return conditions, and expose them separately in monitoring.

    Fourth, in-flight and queueing. The concurrency limit counts accepted but unfinished requests. Over the cap, fail fast or enter a bounded queue—do not hang forever. Queue length and queue timeout must align with client timeouts, or client retries will multiply an over-limit event.

    Fifth, health and degradation. When pool error rate, queue latency, or memory water level crosses a threshold, the scheduler should reduce effective concurrency (for example a temporary discount), protect in-flight work, and reject new low-priority traffic. Degradation stays inside the pool and must not spread across pools.

    How to implement the limits

    Split control into three layers with separate duties.

    The ingress layer handles authentication, quota-key resolution, and fast rejection. Unauthorized, exhausted quota, or unsubscribed models return a clear error code and retry hint here so invalid work never reaches inference queues.

    The scheduling layer maintains per-key in-flight counts and pool-wide concurrency. The following pseudocode shows control flow only and is not tied to any vendor API:

    1. on_request(account, model, pool):
    2. key = (account, model, pool)
    3. if pool_inflight[pool] >= pool_cap[pool]:
    4. return reject("pool_busy")
    5. if inflight[key] >= account_cap[key]:
    6. return reject("concurrency_exceeded")
    7. inflight[key] += 1
    8. pool_inflight[pool] += 1
    9. try:
    10. return infer(pool, request)
    11. finally:
    12. inflight[key] -= 1
    13. pool_inflight[pool] -= 1

    Counts must be released when the request truly ends (success, failure, cancel, or timeout). If the client disconnects while the server is still computing, cancel the downstream task quickly, or “zombie” requests will fill the limit.

    The execution layer schedules workers per pool. API and consumer pools may use different queues, batching, and max batch sizes: APIs need per-account fairness and predictable latency; consumer apps need interactive feel and time-to-first-token. Do not mix both sides in one continuous batch just to raise throughput, or isolation holds on paper and fails on the GPU.

    Coordination with retries, timeouts, and idempotency

    Once concurrency limits are live, callers will see “concurrency exceeded” and “pool busy.” Immediate retries with no backoff turn rejections into a new flood. The server should distinguish errors: over-limit is the caller’s own quota and needs longer backoff; pool busy is transient platform capacity and may use short backoff with a hard cap. A suggested wait in the response helps clients align, but it is only a hint, not a billing or contract commitment.

    Timeouts should be layered. Ingress queue timeouts should be short so work is not executed after the client has given up. Inference timeouts follow model SKU; after timeout, release the concurrency count and interrupt compute if possible. For non-idempotent side effects around inference, require an idempotency key before retry. Pure inference reads are safer but should still cap max retries.

    Capacity planning and observability

    Limits are not arbitrary constants. Plan in this order.

    Measure per-request cost: latency, memory, and throughput at target context length to get stable concurrency per GPU. Assign cards to pools to get pool capacity. The sum of account caps may exceed pool capacity because not every account peaks at once, but the designed concurrent load that can hit at once must stay below pool capacity with headroom. Headroom covers node failure, rolling deploys, and long-tail bursts.

    Observe at least: per-pool in-flight, queue depth, queue latency P95/P99, account limit hit rate, reject-reason mix, counters that fail to release after timeout, and GPU utilization on both pools. A hit rate near zero for a long time means limits are too loose and isolation is cosmetic. A persistently high hit rate plus business failures means sold concurrency exceeds what the pool can hold—expand the pool or lower default caps rather than turning limits off.

    Alerts should separate “one account is full” from “the whole pool is full.” The former is tenant behavior (notify the customer or auto-throttle). The latter is a platform capacity event (scale, degrade, or pause new account onboarding). Mixing them leaves on-call unable to decide whether to add machines or constrain one caller.

    Common design mistakes

    Global rate limits without per-account concurrency. A few large customers fill the global cap and small customers fail even at low usage; marketplace fairness is gone.

    Isolating queues but not execution resources. Requests wait in different queues then share the same GPUs and steal memory; latency isolation fails.

    Counting “request count” instead of in-flight. Long requests are few but heavy; short requests are many but finish fast. Cluster pressure is not the same.

    Not decrementing on failure, or not propagating cancel to the inference process. Limits leak until every new request is rejected and it looks like capacity is gone.

    Unlimited API borrowing from the consumer pool for utilization. Without a hard cap, launch days and event days still hurt each other and isolation is bypassed.

    Copying another vendor’s published concurrency numbers into your config. Model size, context, batching, and hardware generation differ. Someone else’s 2500 or 500 only shows that light and heavy models can differ by an order of magnitude—not your cluster’s capacity.

    Suggested rollout order

    First, stamp open API and consumer traffic with unforgeable pool tags, measure real concurrency and latency on both sides, then cut over. Second, give the API pool its own queue and per-account in-flight counters; reject immediately on overflow with distinct error codes. Third, split limit buckets by model SKU—stricter on heavy models, looser on light—and calibrate pool capacity with load tests. Fourth, add cancel propagation, counter reconciliation, and alerts; periodically check counters against real in-flight work. Fifth, consider limited temporary borrowing between pools; do not add elastic borrow until reconciliation and alerts are reliable.

    In that order, scheduling moves from “global best effort” to independent API concurrency limits and hard isolation from the consumer pool. Callers get predictable failure semantics; the platform gets explainable capacity bounds; the two experiences stop dragging each other down. For a stable public inference API, this engineering hygiene matters more than simply growing the cluster.