Concurrency Limits and Resource Pool Isolation for Large Model APIs

    This article explains why concurrency limits are often more appropriate than QPS quotas for generative AI inference, how to set different limits for different model tiers, and why API traffic should be isolated from end-user traffic. It also covers the scheduling lifecycle, distributed counter design, cancellation and token release, observability, capacity planning, and common implementation pitfalls.

    1. The Starting Point: Concurrency Is Not QPS, and Quotas Are Not Rate Limits

    In inference services, QPS and concurrency are two of the most commonly confused concepts. Queries per second (QPS) describes the request arrival rate over a period of time, while concurrency describes the number of in-flight requests actively occupying execution resources at a given moment.

    For generative models, a single request may take anywhere from hundreds of milliseconds to tens of seconds, with substantial variance. As a result, the concurrency level associated with the same QPS can differ by an order of magnitude. Using concurrency as the quota unit more accurately reflects actual resource consumption and is less vulnerable to long-running requests exhausting capacity.

    Another common mistake is implementing quotas as a single global limit. A global quota is simple, but it allows different callers to compete directly for the same capacity. A burst from a batch job can increase the queueing latency of interactive workloads by several times.

    A more practical design is a two-level structure:

    • Per-account or per-caller quotas for fairness and predictable behavior
    • A global protection limit to prevent the cluster from being overwhelmed

    2. Tiered Quotas: Different Model Tiers Need Different Concurrency Limits

    Inference services commonly provide two broad model tiers. One tier consists of lightweight models for high-frequency, low-latency workloads. These models have lower per-request compute costs and shorter average execution times. The other tier consists of more capable models for complex reasoning tasks, with higher GPU memory and compute requirements and longer execution times.

    Because their cost profiles differ, the two tiers should not share the same concurrency limits. Per-account concurrency limits for lightweight models can be set substantially higher because the same number of requests consumes fewer GPU memory resources and scheduling slots. More capable models require significantly more conservative limits. Otherwise, a small number of long-running requests can occupy the available execution slots and cause queueing latency to deteriorate nonlinearly.

    A practical rule of thumb is to:

    1. Use the resource profile of a single request—including GPU memory usage, average latency, and P99 latency—to estimate the number of concurrency slots a single device can support.
    2. Multiply that capacity by the number of replicas.
    3. Reserve a safety margin, typically keeping utilization below 70%–80%.
    4. Allocate the remaining capacity across callers.

    The safety margin is particularly important. Inference throughput does not increase linearly with concurrency. After a certain inflection point, memory paging and reduced batching efficiency can cause throughput to decline while latency rises sharply.

    3. Resource Pool Isolation: Separate API Traffic from End-User Traffic

    The second major design principle is resource pool isolation. Online services for end users and developer-facing API traffic typically have nearly opposite traffic patterns:

    • End-user traffic has clear daily peaks, strong burstiness, and short interactions. Time to first token is highly sensitive.
    • API traffic often includes batch jobs, long contexts, and automated pipelines. These requests run for longer periods and maintain higher concurrency for a sustained time.

    If both traffic types share the same execution pool, batch jobs can push interactive requests to the end of the queue. This creates a feedback loop: the busier the service becomes, the slower it gets, which causes more requests to accumulate.

    The goal of isolation is to prevent the two traffic classes from sharing:

    • Compute resources
    • Scheduling queues
    • Rate and concurrency quotas
    • Failure and degradation policies

    Three implementation details are important:

    1. Isolation must reach the execution layer. Routing traffic separately at the gateway while sharing the same backend inference processes is not effective.
    2. Each pool requires independent capacity planning. Do not assume that one pool can borrow idle capacity from the other.
    3. Shared dependencies also require capacity analysis. Caches, logging systems, and monitoring infrastructure may become new coupling points even after compute resources have been isolated.

    4. Four Stages of the Scheduling Pipeline

    An operationally manageable scheduling pipeline can be divided into four stages. Each stage should have a focused responsibility and be independently observable:

    1. Ingress and authentication: Identify the caller and determine the quota subject.
    2. Quota validation: Check whether the subject has reached its current in-flight request limit. If not, acquire a token.
    3. Queueing and scheduling: Place over-limit requests into a priority queue, or fail quickly with a clear retryable response according to policy.
    4. Execution and release: Submit the request to the execution pool for the appropriate model tier. The token must be reliably released after success, failure, timeout, or client disconnection.

    Illustrative pseudocode:

    1. # Account-level concurrency quota:
    2. # count by caller and model tier
    3. class ConcurrencyLimiter:
    4. def __init__(self, limit: int):
    5. self.limit = limit
    6. self.inflight = defaultdict(int)
    7. def try_acquire(self, subject: str) -> bool:
    8. key = subject
    9. if self.inflight[key] >= self.limit:
    10. return False
    11. self.inflight[key] += 1
    12. return True
    13. def release(self, subject: str):
    14. # Idempotent release prevents duplicate returns
    15. # from artificially increasing available quota
    16. if self.inflight[subject] > 0:
    17. self.inflight[subject] -= 1
    18. async def handle(request, limiter, pool, model_tier):
    19. subject = auth(request) # 1. Authenticate and identify the quota subject
    20. if not limiter.try_acquire(subject): # 2. Validate quota
    21. return reject_retryable("concurrency_exceeded")
    22. try:
    23. return await pool.submit(model_tier, request) # 3-4. Queue and execute
    24. finally:
    25. limiter.release(subject) # 4. Always release

    Several additional engineering concerns must be addressed:

    • If the counter is stored only in the memory of a single instance, the effective concurrency across multiple replicas may become several times higher than the configured value.
    • To avoid this, use a centralized counter while controlling its own latency, or use consistent hashing at the gateway to route the same subject to the same instance.
    • Client disconnections must trigger cancellation and token release. Otherwise, “ghost concurrency” can gradually consume the available quota.

    5. Observability and Capacity Management

    A quota mechanism without observability is a black box. At minimum, monitor four categories of metrics:

    • In-flight concurrency and over-limit rejection rates by subject and model tier
    • Queue wait-time distributions
    • Execution pool utilization and batching efficiency
    • Token leak indicators, such as requests that remain in-flight without being released for an unusually long time

    Alerts should focus on trends rather than isolated data points. Examples include a sustained increase in rejection rates, a continuously rising queue wait-time P99, or an execution pool that remains near capacity for an extended period.

    Capacity planning should be driven by load testing. Apply traffic in stages to identify the throughput inflection point, then record the concurrency level and P99 latency at that point. Use these results to set quotas and safety margins.

    Recalibration is necessary after every model or inference-stack change. The same numeric quota can represent very different resource usage under different batching strategies.

    6. Common Mistakes and an Implementation Checklist

    Common mistakes include:

    • Using QPS quotas instead of concurrency quotas: This can lead to uncontrolled resource usage when requests are long-running.
    • Isolating traffic only at the gateway: Sharing the same execution processes makes the isolation ineffective.
    • Using one limit for every model tier: High-cost models can increase overall latency and overwhelm shared capacity.
    • Omitting cancellation and release paths: Quota tokens can be silently consumed until the available capacity is exhausted.

    Implementation checklist:

    • Define the quota subject and quota dimensions.
    • Calibrate concurrency limits and safety margins separately for each model tier.
    • Complete resource pool isolation at the execution layer.
    • Implement idempotent release and cancellation propagation.
    • Establish four-dimensional monitoring and trend-based alerts.
    • Iterate on quotas based on load-test results.