Cluster Features
Advantages:- High availability and strong disaster recovery capability
- Supports online scaling
- Real-time automatic backup between multiple replicas
- Load balancing
- Slightly complex deployment
- Requires multiple machines
Cluster Principle: WuKongIM follows the
2n+1 principle, where n represents the number of nodes allowed to fail.- Allow 1 machine to fail: requires 3 machines (2×1+1=3)
- Allow 2 machines to fail: requires 5 machines (2×2+1=5)
Environment Requirements
- Number of machines: 4 or more
- Operating System: Linux (Ubuntu recommended)
- Configuration: 2 cores 4GB or 4 cores 8GB
- Docker: Version 24.0.4 or above
| Role | Description | Internal IP | External IP |
|---|---|---|---|
| Load balancer and monitoring | gateway | 10.206.0.2 | 119.45.33.109 |
| WuKongIM node | node1 (ID: 1) | 10.206.0.10 | 146.56.249.208 |
| WuKongIM node | node2 (ID: 2) | 10.206.0.12 | 129.211.171.99 |
| WuKongIM node | node3 (ID: 3) | 10.206.0.5 | 119.45.175.82 |
Deployment Steps
1. Install Load Balancer and Monitoring
Create installation directory on thegateway node:
docker-compose.yml file:
nginx.conf file (replace IP addresses with actual addresses):
prometheus.yml file (replace IP addresses with actual addresses):
2. Install WuKongIM Nodes
Create installation directory on all WuKongIM nodes:3. Start Services
Startup Order:- First start load balancer and monitoring:
- Then start all WuKongIM nodes:
4. Verify Deployment
Check service status:- Demo Interface: http://119.45.33.109:15172
- Management Interface: http://119.45.33.109:15300
- Monitoring Interface: http://119.45.33.109:9090
- API Address: http://119.45.33.109:15001
Configuration Description
Key Environment Variables
| Variable Name | Description | Example Value |
|---|---|---|
WK_CLUSTER_NODEID | Node ID | 1, 2, 3 |
WK_CLUSTER_APIURL | Node API address | http://10.206.0.10:5001 |
WK_CLUSTER_SERVERADDR | Node communication address | 10.206.0.10:11110 |
WK_CLUSTER_INITNODES | Initial node list | 1@10.206.0.10 2@10.206.0.12 3@10.206.0.5 |
WK_EXTERNAL_WSADDR | External WebSocket address | ws://119.45.33.109:15200 |
WK_EXTERNAL_TCPADDR | External TCP address | 119.45.33.109:15100 |
Port Description
| Port | Description | Access Method |
|---|---|---|
| 5001 | HTTP API | Internal access |
| 5100 | TCP connection | Client connection |
| 5200 | WebSocket | Client connection |
| 5300 | Management interface | Web access |
| 5172 | Demo interface | Web access |
| 11110 | Cluster communication | Inter-node communication |
| 15001 | Load balanced API | External access |
| 15100 | Load balanced TCP | External access |
| 15200 | Load balanced WebSocket | External access |
| 15300 | Load balanced management | External access |
| 15172 | Load balanced Demo | External access |
Troubleshooting
Common Issues
Node cannot join cluster:Log Viewing
Scaling Operations
Adding new nodes to existing cluster:- Create configuration file on new node
- Set new node ID
- Update
WK_CLUSTER_INITNODESto include new node - Start new node service
- Update load balancer configuration

