Need advice about which tool to choose?Ask the StackShare community!
Amazon SQS vs MQTT: What are the differences?
Amazon SQS and MQTT are both messaging protocols used for communication between distributed systems. Let's explore the key differences between them.
Scalability and Distribution: Amazon Simple Queue Service (SQS) is a fully managed message queuing service that allows you to decouple and scale microservices, distributed systems, and serverless applications. It provides unlimited throughput and can handle an unlimited number of messages. On the other hand, MQTT (Message Queuing Telemetry Transport) is a lightweight publish-subscribe messaging protocol designed for low-bandwidth, high-latency or unreliable networks. It is ideal for IoT applications and devices with limited resources.
Messaging Patterns: Amazon SQS supports both standard and FIFO (First-In-First-Out) queues. Standard queues provide best-effort ordering of messages while FIFO queues guarantee exactly-once processing of messages. MQTT, on the other hand, follows the publish-subscribe messaging pattern. Publishers send messages to a topic, and subscribers can receive those messages by subscribing to the topic.
Batching and Message Size: In Amazon SQS, messages can be sent and received in batches, allowing you to improve throughput and reduce costs. The maximum size of a single message in SQS is 256KB. In MQTT, messages are sent individually without any batching options. The maximum size of a message in MQTT can vary depending on the implementation.
Security and Authentication: Amazon SQS integrates with AWS Identity and Access Management (IAM), allowing you to control access to your queues using IAM policies. It also supports server-side encryption for message data at rest. MQTT provides its own security mechanisms such as SSL/TLS encryption for secure communication. It also supports authentication and access control through username and password or X.509 certificates.
Persistence and Retention: Amazon SQS guarantees the durability of messages by storing them redundantly across multiple servers. Messages are retained until they are explicitly deleted or their retention period expires. MQTT does not provide built-in message persistence. Once a message is delivered to subscribers, it is not stored on the server and is not available for retrieval later.
Delivery Guarantees: Amazon SQS provides at-least-once message delivery. This means that a message is delivered to a consumer at least once, but duplicate messages may be delivered. MQTT offers different levels of Quality of Service (QoS), including at-most-once (0), at-least-once (1), and exactly-once (2) delivery. This allows you to choose the level of delivery guarantee based on your application's requirements.
In summary, SQS is a fully-managed message queuing service that scales well and supports various messaging patterns, while MQTT is a lightweight protocol designed for IoT applications with limited resources and operates on a publish-subscribe model.
I want to schedule a message. Amazon SQS provides a delay of 15 minutes, but I want it in some hours.
Example: Let's say a Message1 is consumed by a consumer A but somehow it failed inside the consumer. I would want to put it in a queue and retry after 4hrs. Can I do this in Amazon MQ? I have seen in some Amazon MQ videos saying scheduling messages can be done. But, I'm not sure how.
Mithiridi, I believe you are talking about two different things. 1. If you need to process messages with delays of more 15m or at specific times, it's not a good idea to use queues, independently of tool SQM, Rabbit or Amazon MQ. you should considerer another approach using a scheduled job. 2. For dead queues and policy retries RabbitMQ, for example, doesn't support your use case. https://medium.com/@kiennguyen88/rabbitmq-delay-retry-schedule-with-dead-letter-exchange-31fb25a440fc I'm not sure if that is possible SNS/SQS support, they have a maximum delay for delivery (maxDelayTarget) in seconds but it's not clear the number. You can check this out: https://docs.aws.amazon.com/sns/latest/dg/sns-message-delivery-retries.html
Pros of Amazon SQS
- Easy to use, reliable62
- Low cost40
- Simple28
- Doesn't need to maintain it14
- It is Serverless8
- Has a max message size (currently 256K)4
- Triggers Lambda3
- Easy to configure with Terraform3
- Delayed delivery upto 15 mins only3
- Delayed delivery upto 12 hours3
- JMS compliant1
- Support for retry and dead letter queue1
- D1
Pros of MQTT
- Varying levels of Quality of Service to fit a range of3
- Lightweight with a relatively small data footprint2
- Very easy to configure and use with open source tools2
Sign up to add or upvote prosMake informed product decisions
Cons of Amazon SQS
- Has a max message size (currently 256K)2
- Proprietary2
- Difficult to configure2
- Has a maximum 15 minutes of delayed messages only1
Cons of MQTT
- Easy to configure in an unsecure manner1