TOPIC CLOUD
SQS fully managed message queuing for decoupling services
IN 10 SECONDS
Amazon SQS is a message queue that lets you decouple application components. A producer sends a message; a consumer polls and processes it. If the consumer fails, the message becomes visible again after a visibility timeout. SQS scales to handle millions of messages per second and guarantees at-least-once delivery.
GOTCHA SQS is at-least-once, not exactly-once. A message can be delivered twice if the consumer crashes after processing but before deleting. Make your message processing idempotent — deduplicate by a unique message ID or idempotency key.
HOW A MESSAGE FLOWS THROUGH SQS
01 Producer calls `SendMessage` with a JSON payload to a queue URL.
02 SQS stores the message redundantly across multiple AZs and returns a message ID.
03 Consumer polls `ReceiveMessage` — SQS returns up to 10 messages with a receipt handle and visibility timeout.
04 Processing the consumer processes the message. If successful, it calls `DeleteMessage` with the receipt handle.
05 Failure if the consumer doesn't delete within the visibility timeout, the message reappears for another consumer.
POKE IT YOURSELF
aws sqs send-message --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/my-queue --message-body '{"key":"value"}' — send a message to SQS
aws sqs receive-message --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/my-queue — poll for messages
Drill this topic →
~80 sec read