← Back to Playbooks
    SEV-2AWS

    SQS / SNS Delivery Failures Playbook

    Messages not delivering, DLQ filling up, SNS fan-out broken, and consumers unable to keep pace. Messaging failures cause invisible data loss - events silently disappear while the producing service thinks everything is fine.

    Operator's Field Notes

    Jeremy Martinez · Incident Commander | Principal Site Reliability Engineer

    "SQS/SNS failures are insidious because the producer usually succeeds. The message is accepted by SQS/SNS, returns 200, and the producer moves on. The failure happens downstream - the consumer can't process it, the DLQ fills up, or the SNS subscription filter silently drops it. You don't know you're losing data until someone notices the downstream effect."

    "First thing I check: the DLQ. If the DLQ is growing, messages are being received but processing is failing. If the DLQ is empty and the main queue is empty but nothing is processing - the consumer is down or the messages were never sent. CloudWatchNumberOfMessagesSent vsNumberOfMessagesReceived tells you the whole story."

    First 5 Minutes - Triage

    1. Check Queue Metrics

    # Check queue attributes
    aws sqs get-queue-attributes --queue-url QUEUE_URL \
      --attribute-names All
    
    # Key metrics:
    #   ApproximateNumberOfMessages - messages waiting
    #   ApproximateNumberOfMessagesNotVisible - in-flight (being processed)
    #   ApproximateNumberOfMessagesDelayed - delayed messages
    
    # Check DLQ
    aws sqs get-queue-attributes --queue-url DLQ_URL \
      --attribute-names ApproximateNumberOfMessages
    
    # If DLQ is growing: consumer is failing
    # If main queue is growing: consumer is down or slow

    2. Check Consumer Health

    # Lambda consumer: check for errors
    aws lambda get-function --function-name my-consumer
    aws logs filter-log-events --log-group-name /aws/lambda/my-consumer \
      --filter-pattern "ERROR" --start-time $(date -u -d '1 hour ago' +%s)000
    
    # ECS consumer: check task health
    aws ecs describe-services --cluster prod --services consumer-service \
      --query 'services[].{running:runningCount,desired:desiredCount}'
    
    # Check Lambda event source mapping
    aws lambda list-event-source-mappings --function-name my-consumer

    3. Check SNS Subscriptions

    # List subscriptions for a topic
    aws sns list-subscriptions-by-topic --topic-arn arn:aws:sns:us-east-1:123456:my-topic
    
    # Check for pending confirmations
    # Status should be "confirmed" not "PendingConfirmation"
    
    # Check delivery status logging
    aws sns get-topic-attributes --topic-arn arn:aws:sns:us-east-1:123456:my-topic
    
    # Check subscription filter policies
    aws sns get-subscription-attributes --subscription-arn SUB_ARN \
      --query 'Attributes.FilterPolicy'
    # A filter policy might be silently dropping messages

    Recovery Procedures

    Reprocess DLQ Messages

    # Start DLQ redrive (move messages back to source queue)
    aws sqs start-message-move-task \
      --source-arn arn:aws:sqs:us-east-1:123456:my-queue-dlq \
      --destination-arn arn:aws:sqs:us-east-1:123456:my-queue
    
    # Check redrive progress
    aws sqs list-message-move-tasks \
      --source-arn arn:aws:sqs:us-east-1:123456:my-queue-dlq
    
    # Sample a DLQ message to understand the failure
    aws sqs receive-message --queue-url DLQ_URL \
      --max-number-of-messages 1 --visibility-timeout 0

    Scale Consumers for Backlog

    # If queue is backed up, scale consumers
    # Lambda: Increase batch size and concurrency
    aws lambda update-event-source-mapping --uuid ESM_UUID \
      --batch-size 100 --maximum-concurrency 50
    
    # ECS: Scale consumer service
    aws ecs update-service --cluster prod --service consumer-service \
      --desired-count 10
    
    # Monitor drain rate
    watch -n 10 "aws sqs get-queue-attributes --queue-url QUEUE_URL \
      --attribute-names ApproximateNumberOfMessages --output text"

    Prevention

    Queue Configuration

    • • Always configure a DLQ (maxReceiveCount: 3-5)
    • • Set visibility timeout > processing time
    • • Monitor ApproximateAgeOfOldestMessage
    • • CloudWatch alarm on DLQ message count > 0
    • • Enable SNS delivery status logging

    Consumer Resilience

    • • Idempotent message processing
    • • Graceful error handling (don't crash on bad messages)
    • • Auto-scaling based on queue depth
    • • Circuit breaker for downstream dependencies
    • • Message body validation before processing