概述
尾部百分位数如p95和p99显示慢请求行为,但指标定义和用户体验目标取决于服务栈和工作负载。
深入探讨
A streamed language-model response has several timing components. Time to first token (TTFT) measures how long a request waits before the first output token arrives. Inter-token latency (ITL), sometimes reported as time per output token, describes the gaps during generation. End-to-end latency includes the full request through the final output; throughput describes how many requests or tokens a system handles over time. These metrics help distinguish different problems. Long TTFT can reflect queueing, network delay, long prompts, or prompt processing. High ITL can reflect decode speed, model size, or contention. Aggregate throughput may rise under batching even while an individual request waits longer. A fast average can hide slow tail requests, so teams often inspect p50, p95, and p99 along with error rates and token counts. Definitions need care. Some tools report time-per-output-token (TPOT), computed from end-to-end latency and TTFT; others report token intervals directly. The vLLM benchmark documentation defines its metrics and advises users to evaluate in serving conditions. Compare measurements only when workload, streaming mode, prompt lengths, output lengths, concurrency, hardware, and network conditions are comparable. No one metric establishes that a product feels fast. A typing assistant may need low first-token delay; a long research report may tolerate slower initial output if its final answer is good. Set user-centered service objectives, sample real requests, and monitor distributions over time rather than optimizing one average in isolation.
现实世界的实施
团队跟踪p95 TTFT,以查看在高峰负载下聊天界面是否能及时响应。
工程师使用相同的提示和输出长度比较不同模型配置下的ITL。
服务会分别报告每秒总令牌数和每个用户的响应时间。
基准测试记录 p99 延迟和请求失败,而不是仅报告平均值。
首次令牌时间与延迟指标的未来
服务栈可能提供更丰富的追踪,能够区分排队、预填充、解码和网络延迟。更好的遥测可以帮助团队在不对每个工作负载进行过度配置的情况下满足不同的交互目标。只有在公开工作负载和指标定义的情况下,比较才有意义。未来的仪表盘应将尾部延迟与用户任务和质量结果关联,并在显示速度的同时展示不确定性和失败率。共享的基准格式可能提升跨供应商的可重复性,而真实用户监控在流量高峰和发布时的部署仍然是必不可少的。
付诸实践
为什么这很重要
- 成本与预算. 多年来,架构决策决定着性能和运营成本。
- 更清晰的判决. 技术教育帮助团队选择正确的堆栈,而不仅仅是最新的堆栈。
- 质量控制. 更好的工程选择可以减少生产中的可靠性事故。
留意
- 优化一项基准测试可以隐藏更广泛的系统弱点。
- 基础设施和维护成本常常被低估。
- 随着系统变得更加复杂,安全性和可观察性差距可能会扩大。
后续步骤
- 在实施之前定义延迟、质量和成本目标。
- 在实际负载和数据条件下进行基准测试。
- 仪器监控错误、漂移和用户影响。
- 在扩展之前准备回滚和事件响应路径。
不断探索
常见问题
什么是首次令牌时间和延迟指标?
首次令牌时间(TTFT)衡量生成第一个令牌前的延迟,而令牌间延迟(ITL)衡量生成令牌之间的间隔,吞吐量则衡量单位时间内的输出量。p95、p99 等尾部百分位展示慢请求行为,但指标定义和用户体验目标取决于服务栈和工作负载。
聚合吞吐量与单请求延迟有何不同?
服务可以提升每秒总令牌数,同时单个请求的等待时间会更长。
为什么除了平均值外还要检查 p95 或 p99 延迟?
尾部指标描述请求分布中高延迟的部分。
为什么基准比较必须使用相似的提示、输出长度和负载?
工作负载特性会影响测得的服务性能。