LLM Service Peak Capacity Shortages: Capacity Planning and Graceful Degradation

    As LLM workloads scale, peak traffic and long-tail requests can exhaust inference capacity even when average utilization looks healthy. This article explains how to diagnose peak capacity risk, estimate the number of inference instances from peak QPS, latency, concurrency, and redundancy, and design tiered degradation. It also covers rate limiting, bounded queues, timeout and cancellation, observability metrics, user communication, cost trade-offs, and a practical implementation checklist.

    1. Root Cause: Why Compute Capacity Breaks Down at Peak

    Large language model inference compute is roughly proportional to the number of input and output tokens. Longer context and more generated content mean that a single request consumes more GPU memory and compute time. When inference instances receive many long requests at the same time, compute units and memory are occupied, and new requests can only wait in a queue. Once queue time exceeds the timeout threshold, users experience latency or failures.

    The following factors can amplify this problem:

    • Request bursts: New feature launches or operational campaigns can multiply traffic within a short period.
    • Task decomposition increases call volume: Multi-step reasoning, tool calls, and parallel subtasks can split one user action into multiple model calls, increasing total compute.
    • Long-tail requests: A small number of extremely long-context requests can occupy resources for a long time and reduce overall throughput.

    Capacity shortages are therefore usually peak and long-tail problems, not average-load problems. Planning resources based on average traffic often exposes a gap during peak hours.

    2. Capacity Planning: Work Backward from Peak

    The core capacity planning formula is:

    Required instances ≈ peak requests per second × average duration per request ÷ concurrency per instance × redundancy factor

    Consider a set of hypothetical numbers (replace them with actual load-test data): peak traffic is 50 requests per second, average request duration is 4 seconds, concurrency per instance is 8, and the redundancy factor is 1.3. The result is about 32.5, which rounds up to 33 instances.

    1. import math
    2. def estimate_instances(peak_qps, avg_latency_s, concurrency_per_instance, headroom=1.3):
    3. """Estimate the number of inference instances required based on peak traffic."""
    4. required_concurrency = peak_qps * avg_latency_s
    5. instances = required_concurrency / concurrency_per_instance * headroom
    6. return math.ceil(instances)
    7. print(estimate_instances(peak_qps=50, avg_latency_s=4, concurrency_per_instance=8)) # Output: 33

    Two additional points matter during planning. First, billing and capacity should be measured by token throughput; measuring by request count underestimates the burden of long requests. Second, resources should be layered: the core question-answering path keeps a fixed resource pool, while optional high-compute features use an elastic resource pool, so the two do not crowd each other out.

    3. Tiered Degradation: Degrade Service Smoothly

    When service resources are insufficient, the system should first reduce quality and only then reject service. Common tiered strategies include:

    1. Model tiers: Offer large, medium, and small model tiers for the same business function. Automatically switch to a smaller tier during peak hours and clearly label the switch in the interface.
    2. Feature tiers: Pause optional high-compute features, such as deep analysis of long documents and batch parallel tasks, while retaining core question answering.
    3. Parameter tiers: Limit maximum output length and context window to reduce the resource consumption of each request.
    4. Result caching: Cache results for repeated questions or fixed templates to avoid repeated computation.

    The following example selects a model tier based on the current load ratio:

    1. TIERS = ["large", "medium", "small"]
    2. def choose_tier(current_load_ratio: float) -> str:
    3. """Choose a lighter model tier as the load ratio increases."""
    4. if current_load_ratio < 0.7:
    5. return "large"
    6. if current_load_ratio < 0.9:
    7. return "medium"
    8. return "small"

    Thresholds should be set based on load-test results, with a hysteresis band to prevent frequent tier switching near a threshold.

    4. Queueing, Rate Limiting, and Timeout Control

    Beyond degradation, the system also needs to control the volume of requests entering it. The following measures can be combined:

    • Rate limiting: Use token bucket or leaky bucket algorithms and allocate quotas by user tier to prevent a single tenant from consuming all resources.
    • Bounded queue: Set an upper limit on queue length. When the queue is full, return a retryable message immediately instead of waiting indefinitely.
    • Timeout and cancellation: When a client disconnects, the server should terminate generation promptly and release compute resources.
    • Priority scheduling: Process core business requests first, and run batch tasks during off-peak hours.
    1. import asyncio
    2. request_queue: asyncio.Queue = asyncio.Queue(maxsize=200)
    3. async def submit(request):
    4. try:
    5. request_queue.put_nowait(request)
    6. except asyncio.QueueFull:
    7. # Queue is full; tell the client to retry later instead of waiting indefinitely
    8. return {"status": 503, "message": "The service is busy. Please try again later.", "retry_after": 5}
    9. return {"status": 202}

    The bounded queue length should be determined together with the acceptable waiting time. For example, if users can tolerate a maximum wait of 10 seconds and the average request takes 4 seconds, the queue depth should be constrained by that limit.

    5. Observability: Detect Risk Early with Metrics

    Resource alerts often arrive too late. Continuously track the following metrics:

    • P95 and P99 queue time
    • GPU utilization and memory usage
    • Token throughput per second
    • Timeout rate and rejection rate
    • Distribution of tokens per request, to identify long-tail requests
    • Trigger count and duration of degradation strategies

    Alerts should be based on trends, not only single-point thresholds. For example, if queue time rises for several consecutive minutes, autoscaling or rate limiting should be triggered before users perceive an anomaly.

    6. User Communication and Cost Trade-offs

    Beyond technical solutions, communication during service incidents also affects user experience.

    • Transparent notification: The page should show the current service status, impact scope, and estimated recovery time, so users do not have to guess the cause.
    • Perceivable, not silent, degradation: When switching model tiers or disabling a feature, clearly notify users and preserve their ability to choose manually.
    • Cost and availability trade-offs: Redundant resources require continuous investment. Layer by business value: guarantee high availability for core features, and allow long-tail features to queue or degrade during peak hours.
    • Post-incident review: Every incident should record root cause, impact duration, and improvement items, and the improvement items should be incorporated into subsequent planning.

    7. Implementation Checklist

    1. Obtain the real concurrency capacity and latency curve of a single instance through load testing.
    2. Establish a peak forecasting mechanism and include scaling time in capacity calculations.
    3. Implement at least two levels of degradation strategies and conduct regular drills.
    4. Configure rate limiting, bounded queues, and request timeouts.
    5. Build a metrics dashboard and tiered alerts.
    6. Prepare user-facing status notification templates.

    On cloud platforms such as Baidu AI Cloud, these approaches can be implemented using common capabilities such as autoscaling, monitoring and alerting, and object storage. The key is to first clarify the business’s peak characteristics and acceptable degradation scope, then choose the appropriate technical combination.