L2 系统设计 · 分布式 vLLM/SGLang Prefill-Decode 分离推理与 KV 路由架构
对标 AI Infra / Inference Engineer 终面核心题:拆解长上下文高并发下的计算瓶颈(Compute-Bound Prefill)与显存带宽瓶颈(Memory-Bandwidth-Bound Decode)相互干扰问题,设计 P/D 分离集群、RDMA/NVLink KV Cache 传输、Radix 前缀亲和路由与分级成本 FinOps 调度。
适用场景 (Best For)
冲刺 OpenAI / Anthropic / Databricks / Anyscale / Fireworks / NVIDIA AI Infra 与推理系统架构师面试。
人机边界 (Human-AI Boundary)
推理网关根据租户 SLA 优先级、队列深度与缓存亲和自动路由降级;容量规划、多区域 GPU 配额上限及异常熔断策略由 SRE/Infra 工程师审定。
常见反模式与避坑 (Anti-Patterns)
- Co-locating 32k-token prefill bursts and latency-sensitive decode batches on the same replica without chunked-prefill or P/D isolation, causing severe ITL spikes
- Using blind round-robin load balancing across LLM replicas, thrashing Radix/Prefix KV caches down to <5% hit rate
延迟成本与评测门禁
TTFT <= 350ms (8k prompt on Prefill pool); Inter-Token Latency (TPOT) <= 25ms P99 on Decode pool · H100/B200 GPU-hours + InfiniBand/RoCEv2 KV transfer overhead (offset by 3x higher decode batch utilization)
- SLO-Compliant Goodput (Tokens/s/GPU meeting TTFT & TPOT): TTFT P99 < 400ms & TPOT P99 < 30ms at >= 75% GPU HBM KV utilization (Benchmark under mixed realistic length distributions (short chat + 32k RAG/coding bursts))
- Prefix Cache Hit Rate & KV Transfer Overhead: KV prefix hit >= 65% on agentic/system-prompt workloads; KV migration < 15% of TTFT (Measure RDMA/NIXL transfer latency across cross-node Decode handoffs)
💰 商业 ROI 模型与证据等级
verified_benchmarkP/D 分离消除长输入 Prefill 对生成流式卡顿的尾延迟冲击,在严格满足 TTFT/TPOT 双重 SLA 下将单百万 Token 推理 GPU 成本降低 30%–45%(Goodput 显著提升)。
🏗️ 端到端系统架构流水线
网关按最长公共前缀哈希(Consistent Hashing + Load Shedding)将请求优先路由到已热缓存相同 System/Repo 前缀的 Prefill 节点。
Prefill 节点算完首 Token 并立即通过 RDMA/NVLink 将 Paged KV Blocks 推送到目标 Decode 节点,Decode 池以大 Batch 稳定吐字。
⚖️ 工程选型与架构权衡矩阵
📊 同类技术选型与基准对比
- P/D Disaggregation vs Monolithic Continuous Batching (32k input / 512 output mix): cuts P99 TPOT jitter by ~3.2x at 2x concurrency.
🚨 生产失效模式与可观测特征
- Hot-prefix thundering herd overloading one Prefill replica if consistent hashing lacks bounded load shedding
- KV cache transfer backpressure stalling Prefill HBM reclamation when Decode pool saturates
🛡️ 合规边界与治理硬约束
- Strict tenant isolation on shared Radix/Paged KV memory blocks (zero cross-tenant KV cache reuse unless explicitly public system prefix)
- Cryptographic zeroing/invalidation of freed KV memory blocks in regulated multi-tenant clusters
🎤 面试高频追问与架构答辩题
- When does Prefill-Decode disaggregation actually perform WORSE than Chunked Prefill on the same node (hint: compute KV-transfer time vs prompt length over Ethernet vs InfiniBand)?
上下游关联知识链路
站内交互工具与信源依据
- DistServe — Disaggregating Prefill and Decoding for Goodput-Optimized LLM Serving (OSDI '24) (paper, 2026-11-30)
- vLLM PagedAttention & Disaggregated Prefill Architecture Docs (official_docs, 2026-11-30)