Server-Sent Events (SSE) — concept page. One-way server -> client streaming over plain HTTP using text/event-stream format. EventSource browser API with built-in auto-reconnect and Last-Event-ID resume. Three scenarios: (1) basic SSE setup and steady event delivery from a Redis Stream, (2) connection drop with auto-reconnect and Last-Event-ID replay of missed events, (3) LLM token streaming OpenAI/Anthropic-style with data: [DONE] terminator. Three ADRs covering SSE vs WebSocket vs long-poll choice, Redis Stream resume buffer strategy, and disabling proxy buffering plus compression on SSE endpoints.
Server-Sent Events is a browser API and UTF-8 event-stream format over HTTP. It is server-to-client only. The user agent handles reconnection and Last-Event-ID, while authentication, authorization, durable replay, deduplication, backpressure, and retention remain application responsibilities.
Open and dispatch an event stream. EventSource fetches a 200 text/event-stream response and dispatches complete UTF-8 events separated by blank lines.
Reconnect with Last-Event-ID. The browser reconnects after a broken stream and reports its last event ID; the server chooses replay semantics.
Producer commit and subscriber delivery. Publishing and browser delivery are separate phases; an append can succeed while a subscriber is disconnected.
Slow clients, heartbeat comments, and deliberate stop. Streaming services need bounded buffers; HTTP 204 tells EventSource not to reconnect.
Введите числа или выберите пресет