← Back to System Design Mind Map
🏗️ System DesignID: sse-streaming-backpressure

SSE Streaming & Backpressure Control

SSE 长连接流式传输与背压控制
🎯Core Definition
Server-Sent Events (SSE) Streaming & Reactive Backpressure Architecture is the standard high-performance protocol transmitting token-by-token LLM auto-regressive completions to client browsers over persistent unidirectional streams; leveraging native HTTP/1.1 or HTTP/2 (`Content-Type: text/event-stream`), SSE is significantly more lightweight than WebSocket and features built-in browser reconnection using `Last-Event-ID`; under massive concurrency, API gateways enforce Reactive Backpressure control: if a client's network buffer saturates, the gateway signals upstream vLLM/TGI inference engines to pause token generation, preventing buffer overflow and gateway OOM crashes.
💡Use Cases
Real-time typewriter chat interfaces (ChatGPT), streaming Agent internal thoughts/reasoning logs, and live code completion.
⚡Key Problems Solved
Blocking HTTP requests force users into 10-30 second blank-screen waits (ruining Time-To-First-Token, TTFT); SSE delivers first tokens within 200ms, while reactive backpressure protects gateway infrastructure from memory exhaustion under heavy load.
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of SSE Streaming & Backpressure Control.
Use Cases
In production engineering, what are the primary use cases for SSE Streaming & Backpressure Control and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
1
Compare SSE vs WebSocket across connection overhead, bidirectional capabilities, Nginx reverse proxy buffering, and reconnection primitives?
2
Explain why configuring `proxy_buffering off;` in Nginx reverse proxies is strictly mandatory to prevent token buffering in SSE streams?
3
How do async Python generators (AsyncGenerator) in vLLM apply backpressure to pause GPU token scheduling when clients lag?
4
Design Layer-7 load balancing (Envoy / HAProxy) for long-lived SSE connections to prevent connection skew and hot-spotting?
5
How to propagate client disconnect signals via HTTP cancellation tokens to immediately abort active GPU KV-Cache generation?
Updated 2026-08-14
🎯
Verify Mastery: Practice Exam Questions for "SSE Streaming & Backpressure Control"
Take pitfall multiple-choice questions with derivation options; mistakes are automatically logged.
🚀 Start Card Practice ➔
← Previous CardMulti-Tenant Partitioning & RBACNext Card →Context Budgeting & Token Management

🔗 More System Design Knowledge Cards

引用出处: TalentMe 450+ 工业级 AI 架构考点知识库 (Tech Vault) · 遵循 CC-BY-4.0 知识共享协议
URL: https://talentme.airsota.com/resources/tech/roadmap/mindmap/System_Design/card/sse-streaming-backpressure
中文速览与面试要点

SSE 长连接流式传输与背压控制 (SSE Streaming & Backpressure Control)

定义: SSE 长连接流式传输与背压控制架构 (Server-Sent Events Streaming & Reactive Backpressure Architecture) 是大模型在线对话服务中将模型逐 Token 自回归生成的离散 Token 实时、单向、低开销推送至客户端浏览器的核心网络传输标准;与双向繁重的 WebSocket 相比,SSE 基于原生标准 HTTP/1.1 或 HTTP/2 协议(`Content-Type: text/event-stream`),具备极其轻量、原生支持断线自动重连 (Reconnection with `Last-Event-ID`)、天然穿越公司防火墙与代理网关的巨大优势;在高并发场景下,网关与推理服务之间采用响应式背压流控机制 (Reactive Streams / Backpressure: 基于 TCP 滑动窗口与缓冲队列水位),当客户端消费过慢或发生网络拥塞时,主动向 LLM 推理引擎施加反压暂停下一 Token 生成,杜绝网关内存耗尽。 使用场景: ChatGPT 式实时打字机流式对话、智能 Agent 实时思考过程 (Thinking Process) 流式输出、实时代码生成。 解决的问题: 若采用传统单次 HTTP 请求同步等待,用户必须忍受长达 10~30 秒的完全白屏等待(首字延迟 TTFT 极高);SSE 流式传输让用户在 200ms 内看到首字吐出,极大提升交互体验,而背压机制保证了数十万并发长连接下网关内存的绝对安全。

核心要点

  • 详细对比 SSE (Server-Sent Events) 与 WebSocket 在连接开销、双向通信、代理网关缓冲 (Nginx Buffering) 与断线重连机制上的差异?
  • Nginx 代理层配置:为什么必须显式配置 `proxy_buffering off;` 和 `X-Accel-Buffering: no;` 才能防止网关缓冲大模型流式 Token?
  • 大模型推理服务(如 vLLM / TensorRT-LLM)中的 Token 生成器与异步协程背压:如何通过 AsyncGenerator 队列防止消费者过慢导致的显存/内存泄漏?
  • 长连接连接池管理与负载均衡:如何避免数万个长连接导致特定后端网关节点连接数倾斜 (Connection Skew)?
  • 客户端异常断线检测与推理中断 (Client Disconnect Abort):当用户主动点击“停止生成”或关闭网页时,如何跨服务通知 GPU 即刻终止该 Request 的 KV Cache 计算?