WebSocket Telemetry at Scale: Real-Time Streaming Architectures
A single WebSocket server streaming telemetry to a few clients is a weekend project. Streaming live data to thousands of clients across multiple server instances is an architecture problem. The naive design — one process holding every connection in memory — falls over the moment you scale horizontally, because instance A cannot broadcast to a client connected to instance B.
The horizontal-scaling problem
Once you run more than one server process behind a load balancer, connections fan out across instances. An event that originates on one instance has to reach subscribers on all of them. In-memory broadcast only reaches the local process; you need a shared backplane so every instance hears every event.
// Redis pub/sub backplane → broadcast across every instance
import { createAdapter } from "@socket.io/redis-adapter";
io.adapter(createAdapter(pubClient, subClient));
// emit anywhere; every instance's subscribers receive it
metrics.on("tick", (m) => io.to("telemetry").emit("metric", m));Rooms, not broadcasts
Do not push every metric to every client. Scope subscriptions into rooms — per dashboard, per device, per tenant — so a client receives only the streams it is watching. This collapses bandwidth and CPU from O(clients × events) toward O(interested clients), which is the difference between a system that scales and one that melts at a few thousand connections.
Coalesce at the source
High-frequency sources emit faster than any client can render or any socket should carry. Sample or debounce on the server to a sane frame rate before broadcasting, so you push the latest truth at a rate the wire and the React reconciler can actually absorb. Backpressure handled at the source beats backpressure discovered at the client.
Scaling real-time is not about a faster socket. It is about making sure each event travels exactly as far as it needs to — and no further.
For the single-server fundamentals and the React consumption side, see Real-Time Telemetry; the live systems are streamerOS and the CMZ portal.