LLM Service Overload: Capacity Governance and Stability Best Practices

    This article examines why large language model (LLM) inference services are prone to overload, breaking down root causes such as compute and VRAM bottlenecks, bursty and long-tail traffic, cache pressure, anomalous automated requests, and upstream capacity fluctuation. It presents practical capacity estimation methods based on Little's Law and token throughput, along with stability engineering techniques including layered rate limiting, priority queuing, retry backoff, circuit breakers, bulkhead isolation, and graceful degradation, plus guidance on anomalous traffic governance, monitoring metrics, and load testing.

    1. Background: Why Overload Occurs So Often

    When an LLM-based online service experiences problems, users typically see slower responses, longer queue times, interrupted generation, or pages that fail to load entirely. Behind these symptoms is rarely a single failure; more often, it is an imbalance among request volume, per-request resource consumption, and available resource supply.

    Compared with traditional web APIs, a single LLM inference request is far more expensive. Each request occupies VRAM for model weights and intermediate states, consumes compute cycles to generate output token by token, and holds resources for a relatively long processing time. As a result, even when the total request rate seems modest, a concentrated arrival of long-context or highly concurrent requests can quickly push the service to its resource limits.

    The “service crash” commonly described in discussions actually covers several distinct problems: the client application freezing due to page rendering or excessive memory usage, network congestion causing connection timeouts, server-side queue backlogs driving up time-to-first-byte, and overall degradation caused by insufficient upstream resource supply. Troubleshooting must first distinguish among these layers before a governance direction can be determined.

    2. Root Cause Analysis

    2.1 Compute and VRAM Bottlenecks

    Inference can be roughly divided into two phases. The prefill phase processes the entire user context, with compute cost proportional to input length. The decode phase generates output tokens one by one, and each step reads the model weights and historical cache, making it clearly constrained by memory bandwidth. The two phases have different resource demand profiles, so simply adding more GPUs does not necessarily increase throughput linearly.

    2.2 Traffic Patterns: Bursts Coexisting with Long Tails

    Traffic to online services is rarely uniform. Morning and evening peaks, trending events, and concentrated trials after a new release can all amplify request volume within a short window. At the same time, a small number of long conversations or long-document analysis requests consume large portions of the context window, so resource consumption varies widely across requests within the same batch. Averages tend to hide tail risk; capacity should be designed around peaks and the P99 distribution.

    2.3 Context and Cache as a Double-Edged Sword

    In multi-turn conversations, historical content is submitted repeatedly. If the server enables prefix caching or KV cache reuse, redundant computation can be significantly reduced. However, the cache itself occupies VRAM. When cache hit rates drop or the number of long sessions grows, VRAM pressure rises rapidly and may trigger eviction and recomputation, which in turn increases the load. Cache capacity therefore needs to be planned together with session lifecycles and concurrency levels.

    2.4 Unexpected Traffic and Automated Requests

    Some abnormal traffic comes from automated scripts, repeated retries, crawling behavior, or malicious volume inflation. Such requests are characterized by regular intervals, uniform session structures, highly repetitive content, and a tendency to continue despite failures. Without targeted identification and restriction, they crowd out resources meant for legitimate users. Note that behavioral feature-based judgment carries a risk of false positives, so governance policies should remain explainable and reversible.

    2.5 Upstream Resource Fluctuation

    The actual available capacity of a service is also affected by upstream compute supply. When available instances shrink, cross-region scheduling is constrained, or a certain class of hardware becomes scarce, previously sufficient capacity can contract within a short time. Services that depend on a single supply source are especially sensitive to this kind of fluctuation.

    3. Capacity Estimation Methods

    The starting point of capacity planning is converting business metrics into resource metrics. The methods below can serve as an initial estimation framework; concrete numbers must be obtained through load testing on the target hardware and model, and figures from others should not be applied directly.

    3.1 Estimating Concurrency with Little’s Law

    Little’s Law states that the average concurrency in a system equals the arrival rate multiplied by the average time in the system. For LLM services, this can be written as:

    Concurrent requests ≈ QPS × average processing time

    For example, with a peak QPS of 20 and an average processing time of 6 seconds, average concurrency is about 120. This number determines the lower bound for gateway connection counts, inference engine batch sizes, and queue lengths.

    3.2 Estimating Throughput Demand by Tokens

    Input and output tokens consume different resources and should be counted separately. The example function below converts peak QPS into per-second input and output token demand with headroom reserved:

    1. def estimate_token_demand(
    2. peak_qps: float,
    3. avg_input_tokens: int,
    4. avg_output_tokens: int,
    5. headroom: float = 1.3,
    6. ) -> dict:
    7. """Estimate per-second token demand from peak QPS; headroom is the safety margin factor."""
    8. if peak_qps <= 0:
    9. raise ValueError("peak_qps must be positive")
    10. input_tps = peak_qps * avg_input_tokens * headroom
    11. output_tps = peak_qps * avg_output_tokens * headroom
    12. return {
    13. "input_tokens_per_second": round(input_tps, 1),
    14. "output_tokens_per_second": round(output_tps, 1),
    15. }
    16. print(estimate_token_demand(peak_qps=20, avg_input_tokens=1500, avg_output_tokens=400))

    The resulting demand values should be compared against the per-instance throughput measured in load tests to derive the required number of instances. The headroom factor is typically chosen based on business volatility and scaling latency: the greater the volatility and the slower the scaling, the higher the headroom should be.

    3.3 Design by Percentiles, Not Averages

    Averages easily hide long tails. It is recommended to record the P50, P95, and P99 values of input length, output length, and end-to-end latency, and to run stress tests using the request mix corresponding to P95 or P99. If long requests make up a significant share, a dedicated resource pool should be allocated for them so they do not slow down short requests.

    4. Stability Engineering Design

    4.1 Layered Rate Limiting

    Rate limiting is the first line of defense against overload propagation. Limiting by raw request count has an obvious flaw: a long request and a short request can differ in resource consumption by tens of times. A more reasonable approach is weighted accounting based on estimated token counts, aligning rate limits with actual resource consumption.

    The token bucket algorithm suits scenarios that allow a degree of burstiness. The implementation below deducts tokens according to request cost:

    1. import threading
    2. import time
    3. class TokenBucket:
    4. def __init__(self, rate: float, capacity: float):
    5. self.rate = rate # tokens refilled per second
    6. self.capacity = capacity # bucket capacity, determining the maximum allowed burst
    7. self.tokens = capacity
    8. self.updated_at = time.monotonic()
    9. self._lock = threading.Lock()
    10. def try_acquire(self, cost: float = 1.0) -> bool:
    11. with self._lock:
    12. now = time.monotonic()
    13. elapsed = now - self.updated_at
    14. self.tokens = min(self.capacity, self.tokens + elapsed * self.rate)
    15. self.updated_at = now
    16. if self.tokens >= cost:
    17. self.tokens -= cost
    18. return True
    19. return False

    In production, separate buckets should be configured at four levels—user, API key, organization, and global—with requests rejected when any level is exceeded. The global bucket protects overall capacity, while user-level buckets prevent a single source from consuming all resources.

    4.2 Queuing and Priority Scheduling

    Requests exceeding capacity should not fail immediately; they should enter a bounded queue. The queue needs a maximum length and a maximum wait time; beyond those, a clear overload response should be returned to avoid infinite queuing that causes all requests to time out simultaneously.

    Scheduling can consider the following strategies:

    • Run interactive requests and batch offline tasks in separate pools to prevent offline tasks from crowding out online responses;
    • Raise the priority of requests that have waited too long to avoid starvation;
    • Set a separate concurrency cap for long-context requests to keep time-to-first-token of short requests under control.

    4.3 Timely Cancellation and Resource Reclamation

    After a client disconnects, if the server continues generating, resources are wasted. The inference service should monitor connection state and terminate generation and release VRAM as soon as a disconnection occurs. This change is inexpensive, yet in scenarios with frequent user retries it can noticeably reduce wasted computation.

    4.4 Output Length Control

    Output length directly determines decode duration. The server should set a default max_tokens limit and allow callers to adjust it within a reasonable range. For scenarios that clearly do not need long outputs, the gateway layer can apply more conservative defaults.

    4.5 Retry Strategy and Backoff

    Unrestrained client retries amplify failures. Exponential backoff with random jitter is recommended, along with a cap on the maximum number of retries:

    1. import random
    2. import time
    3. class TransientError(Exception):
    4. """Represents a retryable transient error, such as 429 or 503."""
    5. def retry_with_backoff(request_fn, max_retries: int = 5,
    6. base_delay: float = 0.5, max_delay: float = 20.0):
    7. for attempt in range(max_retries + 1):
    8. try:
    9. return request_fn()
    10. except TransientError:
    11. if attempt == max_retries:
    12. raise
    13. # Full jitter strategy: wait randomly within [0, exponential backoff cap]
    14. # to spread out requests retrying at the same time
    15. upper = min(max_delay, base_delay * (2 ** attempt))
    16. time.sleep(random.uniform(0, upper))

    The server should return a suggested wait time in 429 or 503 responses so clients can cooperate.

    4.6 Circuit Breaking and Bulkhead Isolation

    When the error rate of an inference instance pool rises persistently, the gateway should temporarily remove it from rotation so requests stop hitting faulty nodes. A circuit breaker typically has three states—closed, open, and half-open. In the half-open state, only a small number of probe requests are allowed through, and traffic is ramped back up only after recovery is confirmed.

    Bulkhead isolation separates the resource pools of different businesses or different models, so a failure in one pool does not propagate to others.

    4.7 Tiered Degradation

    When capacity is genuinely insufficient, the system should follow a preset degradation path rather than becoming entirely unavailable. Common degradation measures include:

    • Reducing the maximum context length per request, with a clear notice to users;
    • Switching some non-core scenarios to a smaller model;
    • Suspending non-critical features such as batch export or long-document analysis;
    • Returning a queue status page or static fallback content.

    Each degradation tier should have defined trigger conditions, blast radius, and recovery conditions, and should be validated in drills.

    5. Identifying and Governing Anomalous Traffic

    5.1 Observable Characteristics

    Anomalous traffic typically deviates from normal distributions along the following dimensions: overly regular request intervals, abnormal distributions of conversation turns, the same content submitted repeatedly, highly concentrated source IPs or device fingerprints, and an excessive share of immediate retries after failures. Incorporating these characteristics into risk-control metrics allows problems to be detected early.

    5.2 Differentiated Governance

    Governance policies should avoid one-size-fits-all approaches. Suspicious traffic should first be subjected to lower rate limits or additional verification steps rather than outright blocking—this protects legitimate users and reduces collateral damage. Only confirmed malicious traffic should be blocked or have its credentials revoked. Every enforcement action should record its basis to support appeals and postmortems.

    5.3 Compliance and Boundaries

    Traffic governance should be based solely on technical behavioral characteristics and should not make inferences about user content beyond security and compliance requirements. Content safety policies and capacity governance should be designed separately, each with clear rules and audit records.

    6. Monitoring Metrics and Alerting

    The table below lists the core metrics commonly used in stability monitoring; thresholds should be determined based on business baselines.

    Metric Meaning Alerting Approach
    Time to First Token (TTFT) Time from request to the first output token Alert when persistently above baseline, reflecting prefill or queuing pressure
    Time Per Output Token (TPOT) Average per-token latency in the decode phase Investigate memory bandwidth and batch composition changes when it rises significantly
    Queue wait time Time a request spends in the queue Trigger scaling or rate limiting when approaching timeout thresholds
    VRAM and KV cache utilization Usage of VRAM and cache pools Sustained high levels indicate cache eviction risk
    Ratio of 429 and 503 responses Share of requests rejected by rate limiting or overload Check rate limit thresholds and upstream capacity on sudden spikes
    Concurrent request count Number of requests being processed simultaneously Compare against the capacity model using Little’s Law
    Client disconnect rate Share of requests disconnected before completion Investigate timeout configuration or frontend issues on abnormal increases
    Per-user request distribution Share of requests from top users Start anomalous traffic investigation when extreme concentration appears

    Monitoring should be layered: the infrastructure layer focuses on GPU utilization and networking, the inference service layer on the latency and cache metrics above, and the business layer on success rates and user-perceived response times. Alerts should distinguish between “warning” and “incident” levels—warnings drive early scaling, while incidents drive immediate response.

    7. Release, Load Testing, and Elasticity

    7.1 Load Test Design

    Load tests should use request samples close to real distributions, including combinations of inputs and outputs of varying lengths and multi-turn sessions. Using only fixed-length synthetic requests often fails to expose long-tail problems. Load should be increased step by step, recording the throughput knee and latency knee to determine safe operating levels.

    7.2 Canary Releases and Rollback

    Changes to model versions, inference engine configurations, and rate limiting parameters should all be rolled out gradually via canary releases. During the canary period, TTFT, error rates, and resource usage of the new and old versions should be compared, and when metrics show anomalies, a fast…