Decoupling: SQS, SNS & EventBridge

Queues, pub/sub, and event-driven design.

Advanced30 min · lesson 12 of 15

Loosely-coupled architectures are more resilient and scalable than tightly-coupled ones, because components can fail, scale, and evolve independently. AWS provides managed messaging and eventing services to decouple systems.

Queues and pub/sub

Amazon SQS is a managed message queue that decouples a producer from a consumer: the producer drops work on the queue and the consumer processes it at its own pace, so a traffic spike fills the queue rather than overwhelming downstream — the queue absorbs the burst and consumers (often an Auto Scaling group) drain it. Amazon SNS is pub/sub: one published message fans out to many subscribers (queues, Lambda functions, HTTP endpoints), so multiple systems react to the same event without the publisher knowing about them. A common pattern combines them — SNS fans an event out to several SQS queues, each feeding a different consumer — giving reliable, decoupled, parallel processing.

decouple with a queue, fan out with pub/sub
# Absorb spikes: producer never blocks; consumers scale to drain the queue.
producer ──▶ SQS queue ──▶ Auto Scaling consumer fleet
(spike fills the queue, not the consumers)
# Fan out one event to many independent reactions:
event ──▶ SNS topic ──┬─▶ SQS (order processing)
├─▶ Lambda (send email)
└─▶ SQS (analytics)
# EventBridge routes events between services by rules (event-driven integration).

Event-driven integration

Amazon EventBridge extends this to a full event bus: services emit events and rules route them to targets, enabling loosely-coupled, event-driven architectures where adding a new consumer is a rule change, not a code change to the producer. The architectural payoff of decoupling is significant: a slow or failed consumer does not break the producer, each component scales independently to its own load, and you can evolve or replace pieces without ripple effects. Combined with stateless, auto-scaling tiers, decoupled messaging is what lets an AWS architecture stay responsive and resilient under uneven, bursty, real-world traffic rather than failing when one component is overwhelmed.

Decoupling services
buffer work
SQS
queue absorbs spikes
consumers scale to drain
process at own pace
react to events
SNS
pub/sub fan-out
EventBridge
rule-based event routing
Queues buffer bursts, pub/sub fans events out, EventBridge routes them. Decoupled components fail, scale, and evolve independently.
Tight coupling turns one failure into an outage
When a producer calls a consumer synchronously and directly, a slow or failed consumer blocks or breaks the producer, and a spike overwhelms everything at once. Insert a queue (SQS) or event bus (SNS/EventBridge) so components are decoupled — the buffer absorbs bursts and isolates failures, keeping the system responsive.