SNS (Event broadcaster)

SNS (Simple Notification Service) is an Event broadcaster that fans out messages to multiple subscribers.

SNS is a fully managed pub/sub messaging service where publishers send messages to topics and these messages are automatically delivered to all subscribed endpoints/consumers.

Key Features:

  • Message size:

    • Standard: Up to 256 KB of text in any format

    • Extended: Up to 2 GB using Amazon SNS Extended Client Library (stores payload in S3)

  • Encryption:

    • In-transit encryption by default

    • At-rest encryption using KMS (optional)

  • Access Control:

    • IAM policies

    • SNS Access policies (define who can publish/subscribe)

Supported Subscribers:

  • Application integration:

    • Amazon SQS

    • AWS Lambda

    • Amazon Kinesis Data Firehose

  • Messaging:

    • HTTP/HTTPS endpoints

    • Email

    • SMS

    • Mobile push notifications

    • Platform application endpoints

Message Filtering:

  • Subscription filter policies allow filtering messages before delivery

  • Reduces unnecessary message processing

Message Reliability:

  • Dead Letter Queues (DLQ) support for failed message delivery

  • Custom retry policies supported for HTTP/HTTPS endpoints

  • Message durability through multiple Availability Zone replication

Messaging Types:

  • Standard Topics:

    • Best-effort ordering

    • At-least-once delivery

  • FIFO Topics:

    • Strict message ordering

    • Exactly-once message delivery

    • Must have SQS FIFO queues as subscribers

SNS Fanout Pattern:

  • Pushes messages to multiple subscribing endpoints simultaneously

  • Enables parallel, asynchronous processing

  • Provides complete decoupling between publishers and subscribers

  • Common use cases:

    • Application alerts

    • Monitoring systems

    • Workflow processing

    • Cross-account/cross-region message delivery

SNS Topic Subscribers Models:

SNS topic subscribers can be registered in two ways:

  1. Subscription Registration (Push Model):

  • The topic owner creates the subscription

  • Done through AWS Console, AWS CLI, or AWS SDKs

  • You specify the endpoint (like an SQS queue, Lambda function, HTTP/S endpoint, email, etc.)

  • For HTTP/S endpoints, SNS sends a subscription confirmation message

  • The endpoint must confirm the subscription by sending back the token

  1. Subscription Request (Pull Model):

  • The subscriber initiates the subscription request

  • Used mainly for cross-account scenarios

  • Requires explicit approval from the topic owner

  • Topic owner must have a subscription policy allowing the request

Supported endpoint types include:

  • Amazon SQS queues

  • AWS Lambda functions

  • HTTP/HTTPS endpoints

  • Email addresses

  • Mobile push notifications

  • SMS messages

  • Amazon Kinesis Data Firehose

For protocols requiring authentication (like HTTPS), the endpoint must actively confirm the subscription by responding to SNS's confirmation message before messages can be received

Best Practices:

  • Use filter policies to reduce unnecessary message delivery

  • Implement DLQ for handling failed deliveries

  • Monitor delivery metrics using CloudWatch

  • Use FIFO topics when message ordering is critical

Last updated

Was this helpful?