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
- Publish a message to an SNS topic
- SNS delivers a copy to each subscribed SQS queue
- Independent consumers pull from their respective queues
- 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.