7.2 Advanced SQS Patterns — DLQ, Backpressure, and FIFO

Key Takeaways

  • Dead-Letter Queues (DLQs) capture messages that fail processing after maxReceiveCount attempts, preventing poison pills from blocking the main queue.
  • SQS-based backpressure uses queue depth to control the rate at which work is consumed, preventing downstream services from being overwhelmed.
  • SQS FIFO queues support message group IDs for ordered processing within groups and deduplication IDs for exactly-once processing.
  • Long polling (WaitTimeSeconds up to 20 seconds) reduces SQS API costs by eliminating empty response loops.
  • SQS temporary queues implement the request-response pattern for synchronous-style communication over asynchronous infrastructure.
Last updated: March 2026

Advanced SQS Patterns — DLQ, Backpressure, and FIFO

Quick Answer: DLQ = catch failed messages after N retries. FIFO = ordered + exactly-once (3000 msg/s with batching). Long polling = reduce API costs (wait up to 20s for messages). Backpressure = use queue depth to control downstream load. Message Group ID = parallel FIFO processing within groups.

Dead-Letter Queue (DLQ) Patterns

How DLQ Works

  1. Message arrives in main queue
  2. Consumer receives and processes the message
  3. If processing fails, message returns to queue (after visibility timeout)
  4. After maxReceiveCount failures, message moves to DLQ
  5. DLQ messages can be investigated, fixed, and redriven

DLQ Configuration

SettingDescription
maxReceiveCountNumber of receive attempts before moving to DLQ (e.g., 3)
DLQ retentionUp to 14 days (set higher than main queue)
RedriveMove messages from DLQ back to source queue after fixing
AlarmSet CloudWatch alarm on DLQ depth to alert on failures

DLQ Best Practices

  • Set DLQ retention longer than the source queue
  • Set up CloudWatch alarms on DLQ message count
  • Use redrive policy to replay messages after fixing the issue
  • DLQ for a Standard queue must be Standard; DLQ for a FIFO queue must be FIFO

FIFO Queue Advanced Features

Message Group ID

Messages with the same Message Group ID are processed in strict order. Messages with different Group IDs can be processed in parallel.

ScenarioGroup ID StrategyBehavior
All messages must be in orderSame Group ID for allSerial processing
Orders from different customersCustomer ID as Group IDParallel per customer, serial per customer
Events from different devicesDevice ID as Group IDParallel per device

Deduplication

MethodHow
Content-basedSQS generates hash of message body; duplicates within 5 minutes are rejected
Deduplication IDYou provide an explicit ID; duplicates within 5 minutes are rejected

FIFO Throughput

ModeThroughput
Standard FIFO300 messages/second (send, receive, delete per API)
High Throughput FIFO3,000 messages/second with batching, 300 without

Backpressure Pattern

Use SQS queue depth to control the rate of processing:

  1. Producers send messages to SQS at any rate
  2. SQS absorbs the burst (buffers messages)
  3. Consumers process at their own pace
  4. Auto Scaling adds/removes consumers based on ApproximateNumberOfMessagesVisible metric
  5. Downstream services are never overwhelmed

This pattern decouples production rate from consumption rate.

Long Polling

Polling TypeBehaviorAPI CallsCost
Short pollingReturns immediately (even if empty)High (polling in tight loop)Higher
Long pollingWaits up to 20 seconds for messagesLowerLower

Enable long polling by setting WaitTimeSeconds > 0 (queue level or per-request).

On the Exam: "Reduce SQS costs" → Enable long polling (WaitTimeSeconds=20). "Handle messages that repeatedly fail" → Configure DLQ with maxReceiveCount. "Process messages in order per customer" → FIFO queue with Customer ID as Message Group ID.

Test Your Knowledge

A company processes financial transactions that must be processed exactly once and in the exact order they were submitted per account. How should they configure SQS?

A
B
C
D
Test Your Knowledge

What is the purpose of setting WaitTimeSeconds to 20 on an SQS queue?

A
B
C
D