LLM Inference Scaling and Rate Limiting: A Practical Guide to Capacity Planning and Overload Control

    This article explains why large language model inference is harder to scale than traditional web services, how to turn capacity assumptions into testable numbers, and how to use rate limiting, admission control, and elastic scaling to keep a launch stable. It covers the two-stage nature of inference (prefill and decode), KV Cache sizing, load modeling by percentiles, overload protection patterns, throughput optimizations without adding GPUs, and a pre-launch review checklist.

    1. What Really Happened: A “Good Problem” Overload

    An AI assistant platform launched a new-generation model and got far more user growth than expected. The surge in requests pushed the existing inference cluster to its limit, so the platform paused paid sign-ups for new users while keeping existing users running, promising a gradual reopening. The announcement went out shortly after 2 a.m. — not a copywriting issue, but the inevitable result of capacity planning being punched through by real traffic.

    One detail stands out: a few days before the launch, the platform was still running an invite-and-reward campaign. That means the capacity plan assumed the new model would only consume part of the idle compute. Instead, the traffic curve jumped sharply, and the campaign window was completely misaligned with the scaling window. For developers, this is a clear signal: capacity assumptions must be version-controlled like code and continuously recalibrated against traffic data.

    2. Why LLM Inference Is Harder to Scale Than Traditional Services

    Scaling a traditional web service is roughly linear: add machines, add replicas, throughput goes up. LLM inference is different, because resource consumption comes in two stages.

    • Prefill stage: processes the entire input at once. It is compute-intensive, mainly consuming FLOPs, highly parallel, and easy to saturate GPU compute utilization.
    • Decode stage: generates one token per step, repeatedly reading all model weights and the growing KV Cache. It is memory-bandwidth intensive, with the bottleneck in VRAM capacity and memory bandwidth.

    This explains a frequently misread conclusion: when GPU utilization looks near saturation, the system is not necessarily producing efficiently. It may simply be spinning on the decode memory-bandwidth bottleneck. In that case, adding compute (stronger compute units) yields almost nothing. What you actually need is higher-bandwidth memory, more efficient KV Cache management, or a more aggressive batching strategy.

    An illustrative resource estimate (order-of-magnitude only, not the parameters of any specific product):

    1. # Rough estimate of per-request KV Cache usage for order-of-magnitude capacity planning
    2. def kv_cache_bytes(layers, kv_heads, head_dim, seq_len, batch, dtype_bytes=2):
    3. # Per layer, per token K/V cache: 2 (K and V) * kv_heads * head_dim
    4. per_token = 2 * kv_heads * head_dim * dtype_bytes
    5. return layers * per_token * seq_len * batch
    6. # Example: demonstrates the calculation only
    7. print(kv_cache_bytes(layers=60, kv_heads=8, head_dim=128, seq_len=8192, batch=32))

    3. Capacity Estimation: Turning “Feels Enough” Into Verifiable Numbers

    The minimum closed loop for capacity planning has four steps:

    1. Define service targets: time to first token (TTFT), time per output token (TPOT), end-to-end latency ceiling, acceptable queueing time.
    2. Build a load model: input/output length distribution (long documents and short Q&A have completely different resource profiles), peak concurrency, daily cycles, and burst multipliers.
    3. Derive resource requirements: under a given batching strategy, estimate how many concurrent sequences a single GPU can hold, then compute required VRAM and GPU count; validate the decode stage against bandwidth rather than compute.
    4. Calibrate with load tests: use shadow traffic or replayed real request distributions, converge the error into an acceptable range, and keep a safety margin (for example, 30% headroom at peak).

    A common mistake is sizing only on “average input length.” In real workloads, long-tail requests (very long context, long-form generation) significantly raise KV Cache usage, and a small number of long requests can drag down the throughput of an entire batch. Design by percentiles (P95/P99) and route oversized requests to a separate path.

    4. Rate Limiting and Admission Control: The Cheapest Stability Under Overload

    When scaling cannot keep up (procurement, delivery, and deployment all take time), rate limiting is the only lever that takes effect immediately. The core idea is to trade an “uncontrollable avalanche” for “controlled rejection.”

    • Admission control: degrade new customers, free tiers, and non-core workloads first, protecting existing paying users. This is the technical mapping of “pause new sign-ups, existing plans still work.”
    • Priority queues: queue by business tier and SLA so high-value requests are not drowned by bursts.
    • Token bucket plus concurrency semaphore: two layers of control — the former limits rate, the latter limits in-flight requests, preventing the batching queue from growing without bound.
    1. # Pseudocode: admission + priority + concurrency cap
    2. def handle(req):
    3. if not token_bucket.allow(req.tenant): # rate layer
    4. return reject(429, "rate limited")
    5. if inflight.current() >= MAX_INFLIGHT: # concurrency layer
    6. return enqueue(req, priority=req.tier) # enter the priority queue
    7. with semaphore.slot(): # actually occupy an inference slot
    8. return inference(req)

    Related recommendations: make queueing time, rejection rate, batch size, and KV Cache hit rate into monitoring and alerting metrics, with tiered thresholds (warning / degradation / circuit breaking), and expose clear retry semantics to clients (backoff plus jitter) to avoid a client retry storm hitting the system a second time.

    5. Efficiency Levers: Squeezing Out Throughput Without Adding GPUs

    • Continuous batching: requests leave the batch as soon as they finish and new requests join immediately, substantially improving GPU time-slice utilization.
    • KV Cache reuse: apply prefix caching to identical prefixes (system prompts, long documents, multi-turn history) to avoid repeated prefill.
    • Quantization and sparsification: reduce the bit width of weights and cache within an acceptable accuracy range, directly relieving VRAM and bandwidth pressure.
    • Speculative decoding: a small model drafts and the large model verifies, increasing output per step in bandwidth-constrained scenarios.
    • Separating long and short requests: route long-context tasks to a dedicated resource pool so they do not pollute the latency of short requests.

    6. Elasticity and Cost: Keeping Scaling Ahead of Traffic

    Reactive scaling is always half a beat behind, so combine predictive and reactive approaches: use historical periodicity and the marketing calendar to drive scheduled pre-scaling, and use metrics-driven autoscaling as a fallback for bursts. At the resource layer, you can combine elastic nodes from a container platform, object storage for models and datasets, message queues for request buffering and peak shaving, and logging plus monitoring for a closed observability loop. If you use the relevant general capabilities of Baidu AI Cloud, follow the same order: load test first, set the watermark second, configure the scaling policy last, so elasticity is never built on unvalidated capacity assumptions.

    On the cost side, distinguish “fixed reservation” from “on-demand top-up”: cover baseline traffic with reservations to lower unit price, and absorb peaks with elastic resources. Also set quotas and degradation paths for very long context and low-value batch jobs, so a few requests cannot consume most of the budget.

    7. Post-Launch Review Checklist: Questions to Answer Before the Next Release

    1. What traffic multiplier range will the new model bring, and what is the basis for that estimate?
    2. Has decode-stage VRAM bandwidth been validated separately, rather than looking only at GPU utilization?
    3. Have the three tiers of rate limiting, degradation, and circuit breaking been drilled, and are the rejection semantics friendly to clients?
    4. Are marketing campaigns (invite rewards, limited-time offers) time-aligned with the scaling window?
    5. Is there a dedicated resource pool that routes by P95/P99 input length?
    6. Can monitoring pinpoint within 5 minutes whether the bottleneck is compute, VRAM, or bandwidth?

    Conclusion

    A “paused new sign-ups” announcement looks like a compute shortage on the surface, but it is really a simultaneous failure of capacity assumptions, traffic forecasting, and rate limiting. Understand the two-stage nature of inference load, turn capacity estimation into an engineering process validated by load tests, and make rate limiting and elastic scaling part of the pre-launch checklist. Then “sweet overtime” becomes predictable, steady scaling.