Analyzing Compute Bottlenecks in LLM Serving: KV Cache and Concurrency Scheduling Strategies
As large language model (LLM) applications scale, interactive AI services face severe infrastructure challenges, particularly during high concurrency. This article delves into the underlying inference mechanisms of LLMs to analyze the root causes of compute and memory bottlenecks. It explores the lifecycle and scheduling challenges of KV Cache, the trade-offs between recomputation and storage I/O, and outlines general optimization strategies—including memory paging, storage-compute separation, elastic scaling, and continuous batching—to help developers improve system throughput and stability.
With the widespread adoption of large language models (LLMs), interactive AI services like chatbots are facing increasingly severe infrastructure challenges. Recently, an LLM platform suspended some premium services due to compute resource constraints, highlighting the resource scheduling bottlenecks in high-concurrency inference scenarios. In the era of chatbots, the core resources determining peak concurrent user limits are often GPU compute power and its associated memory capacity. Starting from the underlying inference mechanisms, this article analyzes the technical reasons behind compute shortages and explores strategies to address them.
1. The Trade-off Between Compute and Memory During Inference
The LLM inference process is generally divided into two main stages: Prefill and Decode. During the Prefill stage, the system processes the user’s prompt, which is highly compute-intensive and parallelized, pushing GPU compute units (like Tensor Cores) to full capacity. In the Decode stage, the model generates tokens one by one. This process has lower compute density, and the bottleneck often shifts to GPU memory bandwidth.
In chatbot services, the number of tokens output per second (throughput) directly dictates user experience and system efficiency. The GPU must operate near full capacity: as long as compute allows, the system quickly completes the current user’s query, offloads its KV Cache, and loads the next user’s request to continue generation. From a resource scheduling perspective, the GPU compute resources and memory capacity directly determine how many active concurrent users can be maintained during peak hours.
2. KV Cache Lifecycle and Scheduling Challenges
KV Cache is a critical technology for accelerating LLM inference. By caching the intermediate states of the attention mechanism from historical conversations, it avoids the overhead of recomputing all previous tokens for each new generation. However, this space-for-time strategy imposes significant memory pressure. As context length increases, the size of the KV Cache grows linearly or even exponentially.
Under resource constraints, memory becomes a more sensitive metric than raw compute. If memory capacity is insufficient to support massive concurrency, the system must rely on compute “speed” to compensate for “space” scarcity—generating tokens faster to quickly complete current requests and free up memory for new ones. This “compute-for-space” strategy is quite effective in short conversation scenarios.
However, in real-world operations to meet the access demands of more users, systems often adopt aggressive KV Cache eviction policies. Statistically, many chatbot sessions are “one-off” in nature, such as querying “what is the weather tomorrow” or “details of a recent news event.” The probability of users repeatedly utilizing a single session is relatively low, and even for long conversations, the frequency of multiple iterations within a day is not high. Therefore, the system tends to prioritize evicting idle KV Cache, allocating the precious memory to actively generating new requests.
3. Trade-offs in Cache Reconstruction and Storage-Compute Separation
Once the system actively evicts the KV Cache, if a user later reactivates a historical session, the system faces two choices: load from persistent storage or recompute from scratch.
- Recomputing from scratch: This involves going through the Prefill stage again with the complete chat history. While this method requires no additional storage space, it consumes significant GPU compute. During peak hours when compute is already scarce, this undoubtedly exacerbates system load and leads to response latency.
- Loading from persistent storage: Reloading the temporarily stored KV Cache from storage media like SSDs back into GPU memory. This method saves compute but is limited by PCIe bandwidth and storage I/O performance. In cases of extremely long contexts, the loading latency cannot be ignored.
At the system design level, both methods introduce additional overhead. However, during peak periods with extreme compute scarcity, “just bite the bullet and recompute” often becomes the reluctant choice, which is essentially a compromise between compute and storage I/O.
4. General Optimization Strategies for Peak Compute Shortages
Facing these challenges, developers and enterprises need to introduce more efficient resource management solutions at the architectural level to enhance overall system capacity.
1. Memory Paging Management Technology
Borrowing the virtual memory paging mechanism from operating systems, the industry has widely adopted general solutions like PagedAttention. This approach divides the KV Cache into fixed-size blocks, effectively solving memory fragmentation issues. It allows multiple concurrent requests to share memory space at a finer granularity, significantly improving memory utilization under high concurrency.
2. Storage-Compute Separation in Cloud-Native Architecture
On general cloud platforms, adopting a storage-compute separated architecture is an effective way to alleviate compute tension. For instance, using high-performance object storage or parallel file systems provided by Baidu AI Cloud can efficiently persist inactive KV Cache. When a user reactivates a conversation, the cache is quickly pulled to the GPU node via high-bandwidth networks, significantly reducing the compute consumption caused by recomputation. This architecture allows compute clusters and storage clusters to scale independently, enhancing resource utilization flexibility.
3. Elastic Computing and Cluster Scheduling
To handle traffic spikes, a single fixed cluster is often inadequate. Relying on container platforms like CCE or elastic scaling services from Baidu AI Cloud, enterprises can dynamically spin up additional inference nodes based on real-time monitored GPU utilization and concurrent request queue depth. Combined with load balancing and logging services, the system can automatically distribute overflow traffic to new nodes, ensuring high overall service availability even during compute shortages.
4. Batching Optimization at the Inference Engine Level
Through Continuous Batching technology, the system can dynamically insert or remove requests during the Decode phase without waiting for all sequences in the current batch to finish generation. This dynamic scheduling strategy keeps the GPU in a high-throughput state at all times, maximizing the concurrent service capacity of each GPU card.
5. Conclusion
The phenomenon of LLM services throttling due to compute shortages is essentially a concentrated manifestation of the trade-off between compute, memory, and storage I/O in LLM inference architectures under massive concurrency. The KV Cache scheduling strategy directly determines the system’s throughput ceiling and user experience. For developers and enterprises, simply piling up GPU compute is not a long-term solution. Introducing advanced memory paging technologies, building cloud-native storage-compute separated architectures, and implementing dynamic elastic scaling and batching optimizations are the general technical solutions to break through concurrency bottlenecks and achieve stable, cost-effective LLM services.
