New

Introducing Free Tier: Get Started with Cedalo MQTT Platform |Get Started

MQTT High Availability

Pro Edition for Eclipse Mosquitto™ leverages MQTT High Availability (HA) that allows your smart automation to keep operating, providing a continuous service at all times and in all cases.

Does my use case require MQTT High Availability?

MQTT High Availability ensures that your clients can always reach the broker. But why is enabling MQTT HA so important?

Ensure continuous communication with your clients

Every industrial-grade solution that relies on MQTT as a central piece of its communication should employ a high availability setup. Otherwise, MQTT becomes the single point of failure and jeopardizes your whole solution.

For instance, you used an MQTT broker to implement a smart factory solution that interprets all events as published and received messages and, based on them, performs specific actions. When your broker is offline, it won't publish data. In other words, your smart solution won't be functioning at all.

Sometimes a broker node might not be reachable. Often, it is not the broker that causes it but the underlying server hardware, operating systems, network connectivity, etc. Therefore, we recommend using MQTT Broker with High Availability to ensure your solution doesn't suffer from outages.

Client Sessions
Connected
Publishers
HA Cluster
Subscribers
Broker status
Online
Active sessionsPersistent
FailoverAutomatic
Message Persistence
Protected
Without HA
Data lost during downtime
With HA
Continuous data flow
Session dataPreserved
Queued messagesDelivered

Avoid loss of data

Many typical MQTT clients run on constrained devices with limited resources and cannot (really) persist data. Even if a client can store data when connectivity is lost, this configuration becomes too complex to implement since you must consider too many aspects when choosing one for your solution.

For example, you have a sensor that collects data and uses an MQTT broker to publish information on different topics. When a server goes down and the MQTT broker loses connection, all information gathered by a sensor during the server's downtime period will not be published by the broker and will not be received by clients. As a result, your system will lose data between when the broker lost the connection and when the connection was finally restored.

If your system were equipped with the MQTT High Availability, it would continue to operate seamlessly since switching from one node to another takes only several seconds. As a result, all information between the two mentioned earlier data points would still be available.

Furthermore, you can maintain the stability of your setup by integrating Enhanced High Availability Monitoring. This allows you to gain insights into your HA cluster's status and take preemptive action before any potential issues or risks arise.

How MQTT High Availability works

Clustering is the key to the MQTT high availability functionality. You require a minimum set of three nodes to create an MQTT broker cluster. All required information coming in and out of the broker is synchronized across the cluster at any moment. In other words, all three brokers possess the same vitals for their functioning data.

When one node fails, the MQTT failover mechanism automatically transitions all MQTT broker operations to another node. However, the Configurable Leader Election feature allows you to manually designate a leader node that best aligns with your system's unique requirements and operational needs.

Enhanced High Availability Monitoring further improves the reliability of the MQTT broker by providing insights into the HA cluster's status. It generates output metrics that indicate the current number of voting nodes and their real-time connectivity status to the leader node. Additionally, the feature provides an indication of the current cluster status, accessible only on the leader node. This allows you to effectively assess the health of your HA setup and proactively address any potential issues or risks.

1

MQTT broker normal operation

One or more load balancers funnel all traffic to the current leader MQTT broker node while the others stay in follower mode ("Follower nodes"). At any given moment in time, our MQTT Cluster Management (CM) keeps synchronizing the following data within the cluster: persistent sessions, retained messages, message queues, ACL (Access Control List), and authentication information on all clients, as well as the overall cluster status.

Normal Operation
All Healthy
Load Balancers
Leader
Follower
Follower
Traffic routing→ Leader
Data sync
Active
Sessions, ACL, queuesSynced
Failover Detected
Re-electing
Load Balancers
Down
New Leader
Follower
Traffic routing→ New Leader
ElectionComplete
Client sessionsPreserved
2

MQTT broker failover operation

If the leader node fails, the Configurable Leader Election enables you to select a specific node in the cluster as the leader, or the MQTT broker cluster performs re-organization and assigns the role of the leader node to one of the followers. Due to the constant synchronization process, the new leader node is up-to-date on the communication status and clients' information. Thus, it can take over seamlessly, ensuring smooth and continuous operation of the cluster. Now, the load balancers route all traffic through the new leader.

3

MQTT broker back to normal operation

Once the initial node is restarted, it rejoins the cluster, becomes available, and takes over a follower role. Therefore, the operation is back to normal.

Cluster Restored
All Healthy
Load Balancers
Follower
Leader
Follower
Traffic routing→ Leader
Node rejoined
As Follower
Cluster statusNormal

Which types of High Availability cluster modes are there?

Pro Mosquitto supports two MQTT HA cluster modes: Full Sync and Dynamic-Security Sync.

Full Sync

Active–Passive

Full Sync acts as an active-passive cluster where only one of the three nodes is active and can have clients connect. This is especially useful in failover cases, allowing the active node to synchronize the MQTT session and authenticate information across the cluster.

Dynamic-Security Sync

Active–Active

The Dynamic-Security Sync was introduced to cover even more use cases, such as failover and performance handling. This cluster mode acts as an active-active cluster, where all three nodes can have clients connect to them simultaneously. However, only dynamic security authentication is synchronized between nodes.

Check out the HA cluster modes documentation for more information.

HA vs Single-Node

How does MQTT High Availability differ from single-node systems?

Single-Node Broker

The risk

MQTT High Availability

The solution

Infrequent disk writes: Due to performance reasons, single-node brokers access the hard drive, store the current status, and queue only a few times per hour. If a single-node broker fails, any changes or queue status updates after the last and before a new disk writing cycle will be lost.

Constant synchronization: The Pro Edition for Eclipse Mosquitto MQTT broker with high availability can perfectly cope with such situations and avoid data loss by performing constant synchronization. Data synchronization in the MQTT High Availability setup follows strict conformation to the OASIS MQTT Specification V5.

Single point of failure: Single-node systems largely depend on the stability of the underlying server, hardware, and network connectivity. When one of these components fails, the single-node system is no longer reachable. The communication between clients interrupts and is unavailable until the failure is rectified. The time required for fixing can take seconds to, in extreme cases, days until replacement parts arrive.

Distributed resilience: MQTT High Availability system's nodes typically operate on different servers. It is even possible to place them in different geographical regions physically. If there is an outage, the operation is automatically switched to one of the follower nodes within less than a second. This is precisely how the MQTT High Availability setup dramatically increases overall system availability and ensures the smooth operation of your IoT infrastructure.

MQTT High Availability extra questions

If you have any further questions, feel free to contact us.

Ready to Get Started?

Experience enterprise-grade MQTT High Availability with automated failover and up to 99.99% uptime. Start your free trial today.