High-Throughput LLM Inference: Engineering Practices and Performance Optimization

    This article breaks down high-throughput LLM inference as a general engineering problem, focusing on how to sustain a high per-user token output rate during peak traffic. It clarifies the relationship between system throughput, per-request output rate, and latency (TTFT and TPOT), then walks through the four key areas that determine output speed: continuous batching and scheduling, KV cache and GPU memory management, decoding-stage operator efficiency, and service architecture with elastic scaling. It also outlines a capacity planning method for peak hours, the observability metrics needed for closed-loop tuning, and common pitfalls to avoid. Readers will gain a reusable framework for building an LLM inference service that delivers smooth experience with controlled cost.

    High-Throughput LLM Inference: Engineering Practices and Performance Optimization

    A metric that comes up frequently in recent industry discussions is “the output rate available per user during peak hours.” This metric draws attention because it constrains both server-side throughput and client-side experience at the same time: if the rate is too low, long-form generation becomes unbearable to wait for; if the rate is high but fluctuates wildly, it signals hidden risks in capacity planning. This article does not benchmark any specific product. Instead, it abstracts the topic into a general engineering problem—how to reliably deliver a high token output rate during traffic peaks—and provides a reusable analysis framework and practical path.

    1. Getting the Metrics Straight: Throughput, Rate, and Latency

    Three concepts are commonly confused in engineering:

    • System throughput: the total number of tokens produced by the entire cluster per unit of time, usually measured in tokens/s.
    • Per-request output rate: the number of tokens a single session receives per second, which directly determines whether the “typewriter effect” feels smooth.
    • Latency: includes time to first token (TTFT) and time per output token (TPOT).

    These three are not independent. Raising system throughput often relies on larger concurrent batches, and increasing batch size raises per-request TPOT, which in turn lowers the per-request output rate. Therefore, a target like “still maintaining on the order of 70–80 tokens/s during peak hours” is essentially a requirement that, as load rises, the scheduling strategy and GPU memory management keep TPOT within an acceptable range—rather than simply piling on more compute.

    A handy approximate relationship to remember:

    1. Per-request output rate ≈ 1 / TPOT
    2. Cluster throughput ≈ concurrent requests × per-request output rate

    This shows there are two paths to improving experience: reduce TPOT (optimize single-step decoding time), or increase effective concurrency at the same TPOT (optimize GPU memory and scheduling).

    2. Four Key Factors That Determine Output Rate

    2.1 Continuous Batching and Scheduling

    Traditional static batching requires all requests in a batch to advance in lockstep, so short requests get held back by long ones. Continuous batching dynamically swaps requests in and out at iteration granularity, allowing completed requests to yield immediately and significantly boosting effective concurrency. In practice, this also needs to be paired with priority and fair queuing to prevent long-context requests from occupying resources for extended periods and starving small requests.

    2.2 KV Cache and GPU Memory Management

    The GPU memory consumed by autoregressive decoding is mainly spent on the KV cache, whose size grows linearly with context length and concurrency. Common optimizations include paged memory management to reduce fragmentation, prefix reuse so that identical system prompts share a cache, and tiered eviction of the cache under high concurrency. Once GPU memory runs short, the scheduler can only reject or queue requests, and most rate jitter during peak hours originates here.

    2.3 Operator Efficiency in the Decoding Stage

    The prefill stage is compute-intensive, while the decoding stage is memory-access-intensive. Improving decoding efficiency typically relies on operator fusion, more efficient attention implementations, and low-precision numeric formats to reduce memory access volume. Together these measures lower TPOT and are the main source of per-request rate improvement.

    2.4 Service Architecture and Elasticity

    Inference services are usually split into an access layer, a scheduling layer, and an execution layer. The access layer handles authentication and rate limiting, the scheduling layer handles batching and routing, and the execution layer runs the model. Combined with elastic scaling and readiness probes, capacity can be added before traffic ramps up, avoiding first-token latency spikes caused by cold starts.

    3. Capacity Planning for Peak Hours

    The goal of capacity planning is not to meet the average, but to avoid collapse at the peak. The following steps are recommended:

    1. Define experience targets: for example, a per-request output rate during peak hours no lower than a certain threshold, with upper limits set for both TTFT and TPOT.
    2. Build a load model: distinguish the traffic share of three categories—short Q&A, long-form generation, and batch offline jobs.
    3. Load test to find the inflection point: gradually increase load, recording throughput, TPOT, error rate, and queue time, and find the point where throughput stops growing while latency rises sharply.
    4. Reserve a safety margin: use sixty to seventy percent of the inflection point as the daily ceiling, leaving the rest for bursts.
    5. Establish a degradation strategy: during peak hours, rate-limit extremely long contexts or low-priority tasks to protect the main-path experience.

    Illustrative load-test pseudocode:

    1. for concurrency in [8, 16, 32, 64, 128]:
    2. metrics = run_load_test(concurrency=concurrency, duration="5m")
    3. print(concurrency, metrics.throughput, metrics.tpot_p95, metrics.queue_time)

    4. Observability and Continuous Tuning

    Without measurement there is no optimization. At a minimum, collect: request volume, concurrency, batch size distribution, KV cache utilization, percentile values of TTFT and TPOT, queue time, and failure and retry rates. These metrics enable closed-loop tuning: if cache utilization is too high, adjust the eviction and reuse strategy; if TPOT percentiles rise, check the batch size cap and operator implementations; if queue time grows, then capacity or scheduling fairness needs adjustment. Within Baidu AI Cloud’s general capability system, log services, monitoring and alerting, and container platforms can be combined into an observability and elastic-scaling foundation like this.

    5. Common Pitfalls

    • Looking only at average rate: averages hide the long tail, so you must look at P95/P99.
    • Inferring online experience from offline throughput: offline scenarios have no TPOT constraint, so the conclusions cannot be transferred directly.
    • Ignoring prefix reuse: when a large number of requests share the same prompt, the benefit of prefix reuse is extremely high.
    • Enlarging batch size without limit: a bigger batch does not necessarily mean higher throughput; memory access and GPU memory become the new bottleneck.

    Conclusion

    A stable output rate during peak hours is a systems engineering effort. The core is to weigh “per-request experience” and “cluster throughput” on the same budget sheet: use continuous batching to raise effective concurrency, use GPU memory and cache management to hold the ceiling, use operators and numeric precision to lower TPOT, and use capacity planning and observability to ensure long-term stability. Mastering this approach lets you build an LLM inference service in your own business that delivers a smooth experience with controlled cost.