loading...
Cover image for AWS Series: SNS, SQS or both?

AWS Series: SNS, SQS or both?

helenanders26 profile image Helen Anderson Updated on ・3 min read

AWS Associate Certifications (13 Part Series)

1) AWS Series: The Journey to Certification 2) AWS concepts from A to Z 3 ... 11 3) AWS Series: Don't you know who IAM? 4) AWS Series: What's in the Bucket? 5) AWS Series: Which EC2 is right for you? 6) AWS Series: SNS, SQS or both? 7) AWS Series: Gently Down the Stream with Kinesis 8) AWS Series: Why a VPC is like the London Underground 9) AWS Series: CloudWatch or CloudTrail? 10) AWS Series: Free AWS Services 11) AWS Series: All About Security 12) AWS Series: All About Cost Optimisation 13) I Sat the AWS Cloud Practitioner Exam Online: Here's What Happened

By combining pub/sub and queueing components we are able to build resilient, scalable and fault-tolerant architecture with AWS. This is an overview of SNS (Simple Notification Service), SQS (Simple Queue Service) and how they can be used in isolation or together to send persistent and immediate messages.


What is SNS?
When to use SNS
What is SQS?
When to use SQS
When to use them together



What is SNS?

  • SNS is a fully managed pub/sub messaging service from AWS.

  • It is used in application integration and allows apps and services to communicate with messages when these are decoupled.

  • Messages are in JSON format and are pushed to subscribers.

  • 'Topics' are logical access points and allow recipients to subscribe to identical copies of the same message.

  • Notifications are then formatted for the protocol receiving the message and can be delivered as text messages, emails, and to SQS or HTTP endpoints.


aws-sns


When to use SNS

  • SNS can be used to send large numbers of time-sensitive messages to end-users in the form of a push notification, SMS and email. Clients can subscribe to topics and specify the endpoint.

  • In this example from Adnan we see how SNS can be used in conjunction with Lambda to perform calculations. By using SNS we ensure that the message gets through.



What is SQS?

  • SNS is a fully managed message queue service from AWS.

  • It is used in application integration and allows apps and services to communicate with messages when these are decoupled.

  • SQS can store messages up to 256KB in any format for up to 12 hours while waiting for a system to pull them to process them.

  • If the job isn’t processed before the time out expires the message will be placed back in the queue, which could cause the message to be processed twice.

  • Auto-scaling groups can monitor the SQS group and scale up and down depending on the number of messages in the queue.

  • The Standard queue uses 'best-effort' ordering, FIFO queues guarantee messages are pulled in the order that they arrive.

  • By default short polling returns messages immediately. Long polling waits until there is a message in the queue or until the timeout expires.


aws-sqs


When to use SQS

  • SQS can be used to throttle workload and process work in batches with non-time sensitive messages being stored for up to 14 days.

  • In this example from Marcin we see how using Dead Letter Queues allows error handling logic from the application logic



When to use them together

  • By combining SNS topics and SQS queues together, you can send immediately and persisted messages.

  • In this example from Frank in his excellent AWS series, we see how to use SNS, SQS and Lambda together.

  • The architecture involves S3 event notifications, an SNS topic, an SQS queue, and a Lambda function sending a message to the Slack channel. This shows how it is possible to implement an event processing pipeline with potentially multiple consumers and producers.



Useful Links:


Read more:


This post first appeared on helenanderson.co.nz


AWS Associate Certifications (13 Part Series)

1) AWS Series: The Journey to Certification 2) AWS concepts from A to Z 3 ... 11 3) AWS Series: Don't you know who IAM? 4) AWS Series: What's in the Bucket? 5) AWS Series: Which EC2 is right for you? 6) AWS Series: SNS, SQS or both? 7) AWS Series: Gently Down the Stream with Kinesis 8) AWS Series: Why a VPC is like the London Underground 9) AWS Series: CloudWatch or CloudTrail? 10) AWS Series: Free AWS Services 11) AWS Series: All About Security 12) AWS Series: All About Cost Optimisation 13) I Sat the AWS Cloud Practitioner Exam Online: Here's What Happened

Posted on Jun 28 by:

helenanders26 profile

Helen Anderson

@helenanders26

Making applications go faster at Raygun, AWS Data Hero, and tag moderator on Dev.to. Database concept you don’t understand? Let me know, I’ll write a post!

Discussion

markdown guide
 
 

@helenanders26 have you managed to get Amazon SES working with SNS notifications? Would love to ask a question on this if you're open to it.