Home/Labs/Pub/Sub Fanout Topology Lab
All 280 Labs
INTERACTIVE LAB📡

Pub/Sub Fanout Topology Lab (Interactive)

Compare point-to-point queues with topic fanout as subscribers appear, filter, and crash. Send events through direct peer queues or an SNS-style topic fanout and measure delivered copies, lost messages, filtering savings, and per-subscriber buffering.

Point-to-Point Queue vs. SNS + SQS Fanout

Publish OrderPlaced events and compare one-consumer work splitting with one-copy-per-domain broadcast.

Events Published

0

1 network call each

Delivered Copies

0

publish to see fan-out

Lost / Buffered

0

safely isolated in own queue

Filter Savings

0

copies the broker skipped

SNS topic → dedicated SQS queue per microservice

📦 Inventory

received: 0

💳 Billing

received: 0

📧 Notification

received: 0

🕵️ Fraud Audit 🔎

received: 0

only amount ≥ $10k

COST METER:

$0.000 per month per 1k events at this fan-out — pub/sub multiplies queue writes by subscriber count (—), which is why attribute filtering matters.

Point-to-point divides work; pub/sub broadcasts facts. With a shared queue, one crashed consumer strand type loses messages for every other domain — the reason Amazon orders emit a single OrderPlacedto SNS and let each team's own SQS queue, DLQ, and scaling policy stay an independent failure domain.

How It Works Under the Hood

Point-to-point queues own one consumer per message—perfect for work distribution—but coupling producers to every recipient’s address makes adding a consumer a producer code change. Publish/subscribe inverts it: producers emit to a topic, and the broker fans one publish out to every subscription. With push fanout a crashed subscriber loses its copy unless the platform retries; pull fanout via SNS-to-SQS buffers each subscriber in its own queue so slow consumers never block others. Subscription filters keep full payloads off subscribers that only care about a slice.

Core Architectural Principles

  • Fanout cost is per publish-subscriber pair: one event × N subscriptions = N delivered copies.
  • Pull-based fanout (SNS → per-subscriber SQS) buffers a crashed consumer; direct P2P links lose its message.
  • Subscription filtering (price ≥ $10k to fraud) drops egress cost without touching producer code.
Interview Round Script

Frame the choice by coupling direction: "queues route one message to one worker; topics replicate one event to many interested parties." Mention the N-copy cost, that new consumers must be zero-touch for producers, and that pairing topics with per-subscriber queues converts push fragility into buffered pull resilience.

Key Trade-Offs

Topics decouple producers from consumer churn but multiply storage and egress and require per-subscriber buffering to survive crashes.

Related Curriculum Chapter

Point-to-Point vs Publish-Subscribe (Pub/Sub)

Read Full Chapter Blueprint

Explore More Interactive Labs

View All 280 Labs