Capacity Governance and Quota Design for LLM Services Under Compute Pressure
This article explains why LLM inference services hit compute and memory limits under heavy demand. It shows how to estimate per-request memory and multi-step task costs, and how to manage capacity through KV cache tiering, admission control, graceful degradation, and quota design. It also covers subscription changes and the monitoring metrics that signal when to scale or throttle.
1. Background: Why Inference Services Run Short of Compute
In conversational LLM services, the number of users one deployment can serve is usually limited by GPU resources. When a model generates text, it reads large amounts of weights and cached history at every step. The decode stage is limited by memory bandwidth, so GPU compute units often cannot run at full capacity. Service providers therefore try to keep the GPU busy. The more tokens produced per second, and the sooner each request finishes, the sooner resources free up for the next queued request.
This leads to a direct conclusion: the peak concurrency limit is determined by both available compute and memory. When demand exceeds this limit, the service can only choose among queuing, rate limiting, degradation, and rejection.
Conversation workloads also differ from other workloads. Ordinary Q&A is usually one-off, with short turns and little history. Long sessions, document processing, and agent tasks extend the context significantly and increase the number of model calls per task. As a result, the same number of users can create resource pressure that differs several times over across workloads. Capacity planning should not rely on user count alone. It should weight estimates by workload type.
2. Estimating Per-Request Cost from Memory
During inference, the model must store the attention Key and Value for each active request. This is the KV cache. Its size grows linearly with sequence length. The approximate formula is shown below.
def kv_cache_bytes(layers: int, kv_heads: int, head_dim: int,seq_len: int, dtype_bytes: int = 2) -> int:# K and V are each stored once, so the coefficient is 2return 2 * layers * kv_heads * head_dim * seq_len * dtype_bytes# Illustrative parameters only. They show how the calculation works and do not represent any specific model.per_req = kv_cache_bytes(layers=48, kv_heads=8, head_dim=128, seq_len=32_000)print(f"Approximate KV cache per request: {per_req / 1024**3:.2f} GiB")
This calculation shows two things. First, longer context means each request uses more memory, so long-text requests occupy many concurrency slots. Second, the memory budget is a hard constraint. Using it as the upper bound on concurrency is far more reliable than relying on rough guesses.
Estimates should keep a safety margin for activations, batch scheduling overhead, and memory fragmentation. Actual capacity should generally be determined through load testing, not only from theoretical values.
3. Three Strategies for Handling the KV Cache
A session’s KV cache does not have to stay in GPU memory permanently. When capacity is tight, there are three common approaches, each with different costs.
| Strategy | Approach | Advantages | Cost |
|---|---|---|---|
| Keep | The cache stays resident in GPU memory | Lowest latency when the session resumes | Occupies a concurrency slot |
| Swap out | The cache is written to lower-speed storage and loaded when needed | Frees GPU memory and can be restored | Loading time and storage bandwidth requirements |
| Drop and recompute | The cache is released and rebuilt from history when needed | Simplest to implement and uses no storage | Recomputation cost grows with context length |
In practice, these strategies are often combined. Short or frequently accessed sessions stay in GPU memory. Sessions that are idle beyond a threshold move to a cheaper storage tier. Sessions that have not been accessed for a long time and have very long context are dropped, and their cache is recomputed when the user returns. The right choice depends on how likely the session is to be accessed again and on the cost of recomputation. For one-off Q&A, dropping the cache causes almost no loss. For long-running collaborative sessions, swapping out is often more economical.
4. How Agents and Multi-Step Tasks Amplify Resource Use
In agent scenarios, a single user request can trigger several model calls: planning, tool calls, result summarization, and error correction with retries. Each step must carry a longer context than the one before, so the costs accumulate.
The following function gives a rough estimate of the resource consumption of one task.
def task_cost(steps: int, base_ctx: int, growth_per_step: int,cost_per_token: float = 1.0) -> float:total = 0.0ctx = base_ctxfor _ in range(steps):total += ctx * cost_per_token # each step processes the full current contextctx += growth_per_step # tool results are appended to the contextreturn totalsimple_chat = task_cost(steps=1, base_ctx=500, growth_per_step=0)agent_task = task_cost(steps=8, base_ctx=500, growth_per_step=800)print(f"Multi-step task cost is about {agent_task / simple_chat:.1f}x that of a single-turn Q&A")
The parameters here are illustrative. The multiplier depends on the actual number of steps and how fast the context grows. The conclusion still holds: more steps and faster context growth increase the cost of a single task by more. Quotas and rate limits should therefore be measured in compute or token volume, not only in request count.
5. Engineering Responses When Capacity Is Tight
5.1 Admission Control and Queuing
The service entry point needs an explicit concurrency limit. Requests beyond that limit enter a bounded queue with a queue timeout. When a request times out in the queue, the service returns a clear busy message. This prevents requests from piling up indefinitely.
import asyncioclass AdmissionController:def __init__(self, max_concurrent: int, queue_timeout: float):self._sem = asyncio.Semaphore(max_concurrent)self._timeout = queue_timeoutasync def run(self, handler, request):try:await asyncio.wait_for(self._sem.acquire(), timeout=self._timeout)except asyncio.TimeoutError:raise RuntimeError("Service is busy, please try again later")try:return await handler(request)finally:self._sem.release()
5.2 Tiered Rate Limiting and Priority
Not all requests are equally important. Priority can be assigned by scenario. For example, interactive online requests can take precedence over batch offline jobs. Rate limits should be set separately for each user and each tenant, so that a single user cannot consume all resources. For multi-step tasks, it is recommended to reserve quota in advance based on the estimated total tokens, then settle based on actual usage. If the task fails partway through, the settlement reflects what was actually consumed.
5.3 Degrade Instead of Rejecting Everything
When resources are tight, the service can first reduce the maximum output length per request, shrink the context window, or switch to a lighter inference configuration. Degradation should be visible to users and explained in the response. Otherwise, a drop in output quality could be silently misunderstood.
6. Subscription and Quota Design
When capacity is tight, new subscriptions and plan changes are the most likely to cause disputes. Engineering should address the following points.
- State consistency: The subscription state machine should cover new purchases, renewals, turning off auto-renewal, plan upgrades, and pausing new sign-ups. Every change should have an audit record, so the interface and the billing system stay consistent.
- Existing user rights: When new sign-ups are paused, existing entitlements should remain available. If changes are unavoidable, announce them in advance and provide a transition period.
- Limited issuance: When supply is below demand, issuing a limited quantity by queue or time window is fairer than open first-come purchasing. It also reduces sudden system load.
- Transparent communication: Announcements should explain the cause, the scope of impact, and the recovery plan, and point to a status page or update channel. If the recovery time is not yet known, state “TBD” clearly. Do not make promises without a basis.
7. Monitoring and Alerts
Capacity governance depends on observability. At minimum, monitor the following metrics:
- Queue wait time distribution (P50, P95, P99)
- Time to first token and overall output throughput
- GPU memory utilization and fragmentation
- KV cache hit rate, and the number of swap-outs and recomputations
- Timeout and rejection rates
- Resource consumption broken down by user, tenant, and workload type
Alert thresholds should be set based on load-test results. A sustained rise in queue wait time is usually an early signal that scaling or rate limiting is needed. It appears earlier than an increase in the error rate.
8. Implementation Checklist
- Use load testing to determine the concurrency limit per GPU and the memory headroom. Measure each workload type separately.
- Define a tiered policy for the KV cache covering keep, swap out, and drop. Record the hit rate and cost of each tier.
- Implement a bounded queue, queue timeouts, and clear busy messages at the entry point.
- Design quotas based on token volume rather than request count. Support pre-deduction and settlement.
- Manage subscription changes through a state machine, so the interface and billing stay consistent.
- Announce the cause, scope, and recovery plan for any incident. Do not make time commitments without a basis.
- Set up monitoring and alerts for queue wait time and resource consumption. Review the capacity model regularly.
Tight capacity is a normal condition for inference services, not only an occasional incident. Building capacity estimation, cache tiering, admission control, and quota design as one system keeps the service stable under resource constraints. It also helps users clearly understand the rules and what to expect.
