Amazon Web Services

Messaging & Events — SQS, SNS & EventBridge

Decouple services with queues, fan-out topics and an event bus, and know which one an interviewer wants.

Three services, three delivery shapes. Picking the wrong one is the mistake interviewers look for.

SQS is a ticketed queue at a counter — each ticket is served once. SNS is a public address announcement — everyone in the building hears it. EventBridge is a sorting office that reads the address on each envelope and sends it only where it belongs.

Key Concepts

1
    SQS          one queue, many workers, EACH message to ONE consumer
    SNS          one topic, many subscribers, EACH message to ALL of them
    EventBridge  a bus that ROUTES on message content, to many targets
2
SQS is a buffer. A producer writes, a worker polls, and the queue absorbs the difference in speed:
3
    order-service  ->  [ SQS ]  ->  worker x N  ->  database
4
If workers die, messages wait. If traffic spikes, the queue grows instead of the database falling over.
5
Visibility timeout is the detail to know. A received message is hidden rather than deleted:
6
    receive -> hidden for 30s -> worker deletes it   (done)
                             -> worker crashes       (reappears)
7
Set it shorter than the work takes and a second worker picks up the same message — the usual cause of duplicate processing. So consumers must be idempotent.
8
Standard vs FIFO.
    Standard  near-unlimited throughput, at-least-once, best-effort order
    FIFO      strict order per message group, exactly-once, 300 TPS
              (3,000 with batching)
9
A dead-letter queue catches poison messages. After maxReceiveCount failures the message moves aside instead of blocking the queue forever. An interviewer will ask what happens to a message that always fails.
maxReceiveCount
10
SNS fans out. One publish, every subscriber gets a copy — SQS queues, Lambda, HTTP, email.
11
The common pattern is both together. SNS fan-out into SQS queues gives each consumer its own buffer and its own retry, so a slow consumer cannot hold up the others.
12
EventBridge routes on content, which the other two cannot:
13
    { "source": "orders", "detail-type": "OrderPlaced", "detail": { "total": 900 } }
14
    rule: detail.total > 500  ->  fraud-check Lambda
15
It also receives events from AWS services and SaaS partners, has a schema registry, and can replay. The cost is higher latency than SQS and a lower throughput ceiling.
16
What the interviewer is probing.1. "SQS, SNS or EventBridge — how do you choose?" Probing: the delivery shapes. Stalls: "They all send messages." Moves up: SQS is one message to one consumer with a buffer; SNS fans one message out to every subscriber; EventBridge routes on the content of the event.
17
2. "What does the visibility timeout do, and what breaks if it is too short?" Probing: the duplicate-processing cause. Stalls: "It hides the message." Moves up: the message is hidden rather than deleted while being processed; if processing outlives it, a second consumer picks up the same message.
18
3. "How do you give each consumer its own retry?" Probing: the standard pattern. Stalls: "Several SNS subscriptions." Moves up: SNS fan-out into an SQS queue per consumer, so a slow or failing consumer cannot delay the others.
19
4. "What happens to a message that always fails?" Probing: dead-letter queues. Stalls: "It retries until it works." Moves up: after maxReceiveCount it moves to a dead-letter queue; without one it is retried forever and blocks the queue.