Scaling WebSocket Connections to 1 Million Users
Infrastructure architecture for scaling WebSocket servers to handle 1M+ concurrent connections with sub-100ms latency.
Scaling WebSocket Connections to 1 Million Users
The Challenge
A single server can handle ~50K WebSocket connections (limited by file descriptors and memory). To reach 1M, you need horizontal scaling with intelligent routing.
Architecture
Layer 1: Load Balancer (HAProxy/NGINX)
- Use Layer 4 (TCP) load balancing for WebSocket
- Sticky sessions via IP hash or cookie
- Health checks on WebSocket ping/pong
Layer 2: WebSocket Servers (Stateless)
- Each server handles 30-50K conne