WebSocket vs Polling

Polling looks simple until twelve metric layers across 150 servers make the request-per-second math break down.

When we designed the CCS agent, the first question was obvious: how does a server send data to the dashboard? The instinctive answer is HTTP polling. We chose a different model.

HTTP POLLING: about 180 req/s for 150 servers, 12 layers and a 10-second interval.

WEBSOCKET: 150 persistent, bidirectional connections.

The math

requests_per_second = 150 hosts × 12 layers / 10s
                    = 180 req/s

At one-second intervals that becomes 1,800 requests per second. At 100 ms, it becomes 18,000. The cost grows with fleet size instead of the amount of useful information exchanged.

Why WebSocket

WebSocket pays connection setup once per server, then provides full-duplex streaming over one persistent TCP connection. It lowers event latency, enables reverse actions without another endpoint and compresses structured payloads efficiently.

The CCS client uses binary WebSocket, CBOR framing and mTLS authentication, with exponential reconnect, heartbeat and a local offline buffer.

From the inside out

The client installed on the host initiates the connection to the external CCS sys. The host does not expose an administration port, accept control-plane SSH or circulate a remote-access credential. Telemetry and actions share the authenticated channel.

This also isolates failures: a host under CPU, memory or Docker pressure does not share resources with the control plane.

Trade-offs

Persistent connections require capacity planning, proxies can silently time them out, and debugging is harder than using curl. Heartbeats, reconnect logic and dedicated inspection tools are not optional.

What remained

Polling is defensible for small systems that tolerate minutes of latency. WebSocket becomes worthwhile when events must arrive in seconds, actions must travel back without inbound endpoints and hundreds of hosts must remain connected without multiplying HTTP ceremony.

What the CCS dashboard shows exists because an agent just sent it, not because a cron job may check again in five minutes.


— Henrique Salles · Engineering · Platform · CCS