Cluster forming with Mosquitto broker

后端 未结 7 618
生来不讨喜
生来不讨喜 2020-12-16 23:46

I am using Mosquitto broker to implement MQTT protocol. But I am unable to find how clustering can be done in case of mosquitto brokers. Also is there any limitation on numb

相关标签:
7条回答
  • 2020-12-17 00:02

    Original source of this answer: Horizontal scaling for brokers. I just added the plugin support.

    Two functionalities of mosquitto broker combined could be used to setup a n node cluster.

    1. Mosquitto bridge support.
    2. Plugin support - mosquitto-auth-plug(1)

    The bridge functionality is used ONLY to synchronize messages between all mosquitto brokers while the mosquitto-auth-plugin could be used to save authorization and ACL in a single database back end.

    While setting up the bridge, notice the usage of in/out bridge topics to avoid forwarding loops(2). The pattern is of format

    topic pattern [[[ out | in | both ] qos-level] local-prefix remote-prefix]
    

    Quoting mosquitto.conf man page(3), For incoming topics, the bridge will prepend the pattern with the remote prefix and subscribe to the resulting topic on the remote broker. When a matching incoming message is received, the remote prefix will be removed from the topic and then the local prefix added. And vice versa for an outgoing topic

    Sample mosquitto.conf for a 3 node cluster is below. To be load tested with mqtt-malaria(4) and more importantly the effect on clients connecting with 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 # out 2 "" A/     |       | topic # out 2 "" B/     |           | topic # out 2 "" C/     |
    | topic # in 2 ""  B/     |       | topic # in 2 ""  A/     |           | topic # in 2 ""  A/     |
    | topic # in 2 ""  C/     |       | topic # in 2 ""  C/     |           | topic # in 2 ""  B/     |
    +----------------------^--+       +----------------^--------+           +--+----------------------+
                           |                           |                       ^
                           |                           |                       |
                           |                           |                       |
                           |                   +-------+---------+             |
                           +-------------------+ HA PROXY        +-------------+
                                               +-----^--^--------+
                                                     |  |
                                                     |  |
                                                     +  +
    
    0 讨论(0)
  • 2020-12-17 00:04

    You can also check EMQX for clustering support of MQTT.

    EMQX MQTT Broker

    0 讨论(0)
  • 2020-12-17 00:07

    It's not on the list mentioned by Dominik but Solace Systems has an MQTT appliance that supports clustering. Each broker supports several hundred thousand concurrent client connections.

    Disclaimer: I am a Systems Engineer at Solace

    0 讨论(0)
  • 2020-12-17 00:08

    There are 2 (for this time of writing) major open source projects that support large scale MQTT deployments and clustering

    VerneMQ and EMQ are both written in Erlang, which is very suitable for distributed messaging, having all the replication as built in toolset part of the (Erlang) language.

    VerneMQ has commercial enterprise support, while EMQ is planning to in the near future, also both projects have large companies backing them as sponsors.

    • VerneMQ (https://vernemq.com)
    • EMQ (http://emqtt.io)

    You may also look into HiveMQ which is the oldest kid in the block, yet cannot be used without a payed license.

    • HiveMQ (http://www.hivemq.com)
    0 讨论(0)
  • 2020-12-17 00:12

    Your may look into Bevywise IoT Platform. It is a Commercial offering. This has an option to add as many brokers as possible to scale up. This supports MQTT and MQTT-SN protocols.

    Disclaimer: I work for Bevywise Networks.

    0 讨论(0)
  • 2020-12-17 00:13

    You can't do clustering with mosquitto.

    Some other MQTT brokers out there which support clustering, including HiveMQ. HiveMQ has an elastic cluster ability with auto discovery and a distributed masterless architecture and works very well on cloud providers like AWS or Azure.

    You can see a full list of all brokers which support clustering here.

    Disclaimer: I'm a developer of HiveMQ, so this answer may be biased.

    0 讨论(0)
提交回复
热议问题