Comparison of MQTT and AMQP protocols with advantages and disadvantages of each and showcase of a proof of concept that combines the two for better reliability and efficiency.
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
MQTT meets AMQP
1. MQTT meets AMQP
for reliable messaging
By Haci Murat Yaman 25/6/2023
https://www.linkedin.com/in/muratyaman/
2. MQTT: Message Queuing Telemetry Transport
“... lightweight messaging protocol designed for efficient communication between
devices in constrained networks”
It is a Pub/Sub protocol.
It is not a message queue.
3. MQTT: Advantages
● Lightweight and Efficient in terms of bandwidth & processing power
● Persistent Sessions:
○ Clients can maintain their subscriptions and message queues even if they temporarily disconnect from the
broker; this feature ensures message delivery to clients that were offline during a period of unreliable
connectivity. This is misleading!
● Publish/Subscribe Model:
○ Publishers send messages to a broker; subscribers receive messages from the broker.
● Asynchronous Communication:
○ The sender does not need to wait for an immediate response from the receiver.
● Quality of Service (QoS) Levels: This is very misleading!
○ 0 (At most once): Messages are delivered once but may be lost or duplicated.
○ 1 (At least once): Messages are guaranteed to be delivered at least once, but duplicates may occur.
○ 2 (Exactly once): Messages are ensured to be delivered exactly once by using a two-step handshake
process.
● Scalability and Flexibility: a broker handle many devices → suitable for IoT
4. MQTT: Disadvantages
● Increased Network Overhead:
○ esp. in extremely constrained networks or when dealing with a large number of small messages
● Lack of Built-in Security:
○ Even though it can work over TLS; MQTT applications should implement authentication.
● Potential Message Loss:
○ While higher QoS levels (such as QoS 1 and QoS 2) provide reliability, they can introduce additional
overhead and latency, impacting the overall efficiency of the communication.
● Lack of Standardized Support for Request-Response Communication:
○ Its pub/sub model is primarily designed for asynchronous communication.
● Limited Broker Features:
○ Brokers typically focus on message routing and delivery.
○ Advanced features like message persistence depends on implementation.
● Bandwidth Consumption:
○ In scenarios with extremely low-bandwidth or high-cost data connections, the continuous
transmission of MQTT control packets, keep-alive messages, and subscription updates can impact
the overall data consumption.
5. AMQP: Advanced Message Queuing Protocol
“... a messaging protocol that provides a reliable and flexible means of
communication between applications or components in a distributed system.”
6. AMQP: Advantages
● Reliable Message Delivery:
○ It uses acknowledgments and delivery confirmations.
● Interoperability:
○ It provides a standard way of exchanging messages
● Scalability:
○ It supports distributed and scalable messaging architectures.
○ We can add more instances of the message broker or message queues.
● Message Routing and Filtering:
○ It provides flexible mechanisms for routing messages such as header-based, topic-based, content-based.
● Security:
○ It includes built-in security features like authentication and authorization mechanisms
● Vendor Neutrality:
○ It is an open and standardized protocol.
● Message Persistence:
○ It supports durable message queues.
● Monitoring and Management:
○ It includes mechanisms for tracking message rates, queue sizes, and other metrics
7. AMQP: Disadvantages
● Complexity:
○ It can be complex to set up and configure.
○ Learning Curve for Developers: Effort is required to implement message producers and consumers correctly.
○ Operational Complexity: It requires configuring queues, setting up routing rules, monitoring message flows,
and ensuring high availability and fault tolerance.
● Performance Overhead:
○ Robustness and reliability features come with performance overhead; i.e. due to acknowledgments,
confirmations, and message persistence
● Protocol Compatibility:
○ Implementations of senders and receivers may not be compatible.
● Limited Real-Time Messaging:
○ Even though it is capable of handling real-time messaging, it may not be the optimal choice for extremely low-
latency, high-frequency messaging scenarios.
● Scalability Challenges:
○ Managing large-scale deployments with high message volumes requires careful planning, monitoring, and
load balancing to ensure efficient resource utilization and avoid bottlenecks.
● Potential Vendor Lock-In:
○ There is possibility of vendor lock-in if you heavily rely on proprietary extensions or features.
11. Conclusion
The proof of concept works!
Code repository: https://github.com/muratyaman/mqtt-meets-amqp
But more testing is needed esp. under heavy load.
Could this stack of MQTT & AMQP work better than MQTT or AMQP alone?