LLM Chat Service Compute Bottlenecks: Causes and Optimization Practices
Large language model (LLM) chat services often hit compute limits under peak traffic, forcing platforms to throttle registrations or suspend certain benefits. This article explains the engineering reality behind those apparent "capacity constraints": the two-phase inference process of prefill and decode, how KV cache drives GPU memory consumption, and why compute sets the ceiling on peak concurrency. It also covers why conversational KV cache is highly disposable and recoverable, then walks through practical optimization strategies—KV cache eviction and offloading, continuous batching, prefix cache reuse, request scheduling and rate limiting, and elastic scaling with tiered service—along with engineering advice on capacity modeling, observability, layered optimization, and cost control.
In recent years, conversational services built on large language models (LLMs) have spread rapidly. When users flood in during peak hours, many platforms temporarily tighten new-user registration or pause certain membership benefits to relieve concurrency pressure. On the surface this looks like a “compute shortage,” but from a systems engineering perspective, it reflects a whole set of technical trade-offs around inference resources, GPU memory management, and request scheduling. Understanding these mechanisms helps developers and enterprises plan capacity, control costs, and keep services stable.
1. The Two Phases of Inference: Prefill and Decode
LLM text-generation inference is generally split into two phases:
- Prefill: The model processes the user’s entire prompt in parallel, computing representations for all input tokens at once. This phase has high parallelism, is bound primarily by compute (FLOPs), and is compute-intensive.
- Decode: The model generates output autoregressively, token by token, based on what has been produced so far, re-reading the context for every new token. This phase has low parallelism, is bound primarily by GPU memory bandwidth, and is memory-intensive.
This distinction is critical: what usually determines how many tokens can be emitted per second is the decode phase, and the decode bottleneck is not raw compute but the bandwidth cost of repeatedly reading the growing context into the compute units.
2. KV Cache: The Main Source of Memory Usage
During decoding, to avoid recomputing the attention intermediate results of historical tokens, the inference engine caches the Key and Value tensors of each token. This is the KV cache. Its memory footprint can be approximated as:
KV cache memory ≈ 2 × number of layers × number of attention heads × per-head dimension × sequence length × concurrent batch size × bytes per element
As the formula shows, KV cache size grows linearly with sequence length and concurrent batch size. When many users hold long conversations online at once, the KV cache rapidly consumes GPU memory. Once memory is exhausted, new requests cannot be admitted, and service capacity hits its ceiling.
3. How Compute Sets the Peak Concurrency Ceiling
For chat services, what truly determines how many users can be served simultaneously is the system’s processing throughput per unit time. Think of it as an assembly line: producing each token consumes time on the compute units, and the decode phase is further constrained by bandwidth. As a result, a given amount of GPU resources corresponds to an upper limit on how many users can be served in parallel.
A common engineering observation: a slight shortage of memory does not necessarily make the service unavailable. As long as decoding is fast enough, the system can finish the current user’s output quickly, release that user’s KV cache, and load the next request to keep producing tokens. In other words, resource pressure fundamentally comes down to whether the total volume of requests the system can advance per unit time—within acceptable latency—keeps pace with the rate at which requests arrive.
4. The Disposability of KV Cache and Session Characteristics
Fortunately, unlike many tasks that must maintain long-term state, the KV cache in conversational scenarios is highly disposable:
- Many sessions are “one-off.” Queries like “Will the weather be good tomorrow?” or “What did a certain public figure eat yesterday?” are often asked once and then dropped, with a low probability of reusing the same session.
- Even when long conversations exist, users may not revisit them repeatedly in a short time. A topic discussed today may not be picked up again for several days.
This creates an important degree of scheduling freedom: when concurrency pressure is high, the system can first discard some KV caches to free up memory, prioritizing availability for more users. When a user returns later, the system can:
- Restore the cache from external storage such as SSD (cache offloading);
- Or simply accept the cost of “recomputing from scratch,” re-running prefill with the conversation history.
5. Optimization Strategies for Compute Pressure
With the mechanisms above in mind, compute pressure can be eased at several levels:
1. KV cache eviction and offloading. Use paged memory management to organize the KV cache in blocks, allocating and reclaiming them on demand to reduce fragmentation. For temporarily idle sessions, offload their caches to CPU memory or SSD and swap them back when needed.
2. Continuous batching. Unlike static batching, where a whole batch enters and leaves together, continuous batching schedules dynamically at the token level: as soon as one user’s request finishes, it exits, and its free slot is immediately filled by a new request, significantly improving GPU utilization and overall throughput.
3. Prefix cache reuse. Many conversations share the same system prompt or long-document context. Keeping and reusing the KV cache for this common prefix avoids repeated prefilling and reduces both compute and memory overhead.
4. Request scheduling and rate limiting. Introduce queuing, prioritization, and rate-limiting mechanisms to smooth traffic during peak hours and prevent sudden bursts from overwhelming capacity. For very long-context requests, set length limits or apply chunked processing.
5. Elastic scaling and tiered service. Using the auto-scaling of container platforms, dynamically add or remove inference instances based on real-time load. Through tiered membership, quotas, and differentiated SLAs, prioritize resources for core users and high-value requests.
On cloud platforms such as Baidu AI Cloud, these capabilities are typically delivered together through general-purpose product categories: the container platform handles elastic orchestration of inference services, object storage archives offloaded cache data, message queues smooth out request peaks, and logging and monitoring/alerting help teams observe throughput, memory usage, and queue latency in real time and adjust scheduling strategies promptly.
6. Engineering Practice Recommendations
- Build a capacity model: Based on average and peak QPS and average input/output lengths, estimate the required memory and compute, and reserve headroom for sudden traffic spikes.
- Observability first: Monitor decode throughput, memory levels, cache hit rate, and request queue time, and let data drive decisions.
- Layered optimization: First improve utilization with continuous batching and prefix caching, then consider offloading and scaling, and only as a last resort restrict service availability.
- Cost awareness: Cache offloading, on-demand scaling, and tiered service are fundamentally about finding the right balance between user experience and cost.
Conclusion
A “compute shortage” is never an isolated resource problem; it is the combined result of the two-phase nature of inference, KV cache management, request scheduling, and capacity planning. The KV cache of chat services is naturally disposable and recoverable, which gives engineering teams substantial room for optimization. With fine-grained cache management, continuous batching, and elastic scheduling, a platform can support much larger concurrency under limited compute. For developers and enterprises looking to self-host or manage LLMs, the fundamental way to weather traffic spikes is to build a solid foundation in capacity planning, observability, and scheduling strategy.
