Mosquitto Clustered Architecture for High Availability(HA)
and Load Balancing(LB)
• Bridge
Cluster – Set of active bridge nodes, broadcast incoming/published messages to
remote nodes.
• Remote
Cluster – Set of active remote nodes, Each remote node sends incoming messages
to all subscribers of that particular node.
• HA
Proxy Cluster – Set of HA proxy nodes in master-slave mode. Master is an active
node handles all the requests in roundrobin fashion. Incase master goes down
passive slave node gets elected as master.
• Keepalived
– Linux library runs as a daemon in both active and passive haproxy nodes. It
performs failover on transport layer.
• Virtual
IP – Private network floating IP gets rotated in HA proxy cluster.
• Public
IP – Public IP is mapped to Virtual Private IP.
• Device/Gateway
– Publish data to cluster over MQTT.
• Cloud
Application – Subscribe to cluster for device data over MQTT
Descriptions –
For above setup we need total 6 machines. One machine for
each haproxy master and haproxy slave, 2 machines for mosquito bridge nodes to
handle mqtt publish traffic and 2 machines for mosquitto remote nodes to handle
mqtt subscribe traffic (note - specific to my usecase).
Here, all publish messages from device and
applications are handled on port 1883 and subscribe messages on port 1884.
This is impressive, how many concurrent connections were you able to achieve. Can we add nodes dynamically like autoscaling? Also can you explain the need for bridge cluster and remote cluster? Is it that you are trying to sync a local broker with remote one? I am looking for a solution to load balance the MQTT connections to increase the concurrency.
ReplyDelete10k concurrent connection and 10k simultaneously messages per second.
ReplyDeleteDivided the Publish and Subscribe load using Bridge and Remote nodes respectively.
If it needs another Haproxy cluster to proxy the Remote nodes for the Subscribe client to use.
DeleteIf you are able to provide that setup than its well and good
ReplyDelete