Why Decouple?
In a tightly coupled system, if service B is slow or down, service A fails too. With a queue or event bus in between, A drops a message and moves on, and B processes it when it can. This gives resilience, scaling and flexibility.
Amazon SQS: Simple Queue Service
SQS is a fully managed message queue. Producers send messages; consumers poll and delete them after processing. It is serverless and scales almost without limit.
| Standard queue | FIFO queue | |
|---|---|---|
| Throughput | Nearly unlimited | 300 messages/s per API action (3,000 with batching) and higher with high throughput mode |
| Ordering | Best-effort, may be out of order | Strict order within a message group ID |
| Delivery | At-least-once (duplicates possible) | Exactly-once processing (5-minute deduplication) |
| Name | any | must end with .fifo |
| Use | Most workloads. Make consumers idempotent | Orders, financial steps, commands where order matters |
| Setting | Meaning |
|---|---|
| Visibility timeout | After a consumer receives a message it is hidden for this time (default 30 s, max 12 h). If not deleted in time it reappears and is processed again. Set longer than processing time |
| Retention | Messages stay up to 14 days (default 4 days) |
| Message size | Up to 256 KB. Bigger: store the payload in S3 and send a pointer (Extended Client Library) |
| Long polling | ReceiveMessageWaitTimeSeconds 1-20. Waits for messages: fewer empty responses and lower cost. Prefer it |
| Delay queue | Delay delivery up to 15 minutes |
| Dead-letter queue (DLQ) | Messages that fail maxReceiveCount times move to a DLQ for inspection. DLQ of a FIFO queue must be FIFO |
| Encryption | SSE-SQS or SSE-KMS, HTTPS in transit |
ApproximateNumberOfMessagesVisible per instance** (backlog per instance). A very common exam answer for decoupling a web tier from a processing tier.
Amazon SNS: Simple Notification Service
SNS is a publish/subscribe service. A publisher sends a message to a topic and SNS pushes it to all subscribers: SQS queues, Lambda, HTTP(S) endpoints, email, SMS, mobile push, Kinesis Data Firehose.
- Standard topics (high throughput, at-least-once) and FIFO topics (ordering and dedup, with SQS FIFO subscribers)
- Message filtering: each subscription has a filter policy on message attributes so it gets only matching messages
- Delivery retries and a DLQ for failed deliveries
- Server-side encryption with KMS, access policy on the topic
The Fan-Out Pattern: SNS + SQS
- The SQS queue policy must allow
sns.amazonaws.comtosqs:SendMessagefrom the topic ARN - Fan-out is durable: each queue stores its copy even if its consumer is down
Amazon EventBridge
EventBridge is a serverless event bus that routes events from AWS services, your apps and SaaS partners to targets using rules with pattern matching. It is the modern choice for event-driven architectures.
| Piece | Meaning |
|---|---|
| Event bus | Default bus (AWS service events), custom buses (your apps), partner buses (SaaS like Zendesk) |
| Rule | An event pattern (JSON filter) or a schedule (cron/rate) with up to 5 targets |
| Targets | Lambda, SQS, SNS, Step Functions, ECS tasks, Kinesis, API destinations (any HTTP API), another bus, and 20+ services |
| Schema registry | Discover and version event schemas |
| Archive and replay | Store events and replay them later |
| EventBridge Scheduler | One-time and recurring schedules at scale (replaces many cron jobs) |
| Pipes | Point-to-point integration from a source (SQS, Kinesis, DynamoDB streams) with filtering and enrichment to a target |
AWS Step Functions
Step Functions coordinates multiple services into workflows (state machines) with branching, retries, parallel steps, waits and human approval, written in Amazon States Language (JSON) or built visually in Workflow Studio.
| Type | Features | Use for |
|---|---|---|
| Standard | Up to 1 year runtime, exactly-once, full execution history, priced per state transition | Long-running, auditable business processes |
| Express | Up to 5 minutes, at-least-once, very high rate, priced per request and duration | High-volume event processing, streaming data, microservice orchestration |
- Direct SDK integrations call 200+ AWS services without Lambda glue code
- Wait for callback (task token) pauses until a human or system responds
- Map state runs steps for each item in an array (distributed map can handle millions of S3 objects)
- The Saga pattern with
Catchand compensating steps handles failure across services
Amazon MQ
- Managed Apache ActiveMQ and RabbitMQ brokers
- Use when migrating existing apps that use standard protocols (AMQP, MQTT, OpenWire, STOMP, JMS). For new cloud-native apps prefer SQS/SNS/EventBridge
- Multi-AZ active/standby deployment for high availability
Choosing the Right Service
| Need | Service |
|---|---|
| Buffer work between tiers, each message processed by one consumer | SQS |
| Strict ordering and dedup of commands | SQS FIFO |
| Broadcast one message to many subscribers | SNS (fan-out with SQS) |
| React to AWS or SaaS events, content-based routing, schedules | EventBridge |
| Orchestrate a multi-step workflow with retries and branches | Step Functions |
| Stream of ordered, replayable records consumed by many readers at once | Kinesis Data Streams |
| Existing app using JMS, AMQP, MQTT | Amazon MQ |
Practice Tasks
- Create a standard queue with a DLQ (maxReceiveCount 3), send a poison message, and watch it move to the DLQ
- Build SNS to two SQS queues with a filter policy on one
- Create an EventBridge rule that reacts to an S3 object-created event and invokes Lambda
- Draw a Step Functions workflow for order processing with a failure path
- Explain visibility timeout using a timeline for a message that takes 40 seconds to process with a 30-second timeout
Conclusion
Decouple tiers with SQS (queues, long polling, DLQ, FIFO when order matters), fan out with SNS, route events with EventBridge, orchestrate with Step Functions, and use Amazon MQ only to migrate existing brokers. Make consumers idempotent and scale workers on queue depth.

