サービス · Application Integration · CLF-C02 の発展
Amazon Simple Queue Service (Amazon SQS)
The settings that decide behavior: visibility timeout, long polling, delay, retention, DLQs, and scaling on queue depth.
このレッスンはまだ翻訳されていないため、英語で表示しています。
クラウドプラクティショナーで学んだこと
- A queue holds messages until a consumer processes and deletes them. Consumers pull.
- It decouples and buffers: peaks wait in the queue, and messages survive a consumer failure.
- Standard queues give the most throughput. FIFO queues keep order and avoid duplicates.
- A dead-letter queue collects messages that keep failing.
- 1The producer sends a message. It waits in the queue for up to 14 days.
- 2A consumer receives it, and the message is hidden for the visibility timeout. The consumer deletes it when done. If it does not, the message reappears.
- 3After too many failed receives, the message moves to the dead-letter queue.
流れ
- 1The producer sends a message. It waits in the queue for up to 14 days.
- 2A consumer receives it, and the message is hidden for the visibility timeout. The consumer deletes it when done. If it does not, the message reappears.
- 3After too many failed receives, the message moves to the dead-letter queue.
Throughput
- Standard
- Nearly unlimited
- FIFO
- Limited, high-throughput mode raises it
Order
- Standard
- Best effort
- FIFO
- Kept within a message group
Duplicates
- Standard
- Possible
- FIFO
- Removed for 5 minutes
Queue name
- Standard
- Any
- FIFO
- Ends in .fifo
Use for
- Standard
- Most workloads
- FIFO
- Order matters, no duplicates
| Compare | Standard | FIFO |
|---|---|---|
| Throughput | Nearly unlimited | Limited, high-throughput mode raises it |
| Order | Best effort | Kept within a message group |
| Duplicates | Possible | Removed for 5 minutes |
| Queue name | Any | Ends in .fifo |
| Use for | Most workloads | Order matters, no duplicates |
1 / 2
Throughput
- Standard
- Nearly unlimited
- FIFO
- Limited, high-throughput mode raises it
Order
- Standard
- Best effort
- FIFO
- Kept within a message group
Duplicates
- Standard
- Possible
- FIFO
- Removed for 5 minutes
| Compare | Standard | FIFO |
|---|---|---|
| Throughput | Nearly unlimited | Limited, high-throughput mode raises it |
| Order | Best effort | Kept within a message group |
| Duplicates | Possible | Removed for 5 minutes |
2 / 2
Queue name
- Standard
- Any
- FIFO
- Ends in .fifo
Use for
- Standard
- Most workloads
- FIFO
- Order matters, no duplicates
| Compare | Standard | FIFO |
|---|---|---|
| Queue name | Any | Ends in .fifo |
| Use for | Most workloads | Order matters, no duplicates |
概要
When a consumer receives a message, the message stays in the queue but is hidden for the visibility timeout (30 seconds by default, up to 12 hours). If the consumer deletes the message in time, it is gone. If not, it reappears and another consumer gets it. Set the timeout longer than the processing time. This is also why a standard queue can deliver a message twice, and why consumers must be idempotent.
概要
Short polling returns at once, often empty. Long polling waits up to 20 seconds for a message, which cuts empty responses and cost. A delay queue hides new messages for up to 15 minutes. Retention is 4 days by default and up to 14 days. A message can be up to 1 MiB (older guides say 256 KB). After a set number of failed receives (maxReceiveCount), a message moves to a dead-letter queue. Keep the DLQ retention longer than the source queue, and use redrive to send messages back after you fix the bug.
概要
Standard queues have nearly unlimited throughput. FIFO queues keep order within a message group ID and drop duplicates sent within 5 minutes. A FIFO queue handles 300 calls per second per action, 3,000 messages per second with batching, and more in high-throughput mode. To scale consumers, use an Auto Scaling group on the backlog per instance, not on CPU.
覚えること
- Visibility timeout: 30 seconds by default, up to 12 hours. Set it above the processing time.
- Long polling (up to 20 seconds) cuts empty receives and cost.
- Delay queue: up to 15 minutes. Retention: 4 days by default, up to 14 days. Message size: up to 1 MiB.
- DLQ: used after maxReceiveCount failures. Redrive moves messages back.
覚えること
- Standard: at-least-once, best-effort order. FIFO: exactly-once processing, order per message group.
- Scale consumers on backlog per instance.
試験では
- “Two workers process the same message” points to a visibility timeout shorter than the processing time.
- “Failed messages must be kept for analysis” points to a dead-letter queue.
- “Scale worker instances with the number of waiting jobs” points to an Auto Scaling policy on queue depth per instance.
- “Process orders in order, per customer” points to a FIFO queue with the customer as message group ID.
混同しやすいもの
Amazon Simple Notification Service (Amazon SNS)Filter policies, FIFO topics, fan-out to SQS, retries and DLQs, and when to pick SNS, SQS or EventBridge.
Amazon KinesisReal-time streams that you size in shards. Partition keys decide order and balance.
Amazon MQManaged ActiveMQ and RabbitMQ brokers, for applications that already use JMS, AMQP or MQTT and cannot be rewritten.
ほかのタスクにも登場
このタスクの内容 · 2.1
- Microservices and stateless design
- Multi-tier architectures
- Event-driven and loose coupling patterns
- Serverless application patterns
- AWS Amplify and AWS Device Farm
- Horizontal vs vertical scaling
- Caching strategies
Load Balancing
API Gateway
- When and how to containerize
SQS
SNS
EventBridge
Step Functions
MQ
Secrets Manager
- Choosing purpose-built services
- Choosing object, file or block
Lambda
- Read replicas
ElastiCache
CloudFront
Global Accelerator
Transfer Family
S3
EFS
EBS
Fargate
ECS
EKS