CLOUD / A CONCEPT NOTE
SQS
fully managed message queuing for decoupling services
Overview · mechanism
pitfall · examples
01 / THE SHORT VERSION
The idea in a few sentences.
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.
02 / FOLLOW THE MECHANISM
How a message flows through sqs
Producer
calls
SendMessagewith a JSON payload to a queue URL.SQS
stores the message redundantly across multiple AZs and returns a message ID.
Consumer
polls
ReceiveMessage— SQS returns up to 10 messages with a receipt handle and visibility timeout.Processing
the consumer processes the message. If successful, it calls
DeleteMessagewith the receipt handle.Failure
if the consumer doesn't delete within the visibility timeout, the message reappears for another consumer.
04 / COMMAND NOTES
Read the command, then the result.
Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.
send a message to SQS
aws sqs send-message --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/my-queue --message-body '{"key":"value"}'poll for messages
aws sqs receive-message --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/my-queue05 / CHECK YOURSELF
Could you explain SQS to a teammate?
Try it out loud in two sentences: what it is, and the one detail that changes the picture. If you stall, the gap is the part to reread.
Up next in Cloud architectureDynamoDBserverless NoSQL database with single-digit millisecond latency