Scaling Websockets to 1M+ Concurrent Connections
The Challenge: Breaking the 50k Barrier
When building our real-time synchronization engine, we initially hit severe memory bottlenecks at 50,000 active connections. The default Node.js event loop became sluggish, file descriptor limits triggered socket dropouts, and CPU usage climbed to 100%. To scale to enterprise volume, we had to re-engineer every tier of the networking pipeline.
Linux Kernel Tuning & File Descriptors
A socket in Unix is fundamentally a file descriptor. We raised the system-wide limits via /etc/security/limits.conf, set fs.file-max to 2,097,152, and tuned the TCP keepalive parameters. Modifying net.ipv4.tcp_tw_reuse and adjusting the ephemeral port range ensured rapid socket recycling without connection leakage.
Distributed Redis Pub/Sub Cluster
Scaling horizontally required decoupling socket connections from application logic. By attaching Socket.io to a clustered Redis Pub/Sub stream, messages published on any regional ingress node propagated instantaneously to all target sockets. For teams designing distributed systems, our DevOps and Cloud Architecture Services help automate these multi-node setups.
Production Results
Under simulated load testing with distributed artillery instances, our cluster maintained 1,200,000 active WebSocket connections with a median delivery latency under 45ms and zero dropped frames.
Relevant Engineering Expertise
Need help implementing these architectures in your own infrastructure? Check out our specialized services.
DevOps and Cloud Architecture Services→