Ends in
00
days
00
hrs
00
mins
00
secs
SHOP NOW

Get $4 OFF in AWS Solutions Architect & Data Engineer Associate Practice Exams for $10.99 each ONLY!

Lesson Progress
0% Complete

Amazon SQS provides two options for receiving messages from a queue: short polling and long polling. By default, queues use short polling, which involves setting the “Receive message wait time” to 0. On the other hand, long polling is activated when the Receive message wait time is set to a value greater than 0 (e.g. 1 to 20).

1. Click the Start Playcloud button. This will redirect you to the Queues section of the Amazon SQS.

PlayCloud is running in another tab. Time left:

00
00
mins
secs
Got lost? Click here

2. In the list of queues, select FIFO-Queue-Labs.fifo > Click Edit

3. On the Configuration pane, you’ll see the Receive message wait time section.

Short polling and long polling are two different approaches to retrieving messages from an Amazon Simple Queue Service (SQS) queue. When deciding between short polling and long polling, it’s important to consider your particular use case and requirements.

  • Short Polling:
    • If you want to retrieve messages from the queue as fast as possible, it’s best to use short polling.
    • When using short polling, the ReceiveMessage API call will provide an immediate response, regardless of whether there are any messages in the queue.
    • If you’re dealing with a large number of messages and need to keep an eye out for new ones without delay, short polling is a great option.
  • Long Polling:
    • If you aim to minimize the occurrence of empty responses and increase efficiency, implementing long polling is a recommended strategy.
    • Using long polling, the ReceiveMessage API call patiently waits for a specific duration (determined by the WaitTimeSeconds parameter) until messages are received.
    • In case the queue has no messages available, the API call will wait either for a message to appear or for the wait time to expire.
    • If you’re dealing with a small number of messages and want to avoid making multiple API requests to check for new messages, long polling is a great option. This can lead to cost savings and increased efficiency in the long run.