Send each message to the right consumers
Choose a queue, fanout topic, event bus, or retained stream from delivery ownership, buffering, routing, replay, and ordering, then make duplicate side effects safe.
LESSON GOALS
By the end, you can
- Choose SQS, SNS, EventBridge, or Kinesis from who needs each message and whether replay or ordering is required.
- Design independent consumer backlogs with idempotency, bounded retry, dead-letter handling, and observable recovery.
01
Decide who needs each message
Start with one business fact, such as “order 482 was accepted.” Ask who owns it, which consumers need a copy, whether the producer may wait, how long an outage may last, and whether old records must be replayed.
A synchronous call fits when the caller needs an immediate result and accepts the dependency's latency and availability. An asynchronous handoff fits when work may finish later and the producer should continue while consumers recover.
Amazon SQS stores work for competing consumers. One message is processed by one of the workers, not copied to every business function. Standard queues use at-least-once delivery and best-effort ordering.
Visibility timeout is a processing lease. A worker receives a message, performs the work, and deletes the message only after success. If it crashes first, the message becomes visible for retry.
Define maximum backlog age, duplicate tolerance, retention, ordering scope, and poison-message handling before choosing a broker. “Use events” is not yet an architecture.
02
Choose queue, fanout, routing, or stream
Use one SQS queue when several equivalent workers compete to complete one job. This smooths bursts and lets another worker retry when a lease expires.
Use SNS or EventBridge to fan one event out when fulfillment, analytics, and email each need their own copy. Give each consumer its own SQS queue so one outage grows only that consumer's backlog.
EventBridge routes events from many sources to selected targets using rules. It does not replace a durable competing-consumer queue when the target needs backlog ownership.
Use Kinesis Data Streams when independent consumers must replay retained records and ordering within a partition key matters. A hot partition or one FIFO message group can serialize throughput, so choose the ordering key deliberately.
The products may be combined because they own different jobs. EventBridge can decide which business functions receive an event, while separate SQS queues buffer each function's work.
Test the shape. Pause analytics and verify its queue age grows while fulfillment continues. If one shared queue causes either analytics or fulfillment—not both—to receive an order, the design chose competition where fanout was required.
03
Make duplicate delivery safe
At-least-once delivery means the same operation can arrive again. Put a stable operation ID on every irreversible side effect and store the completed result so a retry can return it instead of repeating the action.
Consider a worker that charges a card and crashes before deleting its SQS message. The queue cannot know the charge completed. On retry, the worker must look up the order operation and discover that the charge already exists.
Set visibility timeout longer than ordinary processing or extend it safely. Use bounded retries for transient errors. Move repeatedly failing input to a dead-letter queue, or DLQ, for investigation. A DLQ is quarantine, not successful completion.
Keep contracts loose but explicit. Version schemas, tolerate additive fields, restrict publishers and consumers, encrypt messages, and avoid placing secrets or full payment data in operator-facing dead-letter payloads.
Monitor accepted events, backlog count and age, retries, duplicate suppression, failed subscribers, and drain time. Eight hours of retention is useful only when the recovered consumer can drain the backlog before expiry and before the business deadline.
For the order scenario, fan out to three queues. An analytics outage should not stop checkout or fulfillment, and duplicate injection should produce one fulfillment state transition for the same order ID.
DECISION TABLE
Compare the architecture constraints
| requirement | choose | because | reject |
|---|---|---|---|
| One job to one of many workers | SQS | Competing consumers share backlog | SNS sends copies |
| Every subscriber retains a copy | SNS/EventBridge to separate SQS queues | Fanout and buffering are explicit | One queue makes subscribers compete |
| Many sources routed by rules | EventBridge | Content routing decides | SQS is a work queue |
| Replayable ordered records | Kinesis Data Streams | Retention and partition ordering fit | SQS deletes completed work |
GUIDED WORKED SCENARIO
Reason from the stated constraints
This is a guided example, not a question to memorise. The knowledge check uses new situations to test the same reasoning.
Each order triggers fulfillment, analytics, and email. Analytics may fail for eight hours without blocking checkout or losing backlog. Peak is 500 orders/s.
Requirements
- Deliver each order to all three
- Isolate consumer outages
- Retain analytics backlog eight hours
- Prevent duplicate fulfillment
Reasoning path
- Use fanout because each needs a copy.
- Use a separate queue per consumer.
- Use order IDs and idempotent state transitions.
- Configure visibility, retry, DLQ, retention, and age alarms.
Why it wins
- Fanout gives copies and queues isolate outages.
- Duplicates are handled explicitly.
Why the alternatives lose
Only one business function receives each order.
Becomes correct when: Equivalent workers perform one job.Analytics outage blocks checkout and no backlog exists.
Becomes correct when: Caller requires all immediate results.The scenario asks for simple backlogs, not replay stream semantics.
Becomes correct when: Replay and partition ordering are central.INTERACTIVE ARCHITECTURE VISUAL
Choose competition or fanout before testing failure
Decide whether one worker or every business function needs the message, then pause analytics.
× Request stopsOne shared queue makes fulfillment, analytics, and email compete, so each misses some orders.
Read the diagram as text
An event ledger lists the order copy delivered to each queue, duplicate handling, analytics outage backlog, redrive state, and final side effect.
KNOWLEDGE CHECK
Answer one question at a time
Pass every question to complete this lesson. Each answer includes reasoning before you continue.
KEY TERMS
Glossary
- Queue
- A backlog from which competing consumers receive work.
- Fanout
- Delivering a copy of one message to multiple independent consumers.
- Event bus
- A routing boundary that sends events to targets using rules.
- Stream
- An ordered retained sequence that independent consumers can read or replay.
- Visibility timeout
- The period during which a received SQS message is hidden from other consumers.
- At-least-once delivery
- A delivery model in which a message may be delivered more than once.
- Idempotency
- Handling a repeated operation without repeating its business side effect.
- Dead-letter queue (DLQ)
- A queue holding messages that exceeded their retry policy.
- Partition key
- A value that groups stream records for ordering and distribution.
- Backlog age
- How long the oldest unprocessed work has been waiting.
PRIMARY SOURCES
Verify the claims
- primaryAmazon SQS Developer Guideaws-int-sqs · retrieved 2026-07-29
- primaryAmazon SQS standard queuesaws-sqs-standard-queues · retrieved 2026-07-30
- primaryAmazon SNS Developer Guideaws-int-sns · retrieved 2026-07-29
- primaryWhat is Amazon EventBridge?aws-int-eventbridge · retrieved 2026-07-29
- primaryWhat is Amazon Kinesis Data Streams?aws-kinesis-data-streams-overview · retrieved 2026-07-30