Skip to main content
WuKongIM supports dynamic scaling in Docker environments, allowing flexible adjustment of cluster size based on business requirements.

Single Node Mode Scaling

Description

The previously deployed single node mode now needs to be scaled to multiple servers. Here we use two servers as an example to explain how to scale. Assume there are two servers with the following information: node1 is the originally deployed single node, now we want to scale to two servers, node2 is the newly added node.
The following file contents are set with assumed server IPs, just replace the corresponding IPs with your own.

Deploy WuKongIM on node2

1. Create Installation Directory

Create directory:
Enter directory:

2. Create docker-compose.yml File in Installation Directory

Content as follows (note to replace corresponding IPs with your own):

Adjust node1’s Original docker-compose.yml Configuration

Add the following content under the wukongim1 service:

Deploy Load Balancer nginx

Add the following content to the docker-compose.yml file on node1:
Create nginx.conf file in node1’s installation directory with the following content:

Include New Node in Monitoring prometheus.yml

Modify the prometheus.yml file on node1, complete content as follows:

Start and Stop

Execute the following commands in each node’s installation directory:

Start

Stop

Port Configuration

External Network Ports

Internal Network Ports (nodes need to access each other)

Verification

Log into the management system, in node management you can see if the newly added node’s status is “Joined”. If so, scaling is successful.

Multi-Node Scaling Mode

Description

Nodes originally deployed using multi-node deployment can expand cluster size by adding nodes. This document describes how to expand cluster size by adding nodes. Assume the newly added node information is as follows:

Deploy WuKongIM on node4

1. Create Installation Directory

Create directory:
Enter directory:

2. Create docker-compose.yml File in Installation Directory

3. Configure Monitoring

In the original node1’s installation directory (~/wukongim), add the following content under scrape_configs in the prometheus.yml file:

4. Configure Load Balancer

In the gateway node’s installation directory (~/gateway), add the following content under all upstream sections in the nginx.conf file:

5. Restart Gateway

In the gateway node, enter the installation directory (~/gateway) and execute the following command:

6. Start node4

In node4, enter the installation directory (~/wukongim) and execute the following command:

Verification

Log into the management system, in node management you can see if the newly added node’s status is “Joined”. If so, scaling is successful.

Best Practices

Pre-scaling Checklist

  1. Resource Planning: Ensure new nodes have adequate CPU, memory, and storage
  2. Network Connectivity: Verify all nodes can communicate with each other
  3. Backup: Create backup of existing cluster before scaling
  4. Monitoring: Ensure monitoring is configured for new nodes

Post-scaling Verification

  1. Cluster Status: Check all nodes are in “Joined” state
  2. Load Distribution: Verify traffic is distributed across all nodes
  3. Performance: Monitor system performance after scaling
  4. Data Consistency: Verify data replication is working correctly

Troubleshooting

Common Issues

New node cannot join cluster:
Load balancer not distributing traffic:

Next Steps

Performance Monitoring

Set up comprehensive monitoring for scaled cluster

Cluster Configuration

Advanced cluster configuration options

Best Practices

Backup strategies and cluster best practices

Load Testing

Test cluster performance under load