Realtime Transport: SSE vs WebSocket vs Long Poll
Select the right transport based on interaction model, reliability needs, and infra constraints.
Pattern level: macro
Select the right transport based on interaction model, reliability needs, and infra constraints.
Pattern level: macro
Choose WebSocket for frequent bidirectional interaction, SSE for simpler server-to-client streams, and long poll as compatibility fallback.
Transport choice is a product decision: latency profile, scale model, and developer ergonomics change together.
Start with required interaction directionality and update frequency, then evaluate reconnect/replay needs.
| Category | Level | Requirement | Done When |
|---|---|---|---|
| functional | unit | Incoming events respect sequence and dedupe semantics. | Out-of-order, duplicate, and missing event tests are all covered. |
| functional | integration | Reconnect path correctly hydrates snapshot and applies deltas. | Reconnect test proves no duplicate rows or missing updates. |
| a11y | integration | Live updates are announced without overwhelming screen readers. | Announcement batching and wording pass manual SR checks. |
| a11y | e2e | Focus remains stable when real-time updates occur. | Keyboard-only user can continue primary task uninterrupted. |