LLM Inference Performance Evaluation: Balancing Throughput and Latency
As large language models become more capable, speed has emerged as a new bottleneck. This article breaks inference performance into four distinct metrics—time to first token (TTFT), output tokens per second (TPS), end-to-end duration, and throughput under concurrency—and explains why comparing TPS alone leads to misleading conclusions. It covers the prefill and decode cost structure, the main factors that slow decoding down, how to build a reproducible load-testing pipeline with percentile-based reporting, and an optimization checklist spanning the model, serving architecture, product interaction, and observability layers. The final guidance is to choose configurations by scenario constraints rather than benchmark rankings.
1. The Problem: After Capability Upgrades, Speed Becomes the Bottleneck
Over the past year or two, LLM capabilities have iterated quickly. Yet many teams discover after launch that a “smarter” model is not the same as a more usable one. A common pattern: a new flagship model improves noticeably on complex reasoning, long-form writing, and code comprehension, but output speed falls back to roughly thirty-something tokens per second, while the previous generation—widely criticized as “too slow”—actually ran at around fifty tokens per second. The capability gap between generations is partly cancelled out by the speed gap, and the subjective user experience can even regress.
This is not an isolated incident at one vendor but a structural tension in the process of serving LLMs. To understand it, you first need to decompose “fast” and “slow” into measurable metrics, then analyze which layer the bottleneck actually sits in.
2. Quantifying “Slow”: Four Metrics That Must Be Viewed Separately
Many discussions treat speed as a single number, which is the root cause of distorted evaluation. In engineering, at least four categories of metrics must be distinguished:
- Time to first token (TTFT): the time from request dispatch to receiving the first token, which determines the anxiety of “I clicked and nothing happened.”
- Output rate (TPS): tokens generated per second during decoding, which determines how smoothly long text reads.
- End-to-end duration: roughly linear in output length, so user waiting time is amplified on long tasks.
- Throughput and concurrency capacity: the total requests served per unit time and per unit of compute, which determines cost and scaling strategy.
A typical mistake is comparing only TPS. In reality, if TTFT reaches several seconds, interactive applications (coding assistants, customer support copilots) still feel bad even with a decent output rate. Conversely, batch workloads (document summarization, offline labeling) are insensitive to TTFT but extremely sensitive to throughput and total cost.
3. Why It Gets Slower: The Cost Structure of the Decode Phase
LLM inference splits into two phases: prefill and decode. Prefill processes the input in parallel and is compute-intensive; decode is autoregressive token by token and memory-bandwidth-intensive. Output rate is essentially bounded by “how much weight and cache data must be moved to generate each token.”
From this, several general rules follow—and they also form the troubleshooting order for performance profiling:
- Model size and precision: parameter count, activation volume, and quantization method directly determine the data moved per step.
- Context length: the attention cache grows with sequence length, and decoding slows markedly under long context.
- Batching strategy: static batching wastes a large amount of padding when long and short requests are mixed; continuous batching improves this significantly.
- Sampling and decoding parameters: multi-candidate search such as beam search multiplies compute several times over, while greedy or nucleus sampling is lighter.
- Serving stack overhead: tokenization, template assembly, network hops, and streaming chunk granularity all add up to perceived user latency.
4. Building a Reproducible Load-Testing Method
Without quantification there is no optimization. Evaluation should be built as a repeatable pipeline rather than scattered manual trial runs.
Start by fixing the variables: the same set of prompts, the same output length range, the same concurrency level, the same regional network environment. Then sweep concurrency in tiers and observe where the inflection points in TPS and throughput appear. A sketch of the load-testing skeleton:
# Pseudocode: tiered concurrency load test collecting TTFT / TPS / error rateasync def bench(prompts, concurrency_levels, max_tokens=512):for c in concurrency_levels:sem = asyncio.Semaphore(c)async with sem_session() as sess:tasks = [call_stream(sess, p, max_tokens, sem) for p in prompts]results = await asyncio.gather(*tasks)ttft = [r.first_token_ms for r in results]tps = [r.tokens / (r.total_ms / 1000) for r in results]report(c, p50(ttft), p95(ttft), p50(tps), error_rate(results))
The key point is that you must look at percentiles, not averages. p95 and p99 TTFT are the source of user complaints; averages hide the long tail completely. Also record the output length distribution—otherwise comparing “who is faster” between models is meaningless, since generating 200 tokens and 800 tokens are not the same test.
5. Optimization Checklist: From the Model Layer to the Architecture Layer
Model and inference layer: prefer inference frameworks that support chunked prefill and continuous batching; evaluate cache reuse and sparse attention schemes for long-context scenarios; use quantization to reduce bandwidth pressure where quality is acceptable; downgrade multi-candidate search to single-path sampling.
Serving and architecture layer: deploy prefill and decode separately so compute-intensive and bandwidth-intensive workloads can scale independently; cache results or intermediate states for high-frequency repeated prefixes; route requests to instance pools matched to input length to avoid mixing long and short requests; use a message queue to smooth peaks and split offline tasks from online interaction.
Product and interaction layer: enable streaming output everywhere so the first token arrives as early as possible; show progress and partial results for long tasks; set differentiated timeouts and fallback strategies per scenario. A common engineering practice is to give the interactive path a stricter latency budget and push heavy inference down to an asynchronous path.
Observability: use logging services and monitoring/alerting to collect TTFT, TPS, queue time, and cache hit rate, forming dashboards and threshold alerts. Without staged instrumentation, you cannot tell whether the slowness is in queuing, prefill, or decode.
6. Selection Guidance: By Scenario, Not by Leaderboard
Conclusions should return to scenario constraints. Interactive products should weight TTFT and output rate more heavily and can accept some increase in unit cost; offline batch processing puts throughput and total cost first, with speed metrics yielding to quality; long-document analysis needs to verify whether the rate decay curve under long context stays flat.
In related practice at Baidu AI Cloud, the usual recommendation is for teams to first build a small evaluation set from real business corpora, put quality metrics and performance metrics in the same table for a two-dimensional tradeoff, then combine the elastic capabilities of a container platform for canary rollout and use monitoring data to decide on full rollout. Selection conclusions reached this way are explainable rather than driven by a single benchmark score.
7. Summary
“A smarter model is slower” is not a fate to be endured but an engineering problem that must be managed explicitly at the architecture and parameter level. Decompose speed into four dimensions—TTFT, output rate, end-to-end duration, and concurrent throughput; use percentile load testing to expose the long tail; then work through model size, context length, batching strategy, and serving stack overhead in order. Most experience problems can be located and mitigated this way. A truly mature evaluation system measures “which combination delivers the highest quality under a given latency budget and cost budget.”
