SQS
Web service that give you access to a message queue that can be used to store messages while waiting for a computer to process them
Distributed queue system that enables web service applications to quickly and reliably queue message that one component in the application generates to be consumed by another component.
A queue is a temporary repository for messages that are awaiting processing
Decouple the components of an application so they run independently, easing message management between components
Any component of a distributed application can store messages in a fail-safe queue
Messages can contain up to 256 KB of text in any format. (not hard limit, it's store on S3 so can go up to TB)
Any component can later retrieve the messages programmatically using the Amz SQS API
- (SQS) Pull-based, not pushed-based (SNS), require a compute component (EC2) pulling the message out of queue
- Messages can be kept in the queue from 1 minute to 14 days, default retention period is 4 days
- Messages will be processed/delivered at least once
- Visibility timeout
- Amount of time that the message is invisible in the SQS queue after a reader picks up that message
- The job is done before the visibility timeout expires, the message will then be deleted
- If not, the message will become visible again and another reader will process it
- This could result in the same message being delivered twice
- Eg: if message is being delivered twice? Why? Visibility timeout is not long enough, the job is taking longer time to process than visibility timeout. → increase it
- Maximum: 12hrs
- Amz SQS long polling: a way to retrieve messages from Amz SQS queues
- The regular short polling return immediately (even if the message queue being polled is empty)
- Long polling doesn't return a response until a message arrives in the message queue or times out
- Eg: queue mostly empty, EC2 polling queue will create a charge. How to reduce bill? → long poll
Queue Types
https://www.slideshare.net/AmazonWebServicesJapan/aws-31275003
