LLM Inference Concurrency and KV Cache Scheduling Under Compute Constraints

    When a conversational AI service starts throttling concurrency because it runs short on compute, the immediate assumption is usually "we're out of GPUs." This article explains why the real limiter on peak concurrency for a chatbot is typically not VRAM capacity but GPU compute and memory-bandwidth throughput. It walks through the two inference phases (prefill and decode), why decode dominates wall-clock time despite low compute utilization, and how the KV cache acts as a rebuildable intermediate state that can be discarded. It then covers continuous (in-flight) batching, the trade-off between swap-out and recompute, a practical capacity-planning formula for estimating peak concurrency, and the engineering capabilities needed in production such as autoscaling, tiered rate limiting, observability, and cache-hit optimization.

    1. Why Compute Is the Hard Constraint for LLM Serving

    When a certain conversational AI service hits compute pressure and has to tighten how many concurrent users it accepts, the public’s first reaction is usually “the servers aren’t enough.” For developers, though, there’s a more precise diagnosis: what determines a chatbot’s peak concurrency is usually not VRAM capacity, but GPU compute and memory-bandwidth throughput.

    The reason is straightforward. The lifecycle of a chat request can be abstracted as “accept request → generate tokens → release state → serve the next user.” During the generation phase, every token the system emits brings that user one step closer to completion; once generation finishes, the corresponding session state (mainly the KV cache) can be reclaimed, and the freed compute is immediately put to work on the next queued request. So how many users a single GPU can hold at any given moment is fundamentally supported by the throughput metric of “how many tokens can be emitted per unit of time” — VRAM size only decides how many copies of that state the loop can hold simultaneously.

    2. What the GPU Is Actually Doing: Prefill and Decode

    To understand scheduling strategy, you first have to see the two phases of inference clearly, because their performance characteristics are completely different:

    • Prefill phase: processes the user’s entire prompt at once, feeding all tokens into the model in parallel. This phase is compute-bound — GPU compute is maxed out and matrix-operation throughput is pushed to the limit.
    • Decode phase: generates autoregressively token by token, processing only one new token per step. This phase is memory-bandwidth-bound — compute is not actually saturated; what really slows things down is the bandwidth cost of continuously fetching model weights and the KV cache from VRAM.

    The key conclusion is this: even though the decode phase has low compute utilization, it accounts for the vast majority of the wall-clock time of a conversational service. The “typing speed” users perceive is almost entirely determined by decode throughput. This means the lever for improving concurrency is not simply stacking more VRAM, but keeping the GPU as busy as possible processing requests from many different users in parallel during decode, pushing memory bandwidth to its limit.

    3. KV Cache: A Discardable “Intermediate State”

    To avoid recomputation, autoregressive generation caches the Key/Value vectors of historical tokens — this is the KV cache. It is the biggest VRAM consumer in the decode phase: the larger the cache, the longer the context, and the more concurrent requests, the more its usage grows — linearly or even more steeply.

    But the conversational scenario has a property that is highly favorable to scheduling — most sessions are one-off, and the KV cache is rebuildable. For queries like “Will the weather be good tomorrow?” or “What did so-and-so eat yesterday?”, users typically ask once and then leave, rarely iterating on the same session repeatedly within the same day. Even for long-running conversations, the frequency of a user following up on the same context multiple times within a single day is relatively limited.

    This creates an important engineering degree of freedom: to serve more concurrent users, you can discard part of the KV cache first. When a user comes back to continue a conversation after a long gap, the system either swaps the previous cache back in from persistent storage (such as object storage or a distributed file system), or simply takes the full chat history and runs prefill again. Compared with directly refusing service, this trade-off of “spending a bit of recomputation cost in exchange for a larger concurrency pool” is usually very worthwhile.

    4. Continuous Batching: The Core Way to Trade Memory for Throughput

    What actually lets limited GPUs serve more users is a class of dynamic scheduling techniques like continuous batching (continuous / in-flight batching). Its idea differs from static batching: instead of waiting for a whole batch of requests to be assembled or to finish, it dynamically removes “just-finished requests” and adds “newly-arrived requests” at every decode step, keeping the GPU’s batch within an efficient range at all times.

    A simplified scheduling main loop can look like this:

    1. def scheduler_tick(running_requests, waiting_queue, kv_pool):
    2. # 1. Prioritize letting requests that already hold KV cache keep generating, avoiding needless recomputation
    3. for req in running_requests:
    4. if not kv_pool.has_room_for_next_token(req):
    5. victim = choose_victim(running_requests) # evict by LRU or lowest marginal benefit
    6. swap_out(victim) # swap out to storage or discard outright
    7. # 2. Admit new requests from the waiting queue to dynamically fill the batch
    8. while kv_pool.has_room() and waiting_queue:
    9. req = waiting_queue.pop()
    10. batch.admit(req)
    11. # 3. Run one forward pass to emit this batch's tokens
    12. return model.forward(batch)

    There are three key points: preserve hot caches as much as possible to reduce recomputation, evict cold caches to free up VRAM, and continuously admit new requests to keep the batch full.

    5. Swap-Out or Recompute: Two Ways Back for a Discarded Cache

    When a swapped-out user comes back to continue a conversation, there are two ways to recover, and the trade-off depends on the session’s value and its latency tolerance:

    1. Swap-out / offload: serialize the KV cache and write it to SSD or object storage, then load it back when the user returns. The advantage is that it avoids recomputation; the disadvantage is that it introduces I/O latency, and serializing long context sequences itself has overhead.
    2. Recompute: don’t keep the cache at all; when the user returns, run prefill again with the full history. The advantage is that it’s simple to implement and uses no storage; the disadvantage is that long conversations bring a noticeable time-to-first-token delay.

    A common strategy in practice is: for high-frequency, long-context sessions, lean toward swapping out to fast storage; for one-off, short-context sessions, lean toward discarding outright and allowing recomputation. By giving each session a “hotness score” in the scheduler, you can dynamically decide the fate of its cache.

    6. Do the Concurrency Math: A Capacity-Planning Formula

    Rather than scaling out on a hunch, it’s better to run the numbers first. Peak concurrency can be roughly estimated as:

    1. Peak concurrency ≈ (usable VRAM per GPU − model weights − runtime overhead)
    2. ÷ (average KV cache per request + activation/framework overhead)
    3. × number of GPUs × decode throughput utilization factor

    Here, the “decode throughput utilization factor” reflects how efficient the scheduling is. With the same number of GPUs, good continuous batching yields effective concurrency that is significantly better than naive per-request serial serving. Conversely, when the estimate approaches the ceiling, limiting concurrency, queuing, and degrading gracefully are more responsible choices than simply “powering through” — which is exactly the underlying logic behind why many services choose to periodically tighten availability during compute shortages.

    7. Engineering in Practice: Elasticity, Rate Limiting, and Observability

    To put the above strategies into production, you typically need a full set of supporting capabilities:

    • Autoscaling: with the help of a container platform, automatically scale instances up and down based on metrics like queue length and GPU utilization, so compute is supplied elastically with the load.
    • Tiered rate limiting: do priority queuing and quota control at the entry point, protecting the interactive experience first and avoiding request avalanches that would drag down overall throughput.
    • Observability and alerting: continuously collect metrics such as per-GPU token throughput, KV cache hit rate, and queue latency through logging and monitoring/alerting, providing data support for capacity decisions.
    • Cache-hit optimization: use request routing so that the same session lands as much as possible on the instance holding its cache, reducing cross-instance recomputation.

    Conclusion

    When a conversational AI service tightens concurrency during a compute shortage, it looks like a resource emergency, but at its core it is an engineering problem of scheduling and trade-offs. GPU compute sets the throughput ceiling, while discarding, swapping out, and recomputing the KV cache — along with the high utilization that continuous batching brings — determine how far that extra compute can be squeezed. By understanding the performance differences between prefill and decode, doing the concurrency math, and treating the cache as a rebuildable, temporary state to be scheduled, developers can serve more users on limited compute and make every throttling decision well-grounded and defensible.