Overview
Sockudo supports horizontal scaling across multiple nodes using Redis, Redis Cluster, or NATS as message brokers. Scale to handle 100K+ concurrent connections with proper load balancing.Architecture
Choosing an Adapter
Redis (Recommended)
Best for: Most production deployments, 2-10 nodes Pros:- Simple setup
- Proven reliability
- Built-in persistence
- Low latency (~1-2ms)
- Single point of failure (use Sentinel for HA)
- Limited to single master
Redis Cluster
Best for: Large deployments, 10+ nodes, 100K+ connections Pros:- Horizontal scaling
- Automatic sharding
- High availability
- No single point of failure
- More complex setup
- Higher operational overhead
NATS
Best for: Cloud-native deployments, Kubernetes, multi-region Pros:- Built for distributed systems
- Excellent multi-region support
- Low latency (<1ms)
- Native clustering
- No persistence by default
- Less common than Redis
Multi-Node Setup with Redis
Docker Compose Configuration
Load Balancing
Nginx Configuration
Createnginx/nginx-lb.conf:
HAProxy Configuration
Alternatively, use HAProxy:Sticky Sessions
Why Sticky Sessions?
WebSocket connections are stateful and must remain on the same node. Use one of these methods:IP Hash (Nginx)
Cookie-Based (HAProxy)
Source IP (HAProxy)
Redis Cluster Setup
Creating Redis Cluster
Initialize Cluster
Configure Sockudo
NATS Setup
NATS Cluster
Configure Sockudo
Cluster Health Monitoring
Sockudo includes built-in cluster health tracking:- Automatic node discovery
- Heartbeat monitoring
- Failed node detection
- Automatic cleanup of stale connections
Performance Tuning
Buffer Sizing
Redis Tuning
Database Pooling
Testing Multi-Node Setup
Use the provided test configuration:Scaling Commands
Next Steps
- Set up monitoring for multi-node clusters
- Review production requirements
- Configure Docker deployment options