FastAPI Textbook Ch. 8 — WebSockets, SSE, and Streaming Responses
Real-time FastAPI: WebSockets, broadcast / pub-sub, SSE for one-way streams, StreamingResponse, NDJSON, and disconnect handling.
Real-time FastAPI: WebSockets, broadcast / pub-sub, SSE for one-way streams, StreamingResponse, NDJSON, and disconnect handling.
Cheatsheet: streaming SSR, Suspense, loading.tsx, parallel data fetching.
Practical streaming protocol selection: SSE for one-way, WebSocket for bidi, gRPC for typed RPC, NDJSON for JSON streams. Comparison and production patterns.
Practical gRPC streaming in Go: server streaming for fanout, client streaming for uploads, bidi for chat, cancellation via context, and avoiding goroutine leaks.
Practical FastAPI streaming: SSE for one-way real-time, NDJSON for streamed JSON, LLM token streaming, backpressure handling, and reconnect patterns.
Production LLM streaming with cancellation. SSE plus abort, client cancel propagating to provider, partial-response handling, and the patterns that save real tokens.
How to use gRPC’s three streaming modes correctly. Server-streaming, client-streaming, bidirectional, deadlines, errors, flow control, and concrete patterns for live updates and uploads.
How CDC actually works in 2026. Postgres logical replication slots, pgoutput, Debezium, the outbox pattern, and how to fan out changes to Kafka, NATS, ClickHouse, OpenSearch, or your AI pipeline.
A complete system design for a YouTube-style platform. Upload, transcoding to HLS/DASH variants, storage at petabyte scale, CDN delivery, adaptive bitrate, recommendations, and the operational realities.
A practical comparison of Server-Sent Events and WebSockets in 2026. The protocol differences, AI token streaming, chat with cancellation, code in FastAPI, Hono, and Axum, scaling and CDN/proxy behavior, and a clear decision rule.