Skip to content
StackDecode
System Design
10. API Design and ManagementAnimated

Server-Sent Events

One-way event stream over HTTP.

The idea

The server pushes events over an open response; browsers reconnect automatically.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

BrowserServerGET /events (Accept: text/event-stream)
  • current message
  • earlier
  • failure or attack

The browser opens one long-lived HTTP request.

step:
1/5
from:
Browser
to:
Server
1/5

Time runs downward. Solid arrows are requests, dashed arrows are replies.

Step by step

  1. 1Client opens the stream
  2. 2Server sends events
  3. 3The client handles them
  4. 4It reconnects on a drop

Where it is used

Live updates and token streaming.

Watch out for

Proxies may buffer.

Related