AWS · Application Integration

Amazon SNS

A managed publish/subscribe service that pushes each message to many subscribers: queues, functions, HTTP endpoints, email and SMS.

On the SAA-C03 exam listPublish and subscribeServerless

What it is and what problem it solves

Amazon SNS (Simple Notification Service) is publish/subscribe messaging. A publisher sends a message to a topic; SNS pushes a copy to every subscriber: SQS queues, Lambda functions, HTTP/HTTPS endpoints, Kinesis Data Firehose streams, email, SMS and mobile push.

The publisher does not know who is listening, and subscribers can be added without changing it. SNS keeps no backlog for a slow subscriber, so the common pattern is fan-out: SNS delivers into several SQS queues, and each queue buffers work for its own consumer.

Order servicepublishes onceSNS topicordersSQS: billingall ordersSQS: shippingall ordersSQS: fraudfilter: amount > 1000Lambda: emailfilter: country = DE
Fan-out: one SNS publish delivers a copy to every subscribed queue; filter policies choose who gets what

When to use it

  • One event must reach several independent consumers (billing, shipping, analytics) at the same time.
  • You send notifications to people: email, SMS or mobile push.
  • You want subscription filter policies, so each subscriber receives only the messages it cares about.
  • Alarms or AWS events must trigger several actions.

When to avoid it

  • Work that must be buffered until a consumer is ready: put an SQS queue behind the topic.
  • Content-based routing across many AWS services and SaaS sources: EventBridge is built for this and has built-in integrations.
  • Replay of past messages: SNS does not store messages for later reading; FIFO topics have optional archiving and replay, but a stream is a better fit for long-term replay.

Scaling model and bottlenecks

Standard topics scale to very high publish rates and very large numbers of subscriptions. Throughput limits per account depend on the Region, and FIFO topics have much lower, documented limits per topic and per message group. Delivery to a slow endpoint does not slow other subscribers.

Performance, latency and throughput

Delivery is push-based and fast, but a subscriber that cannot keep up will see retries and, for some protocols, drops after the retry policy is exhausted. Putting a queue between SNS and a slow consumer keeps messages safe while the consumer catches up.

Limits and quotas

ItemValueContextSource
Maximum message size 262,144 bytes (256 KiB) by default Can be raised to 1,048,576 bytes (1 MiB) by setting the topic's MaximumMessageSize attribute. Source
checked
Topics per account 100,000 standard; 1,000 FIFO
Can be raised with a quota request
Source
checked
Subscriptions per topic 12,500,000 standard; 100 FIFO Source
checked
Messages per PublishBatch request 10 Source
checked
FIFO topic throughput 3,000 messages or 20 MB per second per topic, whichever comes first Also 300 messages per second per message group. Source
checked
Filter policies per topic 200 Source
checked

Quotas and limits change. Check the linked source before designing around a number.

Cost model

What you pay for

  • Publish requests, where each 64 KB chunk of a payload counts as one request.
  • Deliveries, priced by endpoint type (SQS and Lambda deliveries differ from HTTP, email and SMS), with each 64 KB chunk counting as one delivery.
  • FIFO topics: published messages, subscription deliveries and payload data are billed separately.
  • SMS is priced by destination country; data transfer out is billed at standard rates; KMS charges apply for encryption with your own key.

Where it is cost-efficient

Moderate fan-out to SQS and Lambda: deliveries to those endpoints carry no per-message delivery charge beyond the request charges, and attribute-based filtering is free.

Where costs grow

  • SMS to many countries, which is priced per message and per destination.
  • Large payloads, because they are billed in 64 KB chunks.
  • Payload-based filtering of large messages, which is charged per scanned payload.

Cost controls and common surprises

Filter on message attributes rather than the payload when you can, keep payloads small (store large data in S3 and send a reference), and set SMS spending limits.

Prices differ by Region and change over time; see the pricing page linked under Sources.

Security

Controls the service provides

  • Encryption at rest with a KMS key, and encryption in transit over HTTPS.
  • Topic policies (resource-based) and IAM policies control who can publish and subscribe, including other accounts.
  • Message data protection policies can find and mask sensitive data in messages.

What you configure

Restrict sns:Publish and subscription permissions, require HTTPS, use a topic policy to allow only specific accounts or AWS services to publish, and confirm endpoint ownership. Use VPC endpoints for private publishing from a VPC.

Logging and monitoring

Delivery status logging to CloudWatch Logs records successes and failures; CloudTrail records API calls.

Related security services

KMS, IAM, VPC endpoints, and Macie for finding sensitive data in S3 that you later publish about.

Shared responsibility

AWS secures the service. You secure who may publish and subscribe, what is in messages, and the endpoints you deliver to.

Availability, backup and failure behavior

SNS stores messages redundantly across multiple Availability Zones before delivery and retries failed deliveries according to each protocol's retry policy. For subscribers that may be down, use an SQS queue as the subscriber, and set a dead-letter queue on the subscription for messages that cannot be delivered.

Common service combinations

SNS to SQS (fan-out), SNS to Lambda, CloudWatch alarms to SNS to email or a chat bridge, S3 event notifications to SNS, and EventBridge rules with SNS targets.

Business application examples

  • An order service publishes one "order placed" event; billing, warehouse and analytics queues each receive a copy.
  • An operations team gets an email and a text message when a CloudWatch alarm fires.
  • A mobile app sends push notifications to users who opted in to a topic.

Exam cues and common confusions

  • One message to many subscribers: SNS. One message to one consumer with buffering: SQS.
  • Fan-out: SNS topic with several SQS queues subscribed.
  • Send only some messages to some subscribers: subscription filter policies.
  • Notifications to humans (email, SMS, push): SNS.
  • Ordered, deduplicated fan-out: SNS FIFO topic with SQS FIFO queues.

Related

Courses and lessons

Services, comparisons and patterns

Sources

Independent study material, not affiliated with or endorsed by Amazon Web Services. AWS and service names are trademarks of Amazon.com, Inc. or its affiliates.

Last reviewed · By the ByteCamel team · How we write content

Was this page helpful?

Report a mistake