vllm-bench-serve
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesevLLM Bench Serve
vLLM Bench Serve
Benchmark vLLM or any OpenAI-compatible serving endpoint using the CLI. Measures throughput, latency (TTFT, TPOT), and goodput against configurable request load.
vllm bench serveReference: vLLM Bench Serve Documentation
使用 CLI对vLLM或任何兼容OpenAI的服务端点进行基准测试。针对可配置的请求负载,测量吞吐量、延迟(TTFT、TPOT)以及有效吞吐量。
vllm bench servePrerequisites
前置条件
- vLLM installed (or any OpenAI-compatible server running)
- A vLLM server or API endpoint already serving a model
- Python environment with vLLM for the benchmark client
- 已安装vLLM(或运行任何兼容OpenAI的服务器)
- 已部署模型的vLLM服务器或API端点
- 用于基准测试客户端的Python环境(需安装vLLM)
Quick Start
快速开始
Basic benchmark against local vLLM server (default random dataset, 1000 prompts):
bash
vllm bench serve \
--backend openai-chat \
--host 127.0.0.1 \
--port 8000 \
--model Qwen/Qwen2.5-1.5B-Instruct \
--endpoint /v1/chat/completionsSave results to JSON:
bash
vllm bench serve \
--backend openai-chat \
--host 127.0.0.1 \
--port 8000 \
--model Qwen/Qwen2.5-1.5B-Instruct \
--endpoint /v1/chat/completions \
--save-result \
--result-dir ./bench-results \
--metadata "version=0.6.0" "tp=1"Note: When using, you must specify--backend openai-chat(default is--endpoint /v1/chat/completions)./v1/completions
针对本地vLLM服务器的基础基准测试(默认random数据集,1000条提示词):
bash
vllm bench serve \
--backend openai-chat \
--host 127.0.0.1 \
--port 8000 \
--model Qwen/Qwen2.5-1.5B-Instruct \
--endpoint /v1/chat/completions将结果保存为JSON:
bash
vllm bench serve \
--backend openai-chat \
--host 127.0.0.1 \
--port 8000 \
--model Qwen/Qwen2.5-1.5B-Instruct \
--endpoint /v1/chat/completions \
--save-result \
--result-dir ./bench-results \
--metadata "version=0.6.0" "tp=1"注意: 使用时,必须指定--backend openai-chat(默认值为--endpoint /v1/chat/completions)。/v1/completions
Core Arguments
核心参数
| Argument | Default | Description |
|---|---|---|
| | Backend type: |
| | Server host |
| | Server port |
| - | Alternative: full base URL instead of host:port |
| | API endpoint; use |
| (from /v1/models) | Model name |
| | Number of prompts to process |
| | Requests per second; |
| - | Max concurrent requests (caps parallelism) |
| | Warmup requests before measuring |
| 参数 | 默认值 | 描述 |
|---|---|---|
| | 后端类型: |
| | 服务器主机地址 |
| | 服务器端口 |
| - | 替代方案:完整的基础URL,无需指定host:port |
| | API端点;使用openai-chat后端时需用 |
| (来自/v1/models) | 模型名称 |
| | 待处理的提示词数量 |
| | 每秒请求数; |
| - | 最大并发请求数(限制并行度) |
| | 正式测量前的预热请求数 |
Datasets
数据集
| Use Case |
|---|---|
| Synthetic random prompts (default) |
| ShareGPT conversation format; requires |
| Sonnet-style prompts |
| HuggingFace dataset; requires |
| Custom dataset; requires |
| Prefix repetition benchmark |
| Random multimodal (images/videos) |
| Spec bench dataset |
Dataset-specific options (examples):
bash
undefined | 使用场景 |
|---|---|
| 合成随机提示词(默认) |
| ShareGPT对话格式;需指定 |
| Sonnet风格提示词 |
| HuggingFace数据集;需指定 |
| 自定义数据集;需指定 |
| 前缀重复基准测试 |
| 随机多模态(图片/视频) |
| Spec bench数据集 |
数据集专属配置示例:
bash
undefinedRandom: control input/output length
Random:控制输入/输出长度
--dataset-name random --random-input-len 1024 --random-output-len 128
--dataset-name random --random-input-len 1024 --random-output-len 128
Sonnet defaults: input 550, output 150, prefix 200
Sonnet默认配置:输入550,输出150,前缀200
--dataset-name sonnet --sonnet-input-len 550 --sonnet-output-len 150
--dataset-name sonnet --sonnet-input-len 550 --sonnet-output-len 150
HuggingFace dataset
HuggingFace数据集
--dataset-name hf --dataset-path "lmarena-ai/VisionArena-Chat" --hf-split test
--dataset-name hf --dataset-path "lmarena-ai/VisionArena-Chat" --hf-split test
General overrides (map to dataset-specific args)
通用覆盖配置(映射到数据集专属参数)
--input-len 512 --output-len 256
undefined--input-len 512 --output-len 256
undefinedLoad Control
负载控制
bash
undefinedbash
undefinedFixed request rate (Poisson process)
固定请求速率(泊松过程)
--request-rate 10
--request-rate 10
More bursty arrivals (gamma distribution, burstiness < 1)
更具突发性的请求到达(伽马分布,burstiness < 1)
--request-rate 10 --burstiness 0.5
--request-rate 10 --burstiness 0.5
Ramp-up from low to high RPS
请求速率从低到高线性提升
--ramp-up-strategy linear --ramp-up-start-rps 1 --ramp-up-end-rps 50
--ramp-up-strategy linear --ramp-up-start-rps 1 --ramp-up-end-rps 50
Limit concurrency (useful for rate-limited APIs)
限制并发数(适用于有速率限制的API)
--max-concurrency 32
undefined--max-concurrency 32
undefinedResults and Metrics
结果与指标
| Argument | Description |
|---|---|
| Save benchmark results to JSON |
| Include per-request TTFT, TPOT, errors in JSON |
| Append to existing result file |
| Directory for result files |
| Custom filename (default: |
| Metrics for percentiles: |
| Percentile values, e.g. |
| SLO for goodput: |
| 参数 | 描述 |
|---|---|
| 将基准测试结果保存为JSON |
| 在JSON中包含每条请求的TTFT、TPOT、错误信息 |
| 添加到已有的结果文件中 |
| 结果文件存储目录 |
| 自定义文件名(默认: |
| 百分位指标: |
| 百分位数值,例如 |
| 有效吞吐量的服务水平目标(SLO): |
Sampling Parameters (OpenAI-compatible backends)
采样参数(兼容OpenAI的后端)
bash
--temperature 0.7 --top-p 0.95 --top-k 50
--frequency-penalty 0 --presence-penalty 0 --repetition-penalty 1.0bash
--temperature 0.7 --top-p 0.95 --top-k 50
--frequency-penalty 0 --presence-penalty 0 --repetition-penalty 1.0Common Workflows
常见工作流
1. Throughput test with random dataset (burst):
bash
vllm bench serve --backend openai-chat --host 127.0.0.1 --port 8000 \
--model Qwen/Qwen2.5-1.5B-Instruct \
--endpoint /v1/chat/completions \
--dataset-name random \
--num-prompts 500 --random-input-len 512 --random-output-len 1282. Latency test with fixed QPS:
bash
vllm bench serve --backend openai-chat --host 127.0.0.1 --port 8000 \
--model Qwen/Qwen2.5-1.5B-Instruct \
--endpoint /v1/chat/completions \
--request-rate 5 --num-prompts 200 \
--save-result --percentile-metrics ttft,tpot --metric-percentiles 50,993. Benchmark against remote API (base-url):
bash
vllm bench serve --backend openai-chat \
--base-url "https://api.example.com/v1" \
--model my-model \
--header "Authorization=Bearer $API_KEY"4. Run inside Docker (when vLLM client not on host):
bash
docker exec <container-name> vllm bench serve \
--backend openai-chat --host 127.0.0.1 --port 8000 \
--model Qwen/Qwen2.5-1.5B-Instruct \
--endpoint /v1/chat/completions \
--dataset-name random --num-prompts 1001. 使用random数据集进行吞吐量测试(突发模式):
bash
vllm bench serve --backend openai-chat --host 127.0.0.1 --port 8000 \
--model Qwen/Qwen2.5-1.5B-Instruct \
--endpoint /v1/chat/completions \
--dataset-name random \
--num-prompts 500 --random-input-len 512 --random-output-len 1282. 固定QPS的延迟测试:
bash
vllm bench serve --backend openai-chat --host 127.0.0.1 --port 8000 \
--model Qwen/Qwen2.5-1.5B-Instruct \
--endpoint /v1/chat/completions \
--request-rate 5 --num-prompts 200 \
--save-result --percentile-metrics ttft,tpot --metric-percentiles 50,993. 针对远程API的基准测试(使用base-url):
bash
vllm bench serve --backend openai-chat \
--base-url "https://api.example.com/v1" \
--model my-model \
--header "Authorization=Bearer $API_KEY"4. 在Docker内运行(当vLLM客户端不在主机上时):
bash
docker exec <container-name> vllm bench serve \
--backend openai-chat --host 127.0.0.1 --port 8000 \
--model Qwen/Qwen2.5-1.5B-Instruct \
--endpoint /v1/chat/completions \
--dataset-name random --num-prompts 100Troubleshooting
故障排除
- Connection refused: Ensure the server is running and /
--hostor--portare correct.--base-url - Model not found: Pass explicitly or ensure
--modelreturns the model./v1/models - URL must end with chat/completions: Use when
--endpoint /v1/chat/completions.--backend openai-chat - Rate limit / 429: Reduce or
--request-rate.--max-concurrency - Ready check: Use to wait for the endpoint before benchmarking.
--ready-check-timeout-sec 60 - SSL: Use for self-signed certificates.
--insecure
- 连接被拒绝:确保服务器正在运行,且/
--host或--port配置正确。--base-url - 模型未找到:显式传递参数,或确保
--model能返回该模型。/v1/models - URL必须以chat/completions结尾:使用时,需指定
--backend openai-chat。--endpoint /v1/chat/completions - 速率限制/429错误:降低或
--request-rate的值。--max-concurrency - 就绪检查:使用,在基准测试前等待端点就绪。
--ready-check-timeout-sec 60 - SSL问题:使用参数忽略自签名证书。
--insecure
Notes
注意事项
- For embeddings/rerank benchmarks, use ,
--backend openai-embeddings, orvllm-pooling.vllm-rerank - requires
--profileon the server for vLLM profiling.--profiler-config - Goodput SLOs are useful for SLA-style analysis; see DistServe paper for details.
- 对于嵌入/重排序基准测试,使用、
--backend openai-embeddings或vllm-pooling。vllm-rerank - 参数需要服务器端配置
--profile才能进行vLLM性能分析。--profiler-config - 有效吞吐量SLO适用于服务水平协议(SLA)风格的分析;详情请参考DistServe论文。