Inferensys

Glossary

Server-Sent Events (SSE)

A standard allowing servers to push real-time updates to clients over a single HTTP connection, often used to stream generated tokens one by one from a language model to a user interface.
MLOps engineer reviewing model serving infrastructure on laptop, container orchestration visible, technical workspace.
UNIDIRECTIONAL STREAMING PROTOCOL

What is Server-Sent Events (SSE)?

Server-Sent Events (SSE) is a standard HTTP-based protocol enabling servers to push real-time updates to clients over a single, long-lived TCP connection. Unlike WebSockets, SSE is strictly unidirectional, streaming text-based data from server to client, making it ideal for streaming generated tokens from a language model to a user interface.

Server-Sent Events (SSE) is a push technology where a client initiates a standard HTTP request and the server maintains an open connection to stream text/event-stream data. The protocol defines simple message fields—event, data, id, and retry—allowing the client to automatically reconnect and resume streams from the last received event ID, ensuring reliable delivery of incremental updates like LLM token generation.

SSE is natively supported in all modern browsers via the EventSource API, requiring no custom library. It leverages standard HTTP semantics, making it compatible with existing load balancers and proxies. For latency-optimized model serving, SSE provides a lightweight, firewall-friendly alternative to WebSockets when only server-to-client streaming is required, such as delivering generated text tokens one by one.

SERVER-SENT EVENTS

Key Features of SSE

Server-Sent Events provide a lightweight, unidirectional channel for servers to push real-time data streams to clients over a standard HTTP connection. Below are the defining characteristics that make SSE the protocol of choice for streaming LLM tokens and live updates.

01

Unidirectional Data Flow

SSE establishes a one-way communication channel from server to client. Once the client initiates the connection via the EventSource API, the server can push data at will, but the client communicates back only through separate HTTP requests. This asymmetry is ideal for token streaming from LLMs, where the model generates output sequentially and the client only needs to display results. Unlike WebSockets, there is no overhead for maintaining a bidirectional protocol when only server-to-client updates are needed.

02

Native Browser Support

SSE is built directly into modern browsers through the EventSource API, requiring no external libraries or custom handshake logic. The browser automatically handles:

  • Connection establishment via standard HTTP
  • Automatic reconnection with exponential backoff on connection loss
  • Event parsing and dispatching to JavaScript handlers
  • Tracking the last received event ID via the Last-Event-ID header

This native integration simplifies client-side code dramatically compared to WebSocket implementations, which require manual reconnection logic and frame parsing.

03

Automatic Reconnection

A critical feature for production resilience: SSE clients automatically attempt to reconnect when the connection drops. The EventSource API implements an exponential backoff strategy out of the box. The server can also include an id field on each event, allowing the client to send the Last-Event-ID HTTP header upon reconnection. This enables the server to resume the stream from the exact point of interruption, preventing duplicate or missed tokens during LLM generation—a capability essential for maintaining coherent output in long-running inference sessions.

04

Text-Based Protocol with Event Typing

SSE transmits data as UTF-8 encoded text using a simple field-based format. Each message can include:

  • event: A named event type for dispatching to specific handlers
  • data: The payload, which can span multiple lines
  • id: A unique identifier for resumption tracking
  • retry: A server-specified reconnection interval in milliseconds

This structure allows a single SSE stream to carry multiple logical event types—for example, streaming token events alongside metadata and error events—without multiplexing overhead. The Content-Type: text/event-stream header signals the protocol to intermediaries.

05

HTTP/2 Multiplexing Efficiency

When served over HTTP/2, SSE connections benefit from multiplexed streams within a single TCP connection. This eliminates the browser's per-domain connection limit problem that plagued HTTP/1.1 SSE implementations, where only 6 concurrent connections were allowed. With HTTP/2, a client can maintain multiple SSE streams to different endpoints simultaneously without head-of-line blocking. The server can also leverage HPACK header compression to reduce the overhead of repeated response headers across long-lived connections.

06

Proxy and Firewall Compatibility

Because SSE operates over standard HTTP on port 80 or 443, it traverses corporate firewalls, load balancers, and reverse proxies without special configuration. Unlike WebSockets, which require an HTTP Upgrade handshake that some intermediaries may block or mishandle, SSE looks like a regular long-lived HTTP response. This makes SSE the preferred choice for enterprise deployments where network infrastructure cannot be modified. Standard HTTP caching rules apply, and intermediaries can buffer or transform the stream as needed.

STREAMING PROTOCOL COMPARISON

SSE vs. WebSocket vs. gRPC Streaming

Technical comparison of the three primary protocols for server-to-client streaming in real-time inference and model serving architectures.

FeatureServer-Sent Events (SSE)WebSocketgRPC Streaming

Transport Protocol

HTTP/1.1 or HTTP/2

Upgraded HTTP/1.1 (ws://)

HTTP/2 (multiplexed)

Communication Direction

Unidirectional (server → client)

Bidirectional (full-duplex)

Bidirectional or unidirectional

Data Format

UTF-8 text (event stream)

Text or binary frames

Protocol Buffers (binary)

Browser Native Support

Automatic Reconnection

Built-in Flow Control

Multiplexed Streams per Connection

Typical Inference Use Case

Streaming LLM token generation to UI

Real-time chat and collaborative editing

High-throughput model serving with typed contracts

TECHNICAL DEEP DIVE

Frequently Asked Questions

Precise answers to the most common engineering questions about Server-Sent Events, covering protocol mechanics, connection management, and production deployment patterns.

Server-Sent Events (SSE) is a W3C standard that enables a server to push real-time updates to a client over a single, long-lived HTTP connection using a unidirectional text-based stream. The client initiates the connection by sending a standard HTTP GET request with the Accept: text/event-stream header. The server responds with a Content-Type: text/event-stream header and maintains the connection indefinitely, streaming data in a simple data: field format. Each message is delimited by double newlines (\n\n), and the protocol natively supports automatic reconnection via the retry: field and event typing via the event: field. Unlike WebSockets, SSE operates over standard HTTP/1.1 and HTTP/2, inheriting all the benefits of HTTP infrastructure including authentication headers, proxies, and firewalls without requiring a protocol upgrade handshake. The EventSource API in browsers handles parsing, reconnection, and Last-Event-ID tracking automatically, making SSE significantly simpler to implement than WebSockets for server-to-client streaming use cases such as token-by-token LLM output streaming, live dashboards, and notification feeds.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.