Monday 12 September 2022

Amazon SQS

 SQS Delay Queues: is used to postpone the delivery of messages to the consumer from 0 sec to 15 mins which is maximum. In this q messages will be invisible for delayed duration and if any consumer wants to consume message they wont see any message till that time.

Delay Queue is not supported for FIFO queues in case of per message. This is not allowed may be because by doing so order will not be maintained. 

Difference between Visibility Timeout and Delay Queues

1)for delay queues, a message is hidden when it is first added to queue, whereas for visibility timeouts a message is hidden only after it is consumed from the queue.

2)Secondly visibility Timeout is mainly used for problematic messages and in case there is any issue with message processing by the consumer , message automatically gets added on the queue. For such scenarios we can even move those erroneous messages to Dead letter Q.

Use case of SQS Delay queue: When we want delay in processing of messages like in case there is some rate limit on the consumer side and we want give some buffer so that we can process once we have some free resources etc.

Takeaways:

1)Visibility timeout range is 0 seconds and 12 hours.

2)Message that can be transferred in SQS queues can have maximum payload of size 256KB.

3)In order to increase payload or video streaming etc SQS extended client lib can be used . In this that make use of S3 and SQS where S3 has actual data and SQS has message which stores link to S3.

4)Visibility time can be set on queue basis or per message basis .

5)Dead letter Queue is good candidate for processing failed scenarios or messages.

6)Delay Q has delay-seconds set which can range from 0 to 15 minutes. 



SQS Dead Letter Queue: used to handle problematic messages.It makes use of redrive policy wherein we define source queue and maxReceiveCount . In this when receiveCount> maxReceiveCount then message is moved to Dead letter Queue if its not deleted. Later we can have consumer which can send notification or can have diagnosis.

Enqueue timestamp is the time when queue was queued in normal SQS queue but remember when that message is moved to Dead letter queue that enqueue timestamp is same which means  deadLetter Q can have lower retention period in order to process that particular message. So we shall cautious for the expiry fo the message when message is moved to Dead Letter Queue.












No comments:

Post a Comment