跳到主要内容

AWS SQS

Long polling vs short polling

  • long polling

    • doesn’t return a response until a message arrives in the message queue, or the long poll times out.
    • helps reduce the cost by eliminating the number of empty responses and false empty responses
  • short polling

    • returns immediately even if the message queue being polled is empty

Receive message wait time:

  • the maximum amount of time that polling will wait for messages to become available to receive.
  • the range is 0 to 20 seconds
  • if it's 0, the requests use short polling

Visibility timeout

  • a period of time SQS prevents other consumers from receiving and processing the message
  • the default is 30 seconds, the range is 0 seconds to 12 hours
  • typically you should set the visibility timeout to the maximum time that it takes your application to process and delete a message from the queue

Message retention period

  • the amount of time that SQS retains a message that does not get deleted
  • the default is 4 days, the range is 60 seconds to 14 days
  • the expiration of a message is always based on its original enqueue timestamp. When a message is moved to a dead-letter queue, the enqueue timestamp remains unchanged. So the retention period of the dead-letter queue should be longer than that of the original queue