High-Throughput LLM Inference: Engineering Practices and Optimization Guide

    This article explains how to achieve high-throughput inference for large language models. It covers how to define key metrics such as TTFT, TPOT, end-to-end throughput, and effective throughput; how to locate bottlenecks in compute, memory bandwidth, or scheduling; and common optimization techniques including continuous batching, paged memory management, prefix reuse, quantization, and speculative decoding. It also outlines capacity planning, load testing, and fallback strategies so teams can reproduce stable output rates under peak traffic while keeping costs under control.

    1. Why High-Throughput Inference Matters: Lessons from a Usage Leaderboard

    A recent public leaderboard of model API usage showed a lightweight model entering the top three in weekly token volume, alongside two other lightweight models from the same family. Setting the specific products aside, the engineering takeaway is what matters: lightweight models can serve trillion-token workloads not only because they have fewer parameters, but because their inference services produce enough output per unit of compute and still maintain a stable output rate during peak hours (the commonly discussed target range is tens of tokens per second).

    For product teams, output rate directly shapes two experiences: the “typewriter” smoothness of interactive applications and the completion time of batch offline jobs. For platform teams, throughput determines how many concurrent requests a single GPU can serve, which in turn determines the cost per token. High-throughput inference is therefore not a single trick but a systems engineering effort spanning metric definitions, bottleneck analysis, and scheduling strategy.

    2. Define the Metrics First: Throughput, Latency, and Output Rate

    A common mistake in performance work is mixing different metrics together. Define the following terms at the start of any project:

    • Time to first token (TTFT): the time from when a request reaches the service to when the first token is emitted. It is mainly determined by the prefill stage and correlates strongly with input length and peak compute.
    • Time per output token (TPOT): the interval between two adjacent tokens during generation. Its reciprocal approximates the “tokens per second” perceived by the user.
    • End-to-end throughput: the total number of tokens produced by the whole cluster per unit of time, including both input and output.
    • Effective throughput: the throughput actually available to the business after subtracting retries, timeouts, and requests rejected by rate limiting.

    Note that statements like “tens of tokens per second available at peak” usually refer to a service level in which TPOT stays within an acceptable range under concurrent load, not the theoretical peak measured on an idle system. A more rigorous approach is to constrain performance with service level objectives:

    1. service_targets:
    2. ttft_p99_ms: 800
    3. tpot_p99_ms: 20 # roughly 50 tokens/s output rate per request
    4. availability: 0.999
    5. max_queue_wait_ms: 200

    With clear targets in place, every later optimization has an acceptance criterion.

    3. Locating the Bottleneck: Compute, Memory Bandwidth, or Scheduling

    Generation performance is usually constrained by one of three factors, and misdiagnosing it sends optimization in the wrong direction.

    1. Compute-bound: mainly seen in the prefill stage and with very long inputs. GPU utilization is high, and TPOT rises significantly as input length grows.
    2. Memory-bandwidth-bound: every generation step reads the model weights and the KV cache, making this a memory-intensive workload. Compute utilization may be low, yet latency still will not come down.
    3. Scheduling- and queue-bound: requests wait in a queue while the GPU sits idle, which points to poor concurrency control, batching windows, or timeout settings.

    A practical diagnostic method is layered observation: collect queue wait time, per-stage latency for each request, memory usage curves, and hardware utilization at the same time, then align them on a single timeline. If queue time dominates, fix scheduling first. If memory usage is near its limit with frequent swapping, fix memory management first. If both look normal but per-step latency is high, look at compute and memory access.

    4. General Optimization 1: Continuous Batching and Request Scheduling

    Traditional static batching requires all requests in a batch to start and finish together, so short requests must wait for long ones, wasting a great deal of capacity. Continuous batching schedules work at the granularity of a single step: after each generated step, the queue is checked again, finished requests leave immediately, and newly arrived requests can join at any time.

    Three points deserve attention in implementation:

    • Controlling length variance within a batch: bucket requests by input length so one very long request does not slow down the whole batch.
    • Preemption and recomputation: when memory is tight, suspend some requests and recompute or reuse cached state on resume, balancing latency against throughput.
    • Fairness: set quotas and priorities per tenant so a single large customer cannot fill the entire batching window.

    Illustrative scheduling loop:

    1. while running:
    2. batch = scheduler.form_batch(max_tokens=BUDGET)
    3. outputs = engine.step(batch) # one forward pass produces the next token for each request
    4. for req, tok in zip(batch, outputs):
    5. if tok.is_eos or req.length > req.max_new:
    6. req.finish()
    7. scheduler.admit_new_requests(queue) # newly freed slots are filled immediately
    8. metrics.observe(batch) # record TPOT and queue wait time

    5. General Optimization 2: Memory Management and Cache Reuse

    The KV cache is the main consumer of GPU memory, and its footprint grows linearly with “concurrency × context length.” Paged memory management is widely used in the industry: the cache is split into fixed-size blocks allocated on demand, which substantially reduces fragmentation and reserved waste. Two further general techniques build on this:

    • Prefix reuse: when multiple requests share the same system prompt, compute the prefix only once and let later requests reference it, lowering both TTFT and compute consumption.
    • Cache swapping and tiering: move cold data down to host memory or slower storage tiers, trading controlled swap-in and swap-out for higher concurrency.

    Any cache reuse must include tenant isolation and invalidation control to prevent context leakage and the data security problems it creates.

    6. General Optimization 3: Quantization, Speculative Decoding, and Parallelism

    • Quantization: representing weights and cache at lower bit widths reduces memory traffic and is one of the most direct ways to raise generation throughput. Validate accuracy with real business data rather than relying only on general benchmark scores.
    • Speculative decoding: a small draft model guesses several consecutive tokens, and the main model verifies them in a single pass, advancing multiple steps when they are accepted. The gain depends on the draft hit rate and is more pronounced for regular business output such as fixed formats or code completion.
    • Parallelism: tensor parallelism reduces per-GPU memory pressure but adds communication overhead; pipeline parallelism improves overall utilization but introduces bubbles. The choice usually has to be weighed at the cluster level.

    7. Capacity Planning and Load Testing: Making Peak Metrics Reproducible

    Whether an optimization works must be proven with reproducible load tests. Recommended steps:

    1. Build a real traffic profile: measure the distribution of input and output lengths, the peak-to-trough ratio, and the burst factor.
    2. Run stepped load tests: increase concurrency level by level, recording the throughput inflection point and the latency inflection point.
    3. Define elastic scaling policies: trigger scale-out based on queue length and TPOT rather than CPU utilization alone.
    4. Prepare fallback plans: at peak, automatically cap maximum output length, reduce draft steps, or switch to a smaller model to keep core paths available.
    5. Observe continuously: build dashboards for TTFT, TPOT, queue wait time, and cache hit rate, with alert thresholds configured.
    1. Sample load test record
    2. Concurrency Output throughput (token/s) TTFT_p99 TPOT_p99 Conclusion
    3. 16 820 210ms 14ms Latency-first tier
    4. 64 2600 430ms 18ms Recommended serving tier
    5. 128 3100 980ms 31ms Exceeds SLO; scale out or degrade

    8. Common Pitfalls

    • Looking only at idle peak numbers: idle data does not represent peak behavior, so SLOs measured under load must be the reference.
    • Blindly enlarging the batch window: a bigger batch does not always mean higher throughput, and past the memory and bandwidth inflection point latency deteriorates sharply.
    • Ignoring input-side cost: long system prompts raise both TTFT and memory usage, and prefix reuse is often more cost-effective than adding hardware.
    • Skipping quality regression: both quantization and speculative decoding need a business-side evaluation set to avoid being “faster but wrong.”

    9. Conclusion

    High-throughput inference is fundamentally about maximizing effective output per unit of compute under a latency constraint. Define the metrics clearly, locate the bottleneck accurately, then apply general techniques in order: continuous batching, paged memory management, prefix reuse, quantization, and speculative decoding. Combined with capacity planning based on a real traffic profile and a fallback plan, developers can reliably reproduce peak-hour output rates of tens of tokens per second in their own environments and keep costs growing linearly and predictably with the business.