How GPU Compute and KV Cache Capacity Determine LLM Inference Concurrency
The concurrency limit of a large language model service is governed by two primary resources: GPU compute throughput and GPU memory available for KV Cache. This article explains how Prefill and Decode consume resources differently, how KV Cache limits concurrent requests, and how techniques such as continuous batching, paged cache management, prefix caching, quantization, admission control, and capacity planning affect system performance. It also provides practical guidance for developers and enterprise users dealing with rate limits, latency, and peak demand.
1. Where Does the Concurrency Limit Come From?
In conversational large language model services, the number of users that can be served at the same time is usually determined not by the total number of users, but by two types of resources:
- GPU compute throughput
- Available GPU memory
The more tokens a model can generate per second, the less time each request occupies compute resources. The service can then complete requests faster, release resources, and accept new requests.
When available compute cannot keep up with demand, users may experience longer queue times, slower generation, or rejected new requests. These symptoms generally have common engineering causes. Understanding them helps explain service fluctuations and design more reliable workloads.
This article does not evaluate the business decisions of any specific provider. It focuses only on general inference engineering principles.
2. Breaking Down Inference: Prefill and Decode
Generating a response typically consists of two stages.
2.1 The Prefill Stage
During Prefill, the model processes the entire user prompt at once. It computes hidden states for all input tokens and generates the Key and Value vectors for each layer.
This stage is compute-intensive and usually produces high GPU utilization. Its execution time is approximately proportional to the input length.
2.2 The Decode Stage
During Decode, the model generates output tokens one at a time. For every new token, the model must read the Key and Value vectors for all previous tokens before calculating the output for the new token.
The amount of computation per step is relatively small, but the system must repeatedly read data from GPU memory. As a result, Decode is often limited by memory bandwidth rather than raw compute capacity.
This distinction is important:
- Long inputs mainly increase Prefill time.
- Long outputs primarily consume Decode time and GPU memory.
- These two workloads place different types of pressure on the system and should be handled differently by the scheduler.
3. KV Cache: How GPU Memory Limits Concurrency
3.1 The Role of KV Cache
Without caching, the inference engine would need to recalculate the Key and Value vectors for the entire conversation history every time it generated a token.
To avoid this repeated computation, the system stores these vectors in GPU memory. This storage is called the KV Cache.
The cache reduces redundant computation, but every active request must reserve part of the cache until the request finishes. Longer contexts and longer outputs therefore consume more memory.
3.2 Estimating KV Cache Usage
The KV Cache size per token can be estimated with the following formula:
Bytes per token = 2 × number of layers × number of KV heads × head dimension × bytes per element
The factor of 2 represents the two cached tensors: Key and Value.
Consider the following hypothetical model configuration. These values are for illustration only and do not correspond to any specific model:
- Number of layers: 32
- Number of KV heads: 8
- Head dimension: 128
- Data type: FP16, 2 bytes per element
The calculation is:
Bytes per token = 2 × 32 × 8 × 128 × 2 = 131,072 bytes (128 KiB)Memory for one 4,096-token request = 128 KiB × 4,096 = 512 MiB
If 40 GiB of GPU memory is available for the KV Cache, the system could hold approximately:
40 × 1024 / 512 = 80 concurrent requests
This calculation assumes that every request contains 4,096 tokens.
The example shows that GPU memory can become the bottleneck even when compute capacity is sufficient. Conversely, when compute is insufficient, each request generates tokens more slowly and remains active in memory for longer. In effect, the same amount of memory can support fewer concurrent requests.
3.3 Memory Fragmentation and Paged Management
Preallocating a contiguous block of memory equal to the maximum context length for every request can waste a significant amount of capacity because most requests do not reach the maximum length.
A common approach is to divide the KV Cache into fixed-size blocks and allocate them on demand. When a request finishes, its blocks are released immediately.
This type of paged cache management can significantly reduce fragmentation and increase the number of requests the system can support.
4. The Trade-Off Between Throughput and Latency
Overall service throughput can be roughly expressed as:
System throughput (tokens/second) ≈ batch size ÷ per-step decode time
For example, if the batch size is 80 and one Decode step takes 40 milliseconds:
80 ÷ 0.04 = 2,000 tokens/second
There is an important trade-off. Increasing the batch size can improve total throughput, but each Decode step must process more requests. Its duration may therefore increase, reducing the generation speed experienced by each individual user.
The service must balance aggregate throughput against per-request latency. The optimal balance changes as system load changes.
5. Continuous Batching and Request Scheduling
Traditional static batching waits for every request in a batch to finish before starting the next batch. Short requests may therefore be forced to wait for long requests, while GPU resources can remain underutilized.
Continuous batching takes a different approach. After each Decode step, the scheduler checks whether any requests have completed. If requests have finished, new requests can be added immediately.
The following simplified example illustrates the core scheduling process:
def scheduler_step(running, waiting, kv_pool):# 1. Release GPU memory used by completed requestsfor req in list(running):if req.finished:kv_pool.release(req.kv_blocks)running.remove(req)# 2. Add waiting requests while sufficient memory is availablewhile waiting and kv_pool.can_allocate(waiting[0].prompt_len):req = waiting.pop(0)req.kv_blocks = kv_pool.allocate(req.prompt_len)running.append(req)# 3. Run one Decode step for active requestsfor req in running:req.append_token(model.decode_one(req))
The key part is the second step. When there is not enough GPU memory, new requests must remain in the waiting queue.
As a result, GPU memory availability is directly related to queue length. The longer the queue, the longer users must wait.
6. Common Responses to Compute or Memory Pressure
When compute or memory resources are insufficient, service operators commonly combine several strategies.
6.1 Admission Control and Queuing
Admission control determines whether to accept a new request based on available memory, current concurrency, and queue length.
If a request cannot be admitted, the service should return a clear status code and retry guidance rather than allowing it to wait indefinitely. Queue policies should also consider fairness so that a small number of high-frequency users do not occupy resources continuously.
6.2 Tiered Quotas
Services may define different limits for different user types or service tiers, including:
- Maximum concurrent requests
- Requests per minute
- Maximum output length per request
The goal is to allocate limited resources to higher-priority or higher-value workloads while keeping the rules transparent for all users.
When changing quotas, providers should notify users in advance and explain the scope of the impact.
6.3 Limiting Output and Context Length
Output length directly affects the growth rate of the KV Cache. Setting an unnecessarily high maximum output length can cause each request to occupy GPU memory for a long time.
A more practical approach is to define a reasonable default limit for each use case while allowing users to request longer outputs when necessary.
6.4 Prefix Caching and Prompt Reuse
If multiple requests share the same system prompt or document prefix, the service can cache the corresponding KV Cache and reuse it for later requests.
This reduces Prefill computation and is particularly effective when requests contain long, repeated prefixes.
6.5 Model and Kernel Optimization
Common optimization techniques include:
- Quantizing model weights and the KV Cache to reduce the number of bytes per element. For example, reducing KV Cache precision from FP16 to INT8 can cut its memory usage approximately in half.
- Using speculative decoding, in which a smaller draft model proposes candidate tokens and the main model verifies them in batches, reducing the number of Decode steps performed by the main model.
- Using more efficient attention kernels to reduce the amount of data transferred from GPU memory.
Quantization may introduce some quality degradation. Evaluation on representative test sets is necessary to determine whether the resulting quality remains acceptable.
6.6 Elastic Scaling
In a general-purpose cloud environment, a service can automatically scale inference replicas based on load metrics. Queue services, monitoring, and alerting can help detect growing backlogs in time.
Scaling takes time to start, so the system should maintain spare capacity and define degradation strategies for sudden traffic spikes.
7. Practical Guidance for Developers and Enterprise Users
7.1 Handle Rate Limits and Timeouts on the Client
When a service returns a rate-limit or temporary-unavailability response, the client should use exponential backoff with random jitter. This prevents many clients from retrying simultaneously and creating a retry storm.
import randomimport timedef call_with_backoff(send_request, max_retries=5, base_delay=1.0):for attempt in range(max_retries):resp = send_request()if resp.status_code not in (429, 503):return resp# Exponential backoff with random jitterdelay = base_delay * (2 ** attempt) + random.uniform(0, 0.5)time.sleep(delay)raise RuntimeError("The service is busy and all retries have been exhausted")
In this example, send_request is a request function implemented by the caller. 429 and 503 are common status codes for rate limiting and temporary service unavailability.
7.2 Control the Cost of Individual Requests
Enterprise users can reduce resource consumption in several ways:
- Set a reasonable maximum output length for each business scenario.
- Place stable, reusable system prompts at the beginning of requests to improve opportunities for prefix reuse.
- Retrieve or summarize long documents before sending them to the model, reducing the number of input tokens.
- Use asynchronous or batch interfaces for non-real-time workloads, if provided by the service, instead of consuming high-priority real-time concurrency.
7.3 Build a Capacity Planning Model
A basic capacity estimate can be developed through the following steps:
- Measure peak requests per minute and the average input and output token counts during busy periods.
Estimate the total number of output tokens required per second:
Peak requests × average output tokens ÷ 60
Combine this estimate with the measured throughput of a single inference replica to calculate the required number of replicas, including an appropriate reserve.
- Compare the result with the service’s quota limits and request additional capacity or adjust workload timing in advance.
All figures should ultimately be validated through real load testing. Theoretical estimates should not be used directly as service guarantees.
8. Conclusion
LLM inference concurrency is constrained by two factors: the compute throughput available from the GPU and the amount of KV Cache that GPU memory can hold.
Prefill and Decode have different resource characteristics, so long inputs and long outputs place different types of pressure on an inference system. Continuous batching, paged cache management, prefix reuse, and quantization can improve capacity on the same hardware.
When compute or memory resources are under pressure, service operators typically rely on admission control, tiered quotas, and output-length limits to preserve overall stability.
Developers and enterprise users can reduce the impact of service fluctuations by implementing appropriate retry behavior, controlling per-request costs, and estimating capacity based on measured traffic and throughput.
Once these mechanisms are understood, service instability is no longer an unexplained black box. It becomes an engineering problem that can be analyzed and planned using operational metrics and capacity models.
