You have a legacy application which process message from SQS Queue.
The application uses a single thread to poll multiple queues.
Which of the following polling timeout will be the best option to avoid latency in processing messages?
Click on the arrows to vote for the correct answer
A. B. C. D.Correct Answer - A.
In the above case, the application is polling multiple queues with a single thread.
Long polling will wait for a message or timeout values for each queue which may delay the processing of messages in other queues that have messages to be processed.
So, the correct option is to use short polling with default timeout values.
Option B & C are incorrect as using Long Polling will delay the processing of messages in other queues.
Option D is incorrect as using short polling with a higher timeout will not help reduce the latency while processing images.
For more information on polling in Amazon SQS, refer to the following URL-
https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-long-polling.htmlWhen polling messages from an SQS queue, you have two options: Short Polling and Long Polling. In short polling, the application immediately receives messages that are available in the queue, regardless of whether there are any more messages waiting to be processed. Long polling, on the other hand, waits until at least one message is available before returning a response to the application.
In general, long polling is preferable to short polling because it reduces the number of API requests your application makes to SQS, and can also reduce overall latency. Long polling can be especially useful when processing high volumes of messages from multiple queues with a single thread.
In terms of visibility timeout values, it is important to set a value that is long enough to allow your application to process the message before it becomes visible again to other consumers. If the visibility timeout is too short, the same message may be processed by multiple consumers simultaneously, which can result in duplicate processing or other errors.
Based on the above, the best option for avoiding latency in processing messages from multiple queues with a single thread would be to use Long Polling with higher visibility timeout values (Option B). This will allow your application to receive messages as soon as they are available, while also ensuring that enough time is available to process each message before it becomes visible to other consumers.
Option A (Short Polling with default visibility timeout values) is not ideal because it can result in increased latency due to the need for frequent API requests to check for new messages. Option C (Long Polling with lower visibility timeout values) is not recommended because it can result in messages becoming visible to other consumers before they have been fully processed. Option D (Short Polling with higher visibility timeout values) may also result in increased latency due to the need for frequent API requests, and may not provide enough time to fully process each message.