Amazon SQS のアイコン

Amazon SQS Essential2006年〜

A fully managed message queuing service

What It Does

Amazon SQS (Simple Queue Service) is a fully managed message queue service for asynchronous communication between microservices and distributed systems. It decouples senders and receivers so that one can stop without affecting the other. Two queue types are available: Standard and FIFO.

Use Cases

Asynchronous communication between microservices, buffering order processing pipelines, job queues for batch processing, event sources for Lambda functions, and absorbing traffic spikes.

Everyday Analogy

Think of a mailbox. You drop a letter (message) into the mailbox (queue), and the mail carrier (receiver) picks it up and delivers it in order. The sender and carrier don't need to be there at the same time - the mailbox temporarily holds the letters.

What Is SQS?

Amazon SQS was one of the first AWS services ever released and serves as the foundation for message queuing. Producers (senders) send messages to a queue, and consumers (receivers) retrieve and process messages from the queue. Messages are retained in the queue until processing completes, and automatic retries handle processing failures.

Standard and FIFO Queues

Standard queues provide virtually unlimited throughput with "best-effort" message ordering. Occasional duplicate delivery is possible. FIFO queues strictly guarantee message ordering and prevent duplicate delivery, but throughput is capped at 300 messages per second (3,000 with batching).

Dead-Letter Queues and Visibility Timeout

Visibility timeout is the period during which a retrieved message is hidden from other consumers. If processing doesn't complete within this window, the message returns to the queue. A dead-letter queue (DLQ) isolates messages that have failed processing a specified number of times. Analyzing DLQ messages helps identify the root cause of processing failures. For practical know-how on dead-letter queues and visibility timeout, reference books on Amazon are a helpful resource.

Getting Started

In the SQS console, select "Create queue" and choose Standard or FIFO. Send messages (SendMessage) and receive messages (ReceiveMessage) via the AWS SDK. Setting Lambda as a trigger automatically executes a Lambda function whenever a message arrives. The always-free tier includes 1 million requests per month.

Things to Watch Out For

  • Standard queues may deliver messages more than once - ensure idempotency on the consumer side
  • Maximum message retention period is 14 days. Messages are automatically deleted after that
  • The always-free tier includes 1 million requests per month
共有するXB!