Back to Blog
Engineering

Scaling WebSockets to 100K Concurrent Connections

The engineering challenges of maintaining persistent connections at scale — memory management, load balancing, and graceful failover.

I
Infrastructure Team · Engineering
September 22, 20259 min read
Scaling WebSockets to 100K Concurrent Connections

WebSockets are essential for real-time features but create unique scaling challenges. Unlike HTTP, each connection is persistent and stateful. At 100K concurrent connections, every inefficiency multiplies.

Challenges We Solved

  • Memory — Each connection consumes memory; we optimized per-connection overhead to under 4KB
  • Load balancing — Sticky sessions with graceful connection draining during deploys
  • Fan-out — Publishing to thousands of connections efficiently using Redis pub/sub
  • Reconnection — Clients reconnect with backoff and resume from last-seen event ID
  • Health checks — Heartbeat pings to detect and clean up zombie connections

Our WebSocket infrastructure now handles 100K concurrent connections per node with p99 message delivery latency under 50 milliseconds.