graph TD
A2[Go Service A] -->|Publish| B2[AWS SNS Topic]
B2 -->|Fan out| C2[AWS SQS Queue 1]
B2 -->|Fan out| D2[AWS SQS Queue 2]
C2 -->|Receive| E2[Go Service B]
D2 -->|Receive| F2[Go Service C]
This project implements a serverless event-driven architecture using AWS SNS (Simple Notification Service) and SQS (Simple Queue Service). The pattern combines the immediate fan-out capabilities of SNS with the reliable message processing of SQS to create a robust, scalable messaging system.
- Reliability: Guaranteed message delivery with built-in retry logic and dead-letter queues
- Scalability: Handles millions of messages with automatic scaling
- Decoupling: Services can evolve independently without affecting each other
- Flexibility: Easy to add new consumers without modifying existing code
- Cost-Effective: Pay only for what you use with serverless infrastructure
- Publisher sends a single message to SNS Topic
- SNS automatically fans out to multiple SQS queues
- Consumer services process messages at their own pace
- Built-in error handling with dead-letter queues
- Automatic message tracking and monitoring
This architecture is ideal for systems requiring reliable message delivery, service decoupling, and independent scaling of components.
Key features:
- Message publishing via SNS
- Message consumption via SQS
- Decoupled service architecture
- Scalable message processing
- Go 1.21+
- AWS Account
- AWS CLI configured
- AWS SDK for Go v2
Required AWS resources:
- SNS Topic
- SQS Queues (one per consumer)
- IAM roles with appropriate permissions
- Create SNS Topic
- Create SQS Queues
- Subscribe SQS queues to SNS Topic
- Configure Dead Letter Queues (recommended)