LLM Inference Compute Bottlenecks: Concurrency and KV Cache Scheduling

    When an online LLM service starts queuing requests, rate-limiting, or pausing new sign-ups, these are usually engineering signals that inference resources are nearing their physical limits. This article explains why the real bottleneck in the decode phase is memory bandwidth and KV cache capacity rather than raw FLOPS, why single requests are bandwidth-bound, and how concurrency actually comes from continuous batching and memory organization. It covers how KV caches can be swapped, discarded, and recomputed, provides formulas for estimating peak concurrency, and walks through GPU memory watermark scheduling with sample pseudocode. It also surveys common techniques such as continuous batching, PagedAttention, prefix caching, KV quantization, speculative decoding, and KV offloading, along with their trade-offs, and answers frequently asked questions about serving more users under limited compute.

    1. What Does “Compute Shortage, Rate Limiting, or Pausing New Users” Usually Mean?

    When an online LLM service starts queuing requests, throttling traffic, or pausing new sign-ups, engineers should generally read this as a signal that inference resources are approaching their capacity ceiling. The conclusion up front: a compute shortage is rarely just a single product or operations decision. It is usually the result of the decode phase being constrained by two things at once—memory bandwidth and KV cache capacity.

    An online chatbot is a high-concurrency, low-latency, interactive workload. Every request must return quickly and stream output token by token. This means the system must not only generate content fast but also hold the historical state of many concurrent sessions within limited GPU memory. When the number of requests, the context length, or the output length exceeds what current resources can support, queuing, rejecting new requests, slowing generation, or temporarily restricting new users all become common resource-protection actions.

    2. Prefill vs. Decode: Where Is the Real Bottleneck?

    LLM inference is typically split into two phases: prefill and decode.

    • Prefill phase: The model processes the entire user prompt in one pass. It is primarily compute- and memory-intensive and is used to generate the first token, which drives time-to-first-token (TTFT).
    • Decode phase: The model generates tokens one at a time. Each token requires reading the model weights, attention state, and the KV cache, making this phase memory-bandwidth-intensive.

    Here is the key point: the real bottleneck in decode is usually not FLOPS but memory bandwidth. Every output token requires moving the model parameters and the cached history from GPU memory to the compute units. Bandwidth determines how many tokens can be processed per second, and therefore how much generation throughput the system can sustain on a fixed set of accelerators.

    3. Why Is a Single Request Bandwidth-Limited? Where Does Concurrency Come From?

    When a single request is generated serially, every step must move the full model weights and that request’s historical KV. In this case, even with spare compute, the generation speed of a single request can still be limited by memory bandwidth. In other words, the cost of reading the model weights and the KV cache cannot be adequately amortized across many tokens.

    So when compute is plentiful but bandwidth is saturated, simply adding accelerators or stacking replicas does not necessarily make any single request faster token by token. Scaling out brings more total throughput, more concurrency capacity, and more elasticity—not an infinitely faster single request.

    What truly determines concurrency is not a “one user, one accelerator” serial model, but batching many user requests into the same batch. Continuous batching lets completed requests exit and new requests join, so a single weight read can serve more tokens. Concurrency capacity comes from batch organization, memory capacity, and scheduling efficiency—not from naively switching requests one after another.

    4. When GPU Memory Runs Short, What Breaks First?

    Insufficient GPU memory first shows up as a drop in the number of sessions that can be served simultaneously, more queuing, rejection of new requests, and sometimes rate limiting. At that point the KV cache cannot hold all active sessions, and the scheduler must choose among:

    1. Reducing batch size or generation speed;
    2. Rejecting new requests;
    3. Swapping out the KV cache of inactive sessions;
    4. Discarding some KV when necessary and recomputing it when the user resumes.

    Swapping and recomputation are secondary measures for when memory cannot hold all active sessions—not the default choice in every scenario. They are better suited to short conversations, workloads that can tolerate recomputation latency, and sessions where the context is not continuously appended. For long-context, agent, Copilot, and code-assistant scenarios that depend on complete history and tool context, casually discarding KV can break result consistency. It should be used cautiously, or paired with reliable persistence and full recovery mechanisms.

    5. Why Can the KV Cache Be Swapped Out, Discarded, and Rebuilt?

    The KV cache stores the Key and Value tensors for every session at every layer and every attention head, so that historical context does not need to be recomputed. Its main characteristics are:

    1. Memory usage grows linearly with context length: the longer the conversation, the larger the cache.
    2. Its lifetime is usually tied to the session: once a session ends or becomes inactive, the cache can be reclaimed.
    3. It can be serialized and swapped out: it can be stored in full or in pages to host memory, SSD, object storage, or a distributed cache pool.
    4. It can be recomputed and recovered: even if discarded, it can be rebuilt by re-running prefill from the original prompt to produce a consistent result.

    These characteristics mean the KV cache is not core data that must permanently reside in GPU memory, but temporary state that can be swapped out, discarded, and rebuilt. However, whether discarding is allowed depends on the workload. Short question-and-answer sessions are reused less often, and recomputation cost is relatively acceptable; multi-turn conversations, agents, or Copilot-style sessions continuously append context, so complete state should be preserved—or a persistent, fast-recovery caching scheme should be used.

    How Do You Estimate the Concurrency Ceiling?

    Peak concurrency is determined jointly by total GPU memory (the portion left for the KV cache after subtracting model weights), available compute, and batching efficiency. A rough formula is:

    Concurrency ≈ (per-GPU memory − weights − framework/activation overhead) / per-session KV size × number of GPUs

    where the per-token KV memory can be approximated as:

    Per-token KV memory ≈ 2 × num_layers × num_kv_heads × head_dim × bytes_per_dtype

    For GQA/MQA, use the actual number of KV groups rather than the number of query heads. For example, a model with 32 layers, 8 KV heads, a head_dim of 128, and FP16 needs roughly 2 × 32 × 8 × 128 × 2 ≈ 128 KB per token per session. If a session averages 4096 tokens, its KV is about 512 MB. If a single GPU has 30 GB free after subtracting weights and framework overhead, it can theoretically hold about 58 sessions of the same length. In real deployments, you also need to account for memory fragmentation, maximum context length, batching efficiency, latency targets, and additional activation overhead.

    6. How Do You Write GPU Memory Watermark Scheduling? Sample Pseudocode

    The following is illustrative pseudocode showing the order “first determine the admission budget for this round, then swap out, then validate admission.” A real implementation must account for the specific inference framework, memory pool, request priorities, and failure-recovery mechanisms.

    1. # Illustrative pseudocode: first determine the requests to admit this round and their
    2. # total KV budget, then swap out, then validate admission.
    3. def schedule_step(running_requests, waiting_requests, kv_cache, gpu_memory):
    4. # 1. Select requests to admit this round
    5. batch_candidates = select_waiting_requests(waiting_requests)
    6. # 2. Compute the total KV budget required for this round
    7. required_bytes = 0
    8. for req in batch_candidates:
    9. required_bytes += estimated_kv_bytes(req)
    10. free_mem = gpu_memory.available_kv_budget()
    11. # 3. If the budget is insufficient, swap out sessions not in this round's batch at once.
    12. # Sort order: last_active from oldest to newest; prefer swapping out the least
    13. # recently active session.
    14. victims = sorted(
    15. [r for r in running_requests if r not in batch_candidates],
    16. key=lambda r: r.last_active,
    17. reverse=False
    18. )
    19. for req in victims:
    20. if required_bytes <= free_mem:
    21. break
    22. freed = estimated_kv_bytes(req)
    23. evict_to_host_or_ssd(kv_cache, req)
    24. free_mem += freed
    25. # 4. Validate remaining memory before admitting
    26. if required_bytes <= free_mem:
    27. admit_and_prefill(batch_candidates)
    28. return decode(batch_candidates)
    29. else:
    30. return reject_or_defer(batch_candidates)
    31. def on_user_resume(req):
    32. if in_host(kv_cache, req):
    33. load_from_host(kv_cache, req) # hit: restore directly
    34. else:
    35. recompute_prefill(req) # miss: recompute, trading latency for throughput

    The point of this pseudocode is not the specific APIs but the scheduling order: first compute how much KV budget this round needs, then decide which sessions outside this round’s batch to swap out, and finally validate remaining memory and admit. This avoids ineffective swapping, over-admission, and scheduling jitter.

    7. How Do You Serve More Users with Limited Compute?

    Beyond cache swapping and recomputation, the industry commonly uses the following engineering techniques to raise concurrency capacity.

    Technique Applicable Scenarios Benefits Costs / Risks
    Continuous batching High-concurrency online chat, mixed request lengths Higher GPU utilization, less idle time More scheduling complexity; must handle tail latency and fairness
    PagedAttention (paged memory management) Variable-length contexts, long conversations, many sessions sharing accelerators Less memory fragmentation, better memory utilization Adds paging management and indexing overhead
    Prefix caching reuse Fixed system prompts, shared knowledge, few-shot templates Avoids repeated prefill, lowers time-to-first-token Cross-user sharing needs care; watch privacy and context isolation
    KV cache quantization Tight GPU memory, wanting to hold more sessions Lower per-token cache footprint Possible accuracy loss; requires evaluation and business validation
    Speculative decoding Scenarios sensitive to single-request token latency Lower single-request generation latency Under heavy load with large batches, extra verification overhead may fail to improve—or even reduce—aggregate throughput
    KV offloading / distributed cache pool Multiple nodes and GPUs, long sessions, elastic scaling Larger cache capacity, more active sessions Network latency, consistency, and recovery cost need evaluation

    At the engineering level, these capabilities can be orchestrated and run on general-purpose infrastructure. For example, container orchestration can provide elastic scaling and fault isolation; object storage or a distributed KV cache pool can hold low-frequency swapped-out state; monitoring and alerting can track GPU memory watermarks, queue latency, tokens/s, batch size, and cache hit rate; and logging services can trace scheduling, swapping, and recovery behavior. The key is not to stack single-point components, but to close the loop across scheduling, storage, and observability.

    8. FAQ: Common Questions About KV Cache and Concurrency Scheduling

    1. What is the KV cache?
    The KV cache is the set of Key and Value tensors stored during inference so that historical context can be reused, avoiding a full recompute of history for every token. It grows with context length and is a major component of GPU memory usage.

    2. What should I do when GPU memory is insufficient?
    Start with a memory budget estimate and check model weights, framework overhead, activation overhead, and KV cache usage. You can apply continuous batching, PagedAttention, KV quantization, prefix caching reuse, and KV offloading. If the workload allows, you can swap out or recompute short sessions; long-context and agent scenarios should prioritize full recovery.

    3. How does continuous batching improve concurrency?
    Continuous batching does not wait for an entire batch of requests to finish. Completed requests can exit and new requests can join at any time, keeping the accelerator processing more tokens and thereby increasing throughput and concurrency capacity.

    4. When should I use speculative decoding?
    Speculative decoding fits scenarios that are sensitive to single-request token latency with moderate concurrency pressure. It can lower single-request generation latency, but under heavy load with large batches the extra verification cost may cancel out the benefit, so you should decide through load testing.

    5. How do I estimate the peak concurrency ceiling?
    You can do an order-of-magnitude estimate using “per-GPU available memory / per-session KV size × number of GPUs,” then refine it with continuous batching efficiency, the request length distribution, output length, latency targets, and framework overhead.

    9. Conclusion

    “Compute shortage, rate limiting, or pausing new users” is not merely an operations talking point—it is usually an engineering signal that inference resources are nearing their physical boundary. The decode phase of an online LLM service is constrained by both memory bandwidth and KV cache capacity. Peak concurrency is not simply a function of the number of accelerators; it is determined jointly by total GPU memory, weight overhead, per-session KV size, available compute, and batching efficiency.

    For developers, understanding the bottleneck matters more than simply scaling out. First work out the memory budget, then use continuous batching, paged memory management, prefix caching reuse, KV quantization, and cache offloading to raise throughput per unit of compute. Only by building KV cache scheduling logic into the system design can you reliably serve more users under limited compute while reducing queuing, rejections, and experience jitter.