AWS Message Queues: SQS and When to Use Something Else
The message queue on AWS is Amazon SQS: a managed queue where producers send messages, consumers poll for them, and each message stays until a consumer deletes it. AWS has four neighbors that get mistaken for queues. SNS fans messages out, Amazon MQ hosts RabbitMQ or ActiveMQ, Kinesis is a replayable stream, and EventBridge routes events by content.
AWS messaging services at a glance
| Service | What it is | Ordering | Use it for |
|---|---|---|---|
| SQS standard queue | Managed queue, at-least-once delivery | Best effort | Background jobs and buffering between services |
| SQS FIFO queue | Managed queue with deduplication | Strict within a message group | Orders, payments, anything order-sensitive |
| SNS | Pub/sub topic that pushes to subscribers | FIFO topics available | Sending one event to many queues or endpoints |
| Amazon MQ | Hosted RabbitMQ or ActiveMQ broker | Per queue | Moving an existing AMQP or JMS app without a rewrite |
| Kinesis Data Streams | Sharded, replayable stream | Per shard | Analytics and high-volume event streams |
| EventBridge | Event bus with rule-based routing | None | Routing AWS and SaaS events by their content |
How an SQS queue works
A producer calls SendMessage, and SQS stores the message redundantly across availability zones. A consumer calls ReceiveMessage, does the work, then calls DeleteMessage. Between receive and delete the message is hidden from other consumers for the visibility timeout, 30 seconds by default and up to 12 hours. If the consumer crashes before deleting, the message reappears and another consumer picks it up. That is why SQS delivery is at least once, and why consumers should be idempotent.
The limits that shape a design are in the SQS quotas: a message can be up to 1 MiB, and unread messages are kept for 4 days by default and at most 14. Larger payloads go in S3 with a pointer in the message.
Sending and receiving with boto3 looks like this. WaitTimeSeconds turns on long polling, so the call waits up to 20 seconds for a message and you are not billed for a stream of empty responses.
import boto3
sqs = boto3.client("sqs", region_name="us-east-1")
queue_url = "https://sqs.us-east-1.amazonaws.com/123456789012/order-queue"
sqs.send_message(
QueueUrl=queue_url,
MessageBody='{"order_id": "12345", "amount": 100.0}',
)
response = sqs.receive_message(
QueueUrl=queue_url,
MaxNumberOfMessages=10,
WaitTimeSeconds=20,
)
for message in response.get("Messages", []):
process(message["Body"])
sqs.delete_message(
QueueUrl=queue_url,
ReceiptHandle=message["ReceiptHandle"],
)
Standard or FIFO
A standard queue has no practical throughput ceiling, may deliver a message more than once, and does not promise order. A FIFO queue delivers messages in order within each message group and drops duplicates sent within a five-minute window. In return, each FIFO partition handles 300 transactions per second per API action unless you batch or turn on high throughput mode.
Default to standard and make consumers idempotent. Reach for FIFO when processing out of order would be wrong, such as applying account updates, and choose the message group ID carefully, because it sets both the ordering scope and the parallelism. The full comparison is in SQS FIFO vs standard.
Handling messages that keep failing
A message that fails every time would otherwise cycle until it expires. A redrive policy on the queue sets maxReceiveCount, and once a message has been received that many times SQS moves it to a dead letter queue where you can inspect it and send it back after a fix. Setup and redrive are covered in the SQS DLQ guide.
For scaling, watch ApproximateNumberOfMessagesVisible and ApproximateAgeOfOldestMessage in CloudWatch. The age metric is the better alarm: a deep queue that drains quickly is fine, while an old message means consumers are stuck or too few.
When SQS is not the right service
SQS gives each message to one consumer. When several services need the same event, publish to an SNS topic and subscribe one queue per service, the pattern in SNS to SQS. When consumers need to replay history or read the same data at different speeds, use a stream instead, as compared in Kinesis vs SQS and Kafka vs SQS. When the hard part is deciding who gets which event, EventBridge rules do that filtering for you, described in SQS vs EventBridge. And when an application already speaks AMQP or JMS, Amazon MQ runs the broker it expects, a tradeoff covered in RabbitMQ vs SQS.
Where SQS fits in your AWS messaging stack
SQS is the default for work that one service hands to another inside your AWS account: it needs no capacity planning, and it scales with whatever you send. Add SNS in front when an event has several consumers, and keep streams for data you will read more than once.
Queues stop at the edge of your own infrastructure. When the consumer is a customer’s server, the delivery mechanism is a webhook, and the retries, signing, and endpoint management it needs are what Svix provides.