Original source of this answer: Horizontal scaling for brokers . I just added plugin support.
To configure the n node cluster, you can use two functions of the combined mosquito broker.
- Mosquito bridge support.
- Plugin support - mosquitto-auth-plug ( 1 )
The functionality of the bridge is used ONLY to synchronize messages between all mosquito brokers, while the mosquito-out-plugin can be used to save authorization and ACLs in one database.
When setting up the bridge, pay attention to the use of I / O bridges to avoid forwarding loops ( 2 ). The template has a format
topic pattern [[[ out | in | both ] qos-level] local-prefix remote-prefix]
Specifying the man page for mosquitto.conf ( 3 ). For incoming topics, the bridge will add the template using the remote prefix and subscribe to the resulting theme of the remote broker. When the corresponding incoming message is received, the deleted prefix will be removed from the topic, and then the local prefix will be added. And vice versa for an outbound topic
An example of mosquitto.conf for a 3 node cluster is given below. To test the load with mqtt-malaria ( 4 ) and, more importantly, the effect on connecting clients with the clean_session flag to false.
+-------------------+ +------------------> BRIDGE BROKER <------------+ | | 192.168.1.1 | | | +--------^----------+ | | | | | | | | | | Broker A | Broker B | | Broker C | | | +----------------------+--+ +----------------+--------+ +--+----------------------+ | connection A | | connection B | | connection C | | | | | | | | address 192.168.1.1:1883| | address 192.168.1.1:1883| | address 192.168.1.1:1883| | | | | | | | topic
source share