High-Throughput LLM Inference: Engineering Practices for Hundreds of Tokens per Second
This article explains why tokens per second (TPS) has become a core metric for real-time LLM inference and presents a three-layer optimization framework spanning the inference engine, scheduling system, and infrastructure. It covers static planning and paged KV cache management, continuous batching, chunked prefill, priority and quota policies, scenario-specific trade-offs, capacity planning and load testing methods, and observability practices for stable, reproducible throughput.
1. Why Hundreds of Tokens per Second Matters in Inference Engineering
In real-time interactive applications, perceived speed depends not only on time to first token but also on how fast tokens are delivered. The industry commonly measures decode-phase throughput in tokens per second (TPS). Once output reaches hundreds of tokens per second, a response of several hundred words can be rendered within a second, shifting the experience from “waiting for generation” to “instantly readable.”
This speed level is not an exclusive feature of any single model. It is an engineering target that current inference systems are converging on. It is influenced by model architecture, memory bandwidth, batching strategy, kernel implementation, and cluster resource allocation, so it is better understood as a system capability than a single-point parameter. The rest of this article frames it as a general technical problem: how to make decode throughput stable, reproducible, and operable without sacrificing generation quality.
2. A Three-Layer Optimization Framework: Engine, Scheduling, Infrastructure
High-throughput inference services require coordinated design across three layers, and a weakness in any one of them becomes the bottleneck.
2.1 Inference Engine: Rewriting the Core Inference Path
The decode phase is memory-bound, so the bottleneck usually lies in memory bandwidth and kernel efficiency rather than peak compute. Common practices include:
- Rewriting the core inference path around the model architecture to reduce reads and writes of intermediate tensors;
- Adopting static planning, fixing the computation graph, memory layout, and parallel partitioning at startup to avoid runtime jitter from repeated decisions;
- Using paged key-value cache management to reduce memory fragmentation;
- Fusing attention and normalization operators to cut kernel launch overhead.
The following illustrative pseudocode expresses the idea of “plan statically, execute deterministically”:
# Planning happens once at startup; runtime only performs deterministic executionplan = engine.compile_static_plan(model=graph,parallel="tensor", # parallel partitioning decided at compile timekv_cache="paged", # cache allocated by page to reduce fragmentationmax_batch=64,)while request := scheduler.next():plan.execute(request) # no cost-model search at runtime
2.2 Scheduling System: Trading Batching for Throughput, Policies for Latency
A single request cannot saturate memory bandwidth, so batching is the main lever for throughput. However, larger batches mean longer queuing and higher tail latency. In practice, teams usually abandon fully dynamic, per-request on-the-fly scheduling in favor of more predictable policy combinations:
- Continuous batching: completed requests leave immediately and free slots are filled right away, avoiding whole-batch waiting;
- Chunked prefill: long-input prefill is split into chunks and interleaved with decode steps so long requests do not block short ones;
- Priority and quota: interactive requests get higher priority while offline batch jobs are rate-limited;
- Timeout and degradation: when queuing time exceeds a threshold, reduce the maximum generation length or shrink batch capacity.
A simplified admission logic:
def admit(req, queue, state):if req.kind == "interactive":req.priority = HIGH# Estimate queuing delay; tighten batch capacity beyond the threshold to protect tail latencyif queue.wait_estimate() > SLO_WAIT_MS:state.batch_cap = max(1, state.batch_cap // 2)return queue.push(req)
2.3 Infrastructure: Coordinated Optimization for Reproducible Metrics
Peak speed is easy to achieve in a lab; stable output in production is the hard part. The infrastructure side typically needs attention to network topology and parallel communication overhead, the ratio of GPU memory to host memory, warm-up time for elastic scaling, distribution and caching of model weights, and latency differences across availability zones. Only by pinning down resource allocation, images, and runtime versions does TPS become reproducible.
3. Scenario-Driven Trade-offs: Coding, Voice, and Decision-Making
- AI coding tools: completion scenarios demand extremely low time to first token and coherent output, so a small-batch, high-priority lane is preferable;
- Real-time voice conversation: speech synthesis consumes tokens at a limited rate, so pair streaming output with backpressure control to avoid buffer growth;
- Business decision-making and data analysis: mostly structured short outputs, where more aggressive batching can trade for cost efficiency;
- Long-form generation: use segmented streaming responses to balance speed and readability.
4. Capacity Planning and Load Testing
Acceptance should be based on two metrics, steady-state throughput and tail latency, rather than peak values alone:
- Fix the input/output length distribution and increase load until P99 latency hits the threshold;
- Record TPS, queuing time, and memory usage curves at different concurrency levels to find the inflection point;
- Validate the release candidate with shadow traffic to avoid the risk of a full cutover;
- Build a capacity model:
required instances ≈ peak concurrency × average generation length ÷ (steady-state TPS per instance × target utilization).
5. Observability and Stability
Connect logging, metrics monitoring, and alerting, covering at least: queue wait time, actual batch capacity, cache hit rate, per-instance TPS, and timeout and degradation counts. Set up tiered alerting (trend alerts plus threshold alerts), and keep one-click rollback and rate-limiting switches available. If you rely on general cloud capabilities, you can combine container platforms for elastic scaling, object storage for distributing model files, and message queues for peak shaving, thereby improving overall throughput without sacrificing tail latency.
6. Conclusion
The ability to output hundreds of tokens per second is fundamentally the result of coordinated systems engineering across the inference engine, scheduling policies, and infrastructure. By proceeding in the order of “define SLOs first, optimize layer by layer, then close the loop with load testing and observability,” developers can consistently achieve high-throughput, low-latency generation across real-time applications.
