LLM Inference Services: Speed, Cost, and Tier Selection Practices

    This article explains how engineering teams can evaluate large language model inference services by considering speed and cost together. It defines core metrics such as output throughput, time to first token, end-to-end latency, and cost per successful task; describes a task-based approach to tier selection; shows how to build reproducible benchmarks; and outlines engineering optimization considerations.

    Background: Evaluate Speed and Cost Together

    Large language model services are usually divided into multiple tiers by capability and speed. High-speed tiers generally provide shorter response times and higher throughput, and their unit price may also be higher. Looking only at speed or only at price can easily lead to one-sided conclusions. Engineering teams need to put both into the same evaluation framework and combine them with business scenarios to determine which tier is most suitable.

    This article provides a practical workflow that can be directly applied from five aspects: metric definitions, selection methods, benchmarking, engineering optimization, and risk control.

    1. Unify Core Metrics

    To evaluate an inference service, at least the following four metrics need attention.

    1. Output Throughput (Tokens per Second)

    This refers to the number of output tokens generated by the model per second. Two measurements need to be distinguished: single-request streaming speed, i.e., generation speed when one request exclusively uses resources; and service aggregate throughput, i.e., the total number of tokens produced per second across the service. The former affects the waiting experience of a single user; the latter determines how much concurrency the service can support.

    2. Time to First Token (TTFT)

    This is the time from sending a request to receiving the first output token. In chat and streaming display scenarios, TTFT determines whether users feel that there is an immediate response. It is affected by input length, queue time, and network round trip.

    3. End-to-End Latency

    This can be estimated with the following approximate formula:

    End-to-end latency ≈ TTFT + number of output tokens / output throughput

    4. Cost per Task

    Most services bill input tokens and output tokens separately. The cost per request is:

    Cost per request = input tokens × input unit price + output tokens × output unit price

    When calculating, retries, failures, and timed-out requests must be included in the total cost. The real cost of successfully completing a task equals the total cost of all attempts divided by the number of successes.

    1. function estimate_cost_per_task(request_stats, pricing):
    2. total_cost = 0
    3. success_count = 0
    4. for r in request_stats:
    5. cost = r.input_tokens * pricing.input_price + r.output_tokens * pricing.output_price
    6. total_cost += cost # Include failures and retries in the total cost
    7. if r.status == "success":
    8. success_count += 1
    9. return total_cost / success_count

    The prices above should be replaced with the latest rates published by the service provider. This article does not list specific prices because prices change over time.

    2. Decision Method for Tiered Selection

    Selection is not about choosing the fastest option or the cheapest option. The right questions are: Does quality meet the bar? Can latency meet requirements? Is cost within budget?

    2.1 Divide by Task Type

    • High-frequency, short-text, structurally simple tasks, such as intent recognition, field extraction, tag classification, and short replies. These tasks are latency-sensitive and produce short outputs, so they usually fit tiers with high speed and low unit price.
    • Multi-step reasoning, long-document analysis, complex code generation, and tasks that must strictly follow complex instructions should prioritize tiers with stronger capabilities. The cost of failure in these tasks is high, and unit price differences are not enough to offset quality loss.

    2.2 Unit Price Multiple Is Not Equal to Total Cost Multiple

    When the unit price of a high-speed tier is several times that of the base tier, you cannot directly conclude that it is more expensive. There are two reasons:

    • If the high-speed tier completes the same task in less time, the compute instances, connections, and user waiting time involved all decrease.
    • If the high-speed tier has a lower retry rate, the extra cost caused by failed requests is offset.

    Conversely, if a task is quality-sensitive and the two tiers have comparable quality, choosing the lower-price tier is more cost-effective. The final conclusion must be based on your own data.

    2.3 Tier Selection Evaluation Dimensions

    Dimension Question to answer Data source
    Quality Does accuracy on the in-house evaluation set meet the bar? Offline evaluation
    Latency Does p95 end-to-end latency meet the service target? Load testing
    Cost Is cost per successful task within budget? Billing and request logs
    Stability Are error rate and rate-limiting frequency acceptable? Production monitoring
    Context Does the maximum input length cover business needs? Sample statistics

    3. Build Reproducible Benchmarks

    3.1 Construct an Evaluation Set

    Sample from real traffic and stratify by task type, with at least several hundred samples per type. Samples should include normal inputs, boundary inputs, and abnormal inputs. Label each sample with reference answers or scoring rules, avoiding quality judgments based only on subjective impressions.

    3.2 Design a Load-Test Matrix

    • Concurrency levels: test at least low, medium, and high concurrency, for example, 1, 8, and 32.
    • Time windows: test during working hours and off-peak hours separately to observe changes in rate limiting and queuing.
    • Repeat count: run each condition multiple times and take the median and p95 to reduce the impact of random fluctuation.

    3.3 Example Test Script

    1. for concurrency in [1, 8, 32]:
    2. results = run_load(
    3. model=candidate_model,
    4. dataset=eval_set,
    5. concurrency=concurrency,
    6. repeat=3,
    7. )
    8. report(
    9. concurrency=concurrency,
    10. ttft_p50=percentile(results.ttft, 50),
    11. ttft_p95=percentile(results.ttft, 95),
    12. e2e_p95=percentile(results.latency, 95),
    13. error_rate=results.errors / results.total,
    14. quality_score=score(results.outputs, eval_set.labels),
    15. )

    Each test should record the model version, request parameters, concurrency settings, and test time for later comparison.

    4. Engineering Optimization Methods

    4.1 Control Output Length