system-type-real-time
System Type: Real-Time & Collaborative
Patterns, failure modes, and anti-patterns for systems with persistent connections and real-time state synchronization.
Connection Patterns
WebSocket
What it is. Full-duplex, persistent TCP connection upgraded from HTTP. Both sides can send frames at any time. When to use. Bidirectional communication with low latency — chat, collaborative editing, multiplayer games, live trading. When the server needs to push AND the client needs to push back frequently. When to avoid. Unidirectional server-to-client updates (SSE is simpler). Infrequent updates where polling is adequate. Environments where intermediaries (corporate proxies, older load balancers) silently kill long-lived connections. Key decisions. Binary vs text frames, subprotocol negotiation, per-message compression (permessage-deflate has CPU cost), ping/pong interval tuning.
Server-Sent Events (SSE)
What it is. Unidirectional server-to-client stream over a standard HTTP response. Built-in reconnection with Last-Event-ID. Works through HTTP/2 multiplexing natively.
When to use. Live dashboards, notification feeds, stock tickers — anything where the server pushes and the client only needs HTTP requests for writes. When you want automatic reconnection semantics for free.
When to avoid. Bidirectional real-time communication. Binary data. When you need more than ~6 concurrent connections per domain in HTTP/1.1 browsers (HTTP/2 eliminates this).