Definition
Message Queuing Telemetry Transport (MQTT) is a machine-to-machine protocol designed to facilitate lightweight publish/subscribe message transportation.
Overview
The MQTT protocol is designed to facilitate pub/sub messaging for low-bandwidth, high-latency networks. It minimizes network bandwidth and resource requirements while ensuring reliability by keeping packet headers as small as possible.
MQTT is also standardized by the OASIS Technical Committee, making it easy to adopt for a variety of IoT devices, platforms, and operating systems. Setting up an MQTT system to handle your pub/sub messaging needs can bring powerful benefits to your process:
- Save development time
- Increase your scalability
- Distribute information quickly and efficiently
- Drastically reduce network bandwidth consumption
How MQTT Servers Work
An MQTT system consists of multiple clients—publishers or subscribers—that are configured to communicate with a server, also known as a broker. There are four primary MQTT Control Packets that a client and server can use to communicate:
- Connect
The first packet sent from the client to the server must be a Connect packet in order to establish a connection. - Disconnect
The final packet sent from the client to the server that indicates why the connection is being closed. - Subscribe
A subscribe packet is always sent from the client to the server to create one or more topic subscriptions. - Publish
A publish packet can be sent from the client to the server, usually transporting an application message, or from the server to a client which has subscribed to the respective topic.
A client’s connection to the broker always contains a specified Quality of Service (QoS) measure. There are three options that MQTT currently supports:
- At most once
A message is sent once and only once. There is no follow-up action taken by the client or server to confirm that a message has been received. This setting has the lowest overhead. - At least once
After a message is sent, the client sends a response to acknowledge that the message has been received. If an acknowledgement is not received, the broker will continue to resend the message. - Exactly once
A two-level handshake takes place between the broker and the client to ensure that the message is received and only delivered once. This setting has the highest overhead.
Examples of MQTT Servers
Major corporations use MQTT systems for maintaining messengers, Internet of Things sensors, danger alert systems, and much more. Here are only a few examples of the ways that MQTT can be leveraged:
- Monitor cardiac patients in real-time using a wearable device after they leave the hospital
- Predict electricity consumption needs by monitoring electricity units
- Implement POS solutions that send sales information and price updates over slow networks
- Provide up-to-the-moment tracking to customers for their cargo
- Reduce latency when sending messages on social networks
MQTT servers at the edge
MQTT is already designed to work on networks with latency issues and bandwidth restrictions. By moving MQTT servers to the edge, latency practically becomes a non-issue, especially with StackPath’s virtual machines and private network backbone. Any of our virtual machines can be configured to operate as MQTT brokers or clients. As with all of our edge-compute products, they can be deployed at various edge locations around the world, making your clients and brokers closer and faster than ever.
Key Takeaways
- MQTT is a lightweight publish/subscribe solution for networks that have limited bandwidth or experience latency issues.
- Latency and network bandwidth issues can be remediated by strategically placing StackPath’s virtual machines around the world and configuring them as MQTT clients and brokers.