Networking & Protocols
WebSocket: multiple-choice review
Six questions that cut across the whole unit. None is a definition to recite — each mirrors a decision a senior engineer makes while a real-time service is degrading under load.
Confirm you can connect the upgrade, the frame format, transport choice, backpressure, reconnection, and scaling ceilings into one coherent operational model — the synthesis the individual lessons built toward.
A teammate proposes opening a raw TCP socket on a custom port to skip the HTTP upgrade and 'save a round-trip'. Why is this the wrong reasoning?
A custom WebSocket client (outside a browser) sends server-to-client-style unmasked frames to your server. Should the server accept them, and why does masking exist at all?
A dashboard pushes ~5 updates per minute to 100k users who never send data back. An engineer reaches for WebSocket. What is the better default and why?
A broadcast server's memory climbs steadily under load until the OOM killer fires; 100 of 10,000 clients are on slow mobile links. What is the mechanism, and what is the first durable fix?
You deploy a new build; all 10 million connected clients drop with code 1006 and reconnect. Your client uses exponential backoff but no jitter. Why does the server still struggle to recover?
Two WebSocket servers sit behind a load balancer. User A on Server 1 sends a chat message that must reach User B on Server 2. Sticky sessions are enabled. Why is sticky routing alone insufficient, and what closes the gap?
The unit’s through-line is one operational model: the upgrade reuses the existing connection so shared infrastructure still routes it; framing and mandatory client masking defend the wire; transport choice (WebSocket vs SSE vs long-polling) follows the direction of data flow; backpressure is the canonical failure mode, answered by a high-water mark; reconnection must be jittered or it becomes a thundering herd; and horizontal scale needs pub/sub for fan-out plus sticky sessions for per-connection state. Every production incident in this unit resolves back to those levers.