← System Design
Server-Sent Events (SSE)
Async CommunicationA one-way, server-to-client stream over plain HTTP with built-in auto-reconnect — simpler than WebSockets when the client never needs to push back over the same channel.
Server-Sent Events let a server keep a single HTTP response open and stream a sequence of text-formatted events down it over time, which the browser's built-in `EventSource` API parses and delivers as discrete messages. Unlike WebSockets, SSE is one-way (server → client only) and rides on plain HTTP/1.1 or HTTP/2, so it works with ordinary HTTP infrastructure (no special upgrade handshake) and gets automatic reconnection with last-event-id resumption built into the browser API for free.
How it connects
Server-Sent Events (SSE) as the source, with the components it typically interacts with.
- → Load Balancer: Streaming SSE responses need LB/proxy timeouts and buffering settings tuned for long-lived, low-throughput connections rather than typical short HTTP requests.
- → WebSockets: WebSockets are the natural upgrade path when a use case that started as one-way server push later needs true bidirectional messaging.
- → Long Polling: SSE and long polling solve the same one-way-push problem; SSE is preferred when streaming HTTP responses are supported, long polling when they aren't.