Home About us Support Partners SIGN UP NOW
 Home    Blog    IoT Implementation on Azure

Enterprise IoT implementation on Azure - MQTT Load Balancing

by Ponlakshmi

iot implementation on azure

The most essential criteria that should be looked at when considering an enterprise IoT deployment is scalability. When there is huge traffic with very large amount of data, the scalability becomes a question? To overcome this, MQTT Broker cluster with robust and fault-tolerant high availability configuration is needed. But how does the devices in an IoT environment know which MQTT Broker to connect? Load balancing at the transport layer can address this challenge and ensure this with Azure load balancer will fit & scale your IoT applications. Bevywise MQTT Broker perfectly works with ALB and it is even flexible to be hosted in Azure VMs. This blog will take you to the tour of how to setup your highly scalable IoT implementation on Azure with Bevywise MQTT Broker.

Insight into IBC-Enabled MQTT Brokers

Maintaining uninterrupted MQTT communication requires a high availability MQTT Broker. While the native publish and subscribe model of MQTT protocol lacks built-in high availability, achieving it is straightforward with the right MQTT Broker. That's where our Bevywise MQTT Broker comes in, introducing the Inter-broker communicator (IBC) functionality. This innovation facilitates continuous inter-broker communication, ensuring seamless device communication even if clients connect to different brokers within the architecture.

Clustered Configuration

Ha architecture

Consider the above architecture as an example. It illustrates the grouping of 2 or more MQTT Brokers (each with IBC enabled) to create a clustered setup. A load balancer is employed to evenly distribute workloads across the brokers, and a shared database serves as a central storage option for all brokers within the setup.

What function does a load balancer serve?

A load balancer’s goal is to increase productivity, shield your servers and resources from overload, and give users a quick, secure, and dependable experience. If you have two or more servers, you need to think about installing a load balancer. The key characteristics of a load balancer are listed below.


  • Distributes traffic to healthy servers with adequate capacity, aiding you in preventing slowdown of your websites caused by an increase in traffic.
  • Route traffic automatically to healthy, available servers to help you do server maintenance without experiencing interruption.
  • Early server failure detection will be made possible, and traffic will be diverted to healthy, still-running servers.
  • Provides you with comprehensive performance data, error alerts, and reporting to help your company plan, modify, and optimise its infrastructure.

Using the Azure load balancer to enable high availability

Requirements for enabling high availability using Azure load balancer :


  • ‘N’ number of clients
  • MQTT Brokers (more than 1) with IBC enabled
  • A load balancer (Azure)
  • A Database

The number of MQTT Brokers can increase based on the count of clients. With the use of IBC server, link and cluster all the MQTT Brokers you possess. If either of the MQTT Broker fails, then the load balancer will decide which broker should take over the responsibility of the failed MQTT Broker and send messages to the connected clients, preventing the failure to happen. This is feasible as all the cluster nodes and brokers will receive all the MQTT messages.

Set up Azure as a load balancer in one of the machines. Azure load balancer health probe will keep track of each virtual machine’s assigned port and only routes traffic to operational virtual machines.

To configure Azure load balancer, take the actions listed below.

Step 1 : Upon logging in into the Azure portal, search for “Load Balancer” and select it from the results. Then click “Add.” In the “Basics tab,” precisely enter the following information, then click “Review + Create.”


  • Subscription : Select your subscription
  • Resource group : Select Create New and provide a resource group name in the text box
  • Name : Give a name
  • Region : Select the region of the server you use
  • Type : Among Internal and Public, select Public
  • SKU : Out of Basic and Standard, select Basic
  • Public IP Address : Select Create new. Choose Utilize existing if you already have a public IP address that you want to use.
  • Public IP Address name : Type the public IP address name in the text box

Once you finally click “Create,” your load balancer will appear.

Step 2 : Go to Networking > Virtual network under Create a resource. Enter the necessary project and instance information on the Basics page to build a virtual network.

A button labelled “Next: IP address” will then appear at the bottom of the page. Enter the IP address under the IP Addresses tab and choose the term ‘Default’ under the Subnet name.

To make changes, select Edit subnet and save anything you wish to change in the subnet category.

Step 3 : Choose All Resources > All Services. From the list of resources, choose your resource’s name. From the Settings menu, pick Backend pools > ‘Add’.

Enter the necessary information on the Add a backend pool page, then click Add.

Step 4 : Select All Services > All Resources > Choose your resource name from the resource list to create a health probe. Select Health Probes under Settings, then click Add. Then click OK after entering the information on the Add health probe screen.


sslprobe

  • Name – Give a name to your health probe
  • Protocol – TCP
  • Port – Enter the port on which your broker is running
  • Interval – 5 seconds
  • Used by – HTTP
health probes

Step 5 : By selecting All services > All resources >, you may create a load balancer rule. The resource list will appear; choose your resource’s name. Choose Load balancing rules from the Settings menu, then click Add.

Type in the required information and select Ok.


load2

Finally click Create / Finish to create the load balancer.


load balancing rules

Step 6 : Locate and copy the public IP address from the load balancer’s Overview screen, then paste it into your browser’s address bar to test the load balancer. Verify the answer.


If you get a valid response, your load balancer has been configured properly and can communicate with the backend virtual machines.

Integrate Azure load balancer with MQTT Broker :

To integrate Azure load balancer with MQTT Broker, follow the below instructions.


  • Go to Bevywise/MQTTRoute/conf/broker.conf
  • Provide the IP address of the load balancer that’s generated after setting it up
CLUSTERING = TRUE
BROKER_IP = IP address of load balancer
Port = 8082

Ensure the load balancer's IP is entered in all MQTT Brokers within the clustered setup.

For database configuration details, refer to our comprehensive high availability MQTT cluster blog.

Get started with our MQTT Broker for FREE and experience uninterrupted connectivity.



Hope this blog has helped you understand how to configure the Azure load balancer to enable high availability. Try customising it yourself. The usage of Nginx load balancing by MQTT Broker to support high availability has already been thoroughly documented.


Please feel free to contact support with any questions or recommendations.