Command Palette

Search for a command to run...

PHASE 6Beginner ~6 min· topic 9 of 10

Topic 6.9

SSE (Server-Sent Events)

In one line

One-way server→client push over a single long-lived HTTP connection — the cheap realtime win.

0/10 · 0%

Think of it like this

A stock ticker screen at a trading office. It only pushes updates one-way (numbers scrolling by) — you never talk back to the screen. That's simpler and cheaper than a two-way phone call (WebSocket) when you only need updates flowing one direction.

Key ideas

  1. 01

    EventSource API; server sends text/event-stream lines indefinitely.

  2. 02

    One-directional (server → client) — built-in auto-reconnect with last-event-id resume.

  3. 03

    Cost: far cheaper than WebSockets (no special LB stickiness beyond persistence, plain HTTP)

  4. 04

    Perfect for: notifications, stock ticks, feed updates, progress bars.

  5. 05

    Not for: client→server messages (use normal POST) or bidi (use WebSocket).

  6. 06

    Interview: 'for one-way push choose SSE over WebSocket' — a sentence that separates people.

Java / Spring map

  • →

    Spring: SseEmitter (MVC) or WebFlux ServerSentEvent + Flux.

Explain without notes

01

Give one product WHERE SSE wins over WebSocket and one where it fails.

Practice

01

Design a notification stream: SSE endpoint, reconnect with last-event-id, and event shaping.

Trade-offs

  • ↔

    Single connection per client means the server must fan messages to many live connections — same memory math as WebSocket.

Completion checklist

  • I know exactly when SSE is the right tool over WebSocket.

Back to phase