/Amazon SNS & Pub/Sub Messaging
Concept Detail

Amazon SNS & Pub/Sub Messaging

Difficulty: medium

Overview


Amazon SNS is a fully managed pub/sub messaging service for fan-out patterns.

Core Concepts: Topic → Subscriptions. Message delivered to ALL subscriptions. Up to 12,500,000 subscriptions per topic.

Protocols: SQS, Lambda, HTTP/HTTPS, Email, SMS, Mobile Push, Kinesis Firehose.

Fan-Out Pattern: SNS → multiple SQS queues. Each queue processes independently.

Message Filtering: Per-subscription filter policy (JSON) routes only matching messages. Filters on message attributes.

SNS FIFO Topics: Strict ordering, exactly-once. Only SQS FIFO queues can subscribe.

SNS vs SQS:

SNSSQS
ModelPush (pub/sub)Pull (polling)
PersistenceNoYes
ConsumersMany (fan-out)One at a time

Practice Linked Questions


medium

Q1. A developer publishes a message to an SNS topic that has 3 subscriptions: one Lambda, one SQS queue, and one HTTP endpoint. The HTTP endpoint is temporarily unavailable. What happens to the HTTP delivery?


Select one answer before revealing.

medium

Q2. A developer wants to ensure that different types of subscribers to an SNS topic only receive the messages relevant to them. For example, "order" subscribers should not receive "payment" messages. Which SNS feature enables this without creating separate topics?


Select one answer before revealing.

medium

Q3. A company wants to send notifications via SNS to both an SQS queue and email subscribers. They are concerned about losing messages if the SQS queue is overwhelmed. Which SNS feature should they configure on the SQS subscription?


Select one answer before revealing.

hard

Q4. A developer publishes a message to an SNS FIFO topic and wants to prevent duplicate messages from being processed by the SQS FIFO subscriber within a 5-minute window. Which mechanism handles this?


Select one answer before revealing.

easy

Q5. A developer needs to send the same promotional notification to 500,000 mobile app users via SNS. Creating individual subscriptions for each user would be complex. Which SNS feature handles this at scale?


Select one answer before revealing.