Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum Number of ReceiveMessage requests for a message in SQS

In SQS, for a single message what is the maximum number of ReceiveMessage requests that can be placed within a queue's Maximum Retention Period?

I searched a lot but couldn't get any number for the Max Cap.

Is it infinite?

like image 488
sarathprasath Avatar asked Apr 01 '16 09:04

sarathprasath


1 Answers

There is no limit mentioned in the documentation of the message lifecycle, only that the message will be deleted when the maximum message retention time (default 4 days, max 14 days) for the queue expires.

It appears to be essentially infinite until then, unless you configure the queue to move messages to a separate "dead letter queue" after a configurable maximum number of receives... and in that case, the maximum number of receives that are allowed -- including the number of times that particular message pops up when viewing queue messages in the console -- is 1000. (Minimum is 1, of course).

See: Using Amazon SQS Dead Letter Queues

There does not appear to be a documented limit on the maximum number of times a message can be received, otherwise, but there is another limit that would throttle a queue where messages were being repeatedly received and their visibility timeout repeatedly allowed to expire (causing them to revert to visible again) -- every queue supports an unlimited number of messages in queue, but each queue is limited to 120,000 messages in flight at any one time (waiting for their visibility timeout to expire).

Otherwise, the maximum number of receives of a given message appears only to be limited by the maximum message retention time multiplied by the visibility timeout. With default values of 4 days and 30 seconds, that would be 4 × 24 × 60 × (60 ÷ 30) = 11,520.

In a well-behaved application, you wouldn't typically want a message to be received hundreds or thousands of times, but in a buggy application, you wouldn't want messages to be lost before you identified the problem, so the assumption I make until it can be proven otherwise is that there is no hard limit.

Your code could also examine the value of the ApproximateReceiveCount attribute to get an idea of how many times the message has been delivered if you wanted to treat messages with values over a certain threshold in a certain way. This counter does include the number of times the message has been enumerated in "view messages" in the console, since the console receives messages and then resets their visibility timeout, just like an application would.

If you want to use this value, note that SQS messages have both "attributes" (system) and "message attributes" (user defined).

like image 103
Michael - sqlbot Avatar answered Nov 15 '22 03:11

Michael - sqlbot