Skip to main content

Documentation Index

Fetch the complete documentation index at: https://wukong.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

WuKongIM supports dynamic scaling in Kubernetes environments, allowing flexible adjustment of cluster size based on business requirements.

Description

Applicable scenarios: Applications with high data security requirements, large applications. Advantages: High availability, strong disaster recovery, supports online scaling, real-time automatic backup between multiple replicas, load balancing, no manual configuration required, fast scaling.
Note: WuKongIM currently supports hot scaling but does not support hot shrinking! Does not support hot shrinking! Does not support hot shrinking!

Scaling Operations

Scale Up Cluster

# Scale to 3 replicas
helm upgrade wkim wukongim/wukongim \
  -n wukongim \
  --create-namespace \
  --version 0.1.0 \
  --set replicaCount=3
Optional parameters:
  • replicaCount=3: Number of replicas (default is 2)
  • externalIP=<IP_ADDRESS>: External IP address

Scale to Different Sizes

# Scale to 5 replicas for high load
helm upgrade wkim wukongim/wukongim \
  -n wukongim \
  --version 0.1.0 \
  --set replicaCount=5

# Scale to 7 replicas for very high load
helm upgrade wkim wukongim/wukongim \
  -n wukongim \
  --version 0.1.0 \
  --set replicaCount=7

Verify Scaling

# Check Pod status
kubectl get pods -n wukongim

# Check cluster nodes
kubectl port-forward svc/wkim-wukongim 5001:5001 -n wukongim &
curl http://localhost:5001/cluster/nodes

# View detailed cluster information
curl http://localhost:5001/cluster/nodes | jq '.'

Scaling Best Practices

Pre-Scaling Checklist

  1. Resource Planning: Ensure Kubernetes cluster has sufficient resources
  2. Monitoring: Check current resource usage and performance metrics
  3. Backup: Create backup before scaling operations
  4. Load Testing: Verify current performance baseline
For Growing Load:
# Start with 3 replicas (minimum for HA)
helm upgrade wkim wukongim/wukongim -n wukongim --set replicaCount=3

# Scale to 5 for moderate load increase
helm upgrade wkim wukongim/wukongim -n wukongim --set replicaCount=5

# Scale to 7 for high load
helm upgrade wkim wukongim/wukongim -n wukongim --set replicaCount=7
Resource Allocation per Replica:
# Scale with resource adjustments
helm upgrade wkim wukongim/wukongim \
  -n wukongim \
  --set replicaCount=5 \
  --set resources.requests.memory=4Gi \
  --set resources.requests.cpu=2000m \
  --set resources.limits.memory=8Gi \
  --set resources.limits.cpu=4000m

Post-Scaling Verification

# Check all pods are running
kubectl get pods -n wukongim -o wide

# Verify cluster health
kubectl exec -n wukongim deployment/wkim-wukongim -- \
  curl -f http://localhost:5001/health

# Check cluster status
kubectl port-forward svc/wkim-wukongim 5001:5001 -n wukongim &
curl http://localhost:5001/cluster/nodes

# Monitor resource usage
kubectl top pods -n wukongim
kubectl top nodes

Monitoring During Scaling

Watch Scaling Progress

# Watch pods being created
kubectl get pods -n wukongim -w

# Monitor events
kubectl get events -n wukongim --sort-by='.lastTimestamp'

# Check deployment status
kubectl rollout status deployment/wkim-wukongim -n wukongim

Performance Monitoring

# Check resource usage
kubectl top pods -n wukongim

# View logs during scaling
kubectl logs -f deployment/wkim-wukongim -n wukongim

# Monitor cluster metrics
kubectl port-forward svc/wkim-wukongim 5300:5300 -n wukongim &
curl http://localhost:5300/metrics

Troubleshooting Scaling Issues

Common Scaling Problems

Insufficient Resources:
# Check node resources
kubectl describe nodes

# Check resource requests vs limits
kubectl describe deployment wkim-wukongim -n wukongim

# View pod events
kubectl describe pods -n wukongim
Pod Startup Issues:
# Check pod status
kubectl get pods -n wukongim

# View pod logs
kubectl logs <pod-name> -n wukongim

# Check pod events
kubectl describe pod <pod-name> -n wukongim
Cluster Communication Issues:
# Test inter-pod communication
kubectl exec -it <pod-name> -n wukongim -- ping <other-pod-ip>

# Check cluster ports
kubectl exec -it <pod-name> -n wukongim -- netstat -tulpn | grep 11110

# View cluster logs
kubectl logs <pod-name> -n wukongim | grep cluster

Recovery Procedures

# Rollback to previous replica count if issues occur
helm rollback wkim -n wukongim

# Force restart problematic pods
kubectl delete pod <pod-name> -n wukongim

# Check and fix resource constraints
kubectl patch deployment wkim-wukongim -n wukongim -p '{"spec":{"template":{"spec":{"containers":[{"name":"wukongim","resources":{"requests":{"memory":"4Gi","cpu":"2000m"}}}]}}}}'

Automated Scaling

Horizontal Pod Autoscaler (HPA)

# hpa.yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: wkim-hpa
  namespace: wukongim
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: wkim-wukongim
  minReplicas: 3
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 70
  - type: Resource
    resource:
      name: memory
      target:
        type: Utilization
        averageUtilization: 80
Apply HPA:
kubectl apply -f hpa.yaml
kubectl get hpa -n wukongim

Vertical Pod Autoscaler (VPA)

# vpa.yaml
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: wkim-vpa
  namespace: wukongim
spec:
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: wkim-wukongim
  updatePolicy:
    updateMode: "Auto"
  resourcePolicy:
    containerPolicies:
    - containerName: wukongim
      maxAllowed:
        cpu: 4
        memory: 8Gi
      minAllowed:
        cpu: 500m
        memory: 1Gi

Performance Considerations

Optimal Replica Counts

Load LevelRecommended ReplicasUse Case
Light3Development, small teams
Medium5Growing applications
High7Large applications
Very High9+Enterprise scale

Resource Planning

# Calculate total resources needed
# For 5 replicas with 4Gi memory each = 20Gi total memory required
# For 5 replicas with 2 CPU each = 10 CPU cores total required

helm upgrade wkim wukongim/wukongim \
  -n wukongim \
  --set replicaCount=5 \
  --set resources.requests.memory=4Gi \
  --set resources.requests.cpu=2000m

Next Steps

Multi-Node Deployment

Learn about multi-node cluster deployment

Upgrade Guide

Upgrade WuKongIM in Kubernetes

Monitoring Setup

Set up monitoring for scaled cluster

Performance Tuning

Optimize performance for scaled deployment