Technical work, should be praised and then see, form a habitCopy the code

RocketMQ use tutorial related series of directories


1. Single Master mode

This is risky because if the Broker restarts or goes down, the entire service may become unavailable. This is not recommended for online environments, but can be used for local testing.

2. Multi-master mode

There are no slaves in a cluster but only masters, for example, two or three masters. The advantages and disadvantages of this mode are as follows:

  • Advantages: simple configuration, the maintenance of a single Master disk has no impact on applications. When the RAID10 disk is configured as RAID10, the RAID10 disk is highly reliable and does not lose messages even when the machine is down and cannot be recovered. (a small number of messages are lost when the asynchronous disk is flushed, but none is lost when the synchronous disk is flushed.)
  • Disadvantages: During a single machine outage, unconsumed messages on the machine cannot be subscribed until the machine is restored, affecting the real-time performance of messages.

3. Primary/secondary (asynchronous and synchronous double-write) :

  • Advantages: Synchronous double-write messages are not lost (messages are written to the master and slave), asynchronous replication has a small amount of data loss (data is written to the master and the master copies data to the slave), the master node breaks down, and the slave node can consume messages but does not support writing
  • Disadvantages: The master has a short message delay, millisecond level, currently does not support automatic switching, requires a script or other program to detect and then stop the broker, restart the slave node to become the master node

 

4. Multi-master multi-Slave mode (asynchronous)

Each Master is configured with a Slave, and there are multiple pairs of master-slaves. HA adopts asynchronous replication, and the Master has a short message delay (in milliseconds). Advantages and disadvantages of this mode are as follows:

  • Advantages: Even if the disk is damaged, the message loss is very small, and the real-time performance of the message is not affected. In addition, when the Master is down, consumers can still consume from the Slave. This process is transparent to the application, without manual intervention, and the performance is almost the same as that of the multi-master mode.
  • Disadvantages: Master down, loss of small messages in case of disk corruption.

 

5. Multi-master multi-Slave mode (synchronization)

Each Master is configured with a Slave. There are multiple master-slave pairs. HA adopts the synchronous dual-write mode.

  • Advantages: No single point of failure for data and services, no delay for messages in the case of Master outage, high service availability and data availability;
  • Disadvantages: Lower performance than asynchronous replication (about 10% lower), higher RT for sending a single message, and the standby node cannot automatically switch to the host when the active node is down.

 

recommendation

3, 4 and 5 are recommended. There is no best plan, only suitable plan is good.