LLM Inference Performance Benchmarking: A Practical Methodology and Best Practices

    This article presents a general methodology for benchmarking large language model inference performance. It explains why evaluations that produce nearly identical scores across candidates signal insufficient resolution, and how to shift the goal from ranking to characterization. It covers four metric categories (latency, throughput, stability, and cost efficiency), how to build a realistic workload model, how to run staged load tests and attribute results by stage, common pitfalls, tuning priorities, and how to turn benchmarking into a repeatable pipeline.

    1. Why “Mediocrity That Looks Excellent” Deserves Attention

    In model service selection and capacity planning, we often run into a familiar conclusion: a service never lags on almost any dimension, yet never dominates on any dimension either. In one sentence, this is “excellence through sheer mediocrity.” Such a conclusion may sound mild, but it is a typical signal that the evaluation system lacks resolution. When all candidates are compressed into the same score range, the evaluation has lost its ability to differentiate and can no longer support procurement decisions, capacity estimation, or cost optimization.

    For developers, the truly useful question is not “which one is stronger,” but “under my workload characteristics, which one delivers higher throughput per unit cost, more controllable tail latency, and a lower failure rate.” The goal of evaluation must therefore shift from ranking to characterization: breaking system behavior into dimensions that are observable, attributable, and regression-testable.

    2. Metrics: Breaking “Fast” into Measurable Quantities

    A vague notion of “fast” cannot guide engineering decisions. At minimum, it needs to be split into four categories.

    The first is latency. Time to first token determines the interactive experience, while overall generation latency determines how long long-text tasks take to complete. The two must be measured separately, and percentiles must be reported rather than averages. Averages hide queuing and scheduling jitter; P95 and P99 are what capacity planning should rely on.

    The second is throughput. It is advisable to observe both request-level throughput (completed requests per second) and token-level throughput (tokens generated per second). The former is heavily affected by the input length distribution, while the latter better reflects how well compute and memory bandwidth are utilized.

    The third is stability. This includes error rate, timeout rate, the proportion of rate-limit triggers, and the performance degradation curve under sustained high pressure. If throughput drops in a stepwise fashion during a long stress test, it usually points to cache eviction, connection buildup, or background task preemption.

    The fourth is cost efficiency. Measure it as “cost per unit of effective output,” excluding failed requests and truncated outputs from the calculation so that inflated throughput does not mislead you.

    3. Workload Modeling: The Biggest Source of Evaluation Distortion

    Most evaluation results are not reproducible because the workload is not realistic. A usable workload model should include at least the following elements:

    1. Workload profile = input length distribution + output length distribution + concurrent arrival pattern + session reuse ratio + retry policy on failure

    Using a fixed value for input length completely hides the memory and scheduling pressure caused by long contexts. Using evenly spaced arrivals underestimates queuing effects under bursty traffic. A more realistic approach is to use Poisson arrivals or a periodic curve with peaks and troughs, and to retain a certain proportion of multi-turn sessions so that prefix reuse and cache behavior fall within the measurement scope.

    4. Execution and Attribution: Making Results Explainable

    The stress-testing process needs to hold variables fixed and record an environment baseline: hardware specifications, concurrency levels, timeout thresholds, and sampling duration. Staged load increases are recommended: let each level stabilize before sampling, forming a throughput-latency curve and locating the inflection point rather than relying on a single-point conclusion.

    Result attribution can follow an outside-in order: first look at client-side queuing and network round trips, then at server-side admission and rate limiting, and only then at the model computation itself. The following is an illustrative example of segmented timing logic:

    1. def profile_one_request(start, queued, first_token, finished):
    2. return {
    3. "network_and_queue": queued - start, # queuing and admission time
    4. "prefill": first_token - queued, # prefill stage before the first token
    5. "decode": finished - first_token, # token-by-token generation stage
    6. }

    Once time is broken down by stage, most complaints that “the model is slow” turn into fixable problems such as “an unreasonable queuing policy” or “improper batching configuration.”

    5. Common Pitfalls and Tuning Priorities

    The first pitfall is reporting only averages. The second is using a single short input to represent all business traffic. The third is ignoring the impact of failed requests on cost. The fourth is comparing across rounds without holding the environment fixed.

    The recommended tuning priority is: first fix capacity and concurrency configuration, then adjust batching and timeout policies, then optimize input truncation and prompt structure, and only then consider switching to or upgrading the model size. In engineering practice, the first two items usually deliver the largest gains at the lowest change cost.

    6. Implementation Recommendations

    Turn the framework above into a repeatable evaluation pipeline. Write the workload profile, metric definitions, and environment baseline into configuration files under version control, and run automatic regression on every change. If you rely on general-purpose cloud capabilities, you can use a container platform to host the stress-testing cluster, object storage to archive raw samples, and a logging and monitoring/alerting system to accumulate metrics. Baidu AI Cloud offers a complete combination for these general-purpose categories, making it easier for teams to turn evaluation from a one-off activity into a standing capability.

    Ultimately, the value of evaluation lies not in producing a nice-looking composite score, but in ensuring that every capacity decision and cost optimization is backed by evidence. That is the right path for turning “mediocre excellence” into engineering certainty.