Performance & Capacity Practical By Samson Tanimawo, PhD Published Aug 28, 2025 4 min read

WebSocket Performance

Long-lived connections.

WebSocket performance characteristics

Long-lived connections. Per-connection memory and file descriptor cost; scales with concurrent users.

Bi-directional. Server can push without polling. Fewer round trips than HTTP polling for live updates.

Stateful. Connection state lives at one server; load balancing is sticky or requires shared state.

Scaling considerations

Connections per server: tens of thousands typical, hundreds of thousands with tuning.

File descriptor limits: ulimit -n must be high. Default 1024 is far too low.

Memory per connection: kilobytes typical. Connection count drives total memory.

Operating WebSocket services

Sticky load balancing required. Connection state lives at one server; routing must be consistent.

Graceful drain on deploy. Open connections must close cleanly; clients reconnect.

Per-connection metrics: connection count, message rate, latency. Aggregate hides per-connection issues.

When not WebSocket

Server-sent events (SSE) for one-directional push. Simpler; HTTP-based.

HTTP/2 streams for request-response patterns with push. Standard infrastructure handles it.

Long polling for low-frequency updates. Simpler than WebSocket; works through restrictive proxies.