C.W.K.
Stream
Lesson 06 of 08 · published

The Decision Matrix

~12 min · foundations, tradeoffs

Level 0Poller
0 XP0/60 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

Pick the lightest tool that meets latency

The four real-time approaches are not a hierarchy. They are a decision matrix. The right answer depends on three questions: direction (one-way or bidirectional?), frequency (once a minute or ten times a second?), and tolerable latency (a 30-second delay is fine, or sub-100ms required?).

The flowchart

If you only need fresh data every minute, polling is fine. If only the server pushes, SSE is the lightest right answer. If both sides push frequently and latency matters, WebSocket. If neither side pushes much and the data fits a request-response shape, do not use real-time at all.

Hybrid is normal

Most production systems mix shapes. cwkPippa: REST for CRUD on conversations, SSE for streaming AI tokens, polling for fleet heartbeats. ChatGPT: HTTP POST for user input, SSE for streaming reply. Slack: WebSocket for chat + SSE for some notifications + REST for everything CRUD. Real-time is not one tool.

Code

Decision flowchart·text
  Do you need real-time updates at all?
  |-- No  -> Use plain HTTP/REST.
  |-- Yes
      |-- Server -> Client only?
      |   |-- Yes -> SSE (Server-Sent Events).
      |   |-- No (bidirectional)
      |       |-- Frequency low + latency tolerant -> long polling can suffice.
      |       |-- Frequency high or latency tight  -> WebSocket.
      |-- Need binary frames?
          |-- Yes -> WebSocket (SSE is text-only).
The matrix at a glance·text
| Approach     | Direction        | Latency      | Complexity | Best for                           |
| ------------ | ---------------- | ------------ | ---------- | ---------------------------------- |
| Polling      | client-driven    | interval     | very low   | dashboards refreshing every 30s+   |
| Long Polling | server -> client | low-medium   | medium     | legacy, when SSE/WS blocked        |
| SSE          | server -> client | low          | low        | AI streaming, notifications, feeds |
| WebSocket    | bidirectional    | very low     | higher     | chat, collab, gaming, trading      |

External links

Exercise

For each of these features, write down the right approach (polling / long-polling / SSE / WebSocket) AND why: (a) GitHub Actions build status badge, (b) live cursor positions in Figma, (c) notification badge count for unread emails, (d) Discord chat, (e) ChatGPT streaming reply, (f) live stock ticker on a public homepage. There is one defensible answer per row.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.