Course contentsShow
← Cloud and Infrastructure
Lesson 559 of 2,98910. API Gateway and Event-Driven PatternsFree lesson

SQS-SNS Fan-Out Pattern

Combining SNS and SQS to broadcast messages to multiple queues for parallel processing by different consumers.

SQS-SNS Fan-Out Pattern

What you'll learn: How to broadcast a single message to multiple SQS queues simultaneously using SNS for parallel, independent processing.

The Core Idea

The fan-out pattern combines SNS and SQS to solve a common problem: delivering the same message to multiple processing pipelines at once. Instead of sending messages directly to individual queues (which requires the publisher to know about every consumer), you publish once to an SNS topic, and SNS automatically delivers that message to all subscribed SQS queues.

Think of it like a breaking news alert: one journalist (the publisher) sends a story to the news wire (SNS topic), and multiple newsrooms (SQS queues) each receive their own copy to process independently—perhaps one translates it, another formats it for web, and another prepares it for broadcast.

Why Use This Pattern?

  • Decoupling: The publisher doesn't need to know who's consuming the message
  • Parallel processing: Each queue's consumer processes independently and at its own pace
  • Reliability: If one consumer fails, others continue unaffected
  • Scalability: Add new consumers by simply subscribing another queue to the topic

How It Works

  1. Publish a message to an SNS topic
  2. SNS delivers a copy to each subscribed SQS queue
  3. Independent consumers pull from their respective queues
  4. Each consumer processes the message according to its own logic and timing

This pattern is ideal when the same event triggers multiple different workflows—like an order placement that needs to update inventory, send confirmation emails, and trigger shipping simultaneously.

Key Takeaway: The SQS-SNS fan-out pattern broadcasts messages from one SNS topic to multiple SQS queues, enabling parallel, independent processing without tight coupling between publishers and consumers.