How to Scale a RocketMQ Cluster: Adding Brokers and NameServers
This guide explains the two main steps for expanding a RocketMQ cluster—scaling brokers and scaling name servers—detailing when to add resources, configuration changes, and command examples for a smooth horizontal expansion.
RocketMQ is a core component in large‑scale architectures, and expanding its cluster involves two distinct parts: broker scaling and NameServer scaling.
NameServer Scaling
Scale NameServers when the routing request QPS is high or the number of brokers, producers, or consumers grows significantly. Since NameServers are stateless, you can simply add new instances and update client configurations to point to the additional servers.
# Example configuration for adding a new broker
brokerClusterName=your-cluster-name # must match existing cluster
brokerName=broker-c # unique name for new broker
brokerId=0 # 0 for master, >0 for slave
namesrvAddr=ns1:9876;ns2:9876 # existing NameServer addresses
autoCreateTopicEnable=false # disable auto‑create in production
listenPort=10911 # default portBroker Scaling
Broker scaling typically means adding a new master (or a master‑slave pair) to increase write/read capacity. The basic workflow is:
Add a new machine.
Copy or create a new broker.conf file.
Update the configuration: change brokerName, brokerId, ports, and storage paths.
Start the new broker.
nohup sh bin/mqbroker -c conf/broker.conf -n "NameServerAddress:Port" &After launching, the new broker joins the cluster and participates in message handling.
Key Considerations
Ensure the new broker’s name and ID are unique within the cluster.
Adjust client configuration to include all NameServer addresses for reliable discovery.
Disable automatic topic creation in production to avoid unintended topics.
Following these steps allows seamless horizontal expansion of a RocketMQ cluster, improving throughput and reliability.
Mike Chen's Internet Architecture
Over ten years of BAT architecture experience, shared generously!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
