You've been hired as a developer to work on an application.
This application is hosted on an EC2 Instance and interacts with an SQS queue.
It's been noticed that when the application is pulling messages, a lot of empty responses are being returned.
What change can you make to ensure that the application uses the SQS queue effectively?
Click on the arrows to vote for the correct answer
A. B. C. D.Answer - A.
Option B is invalid because this is valid only for the processing time for the Messages.
Option C is invalid because this would not be a cost-effective option.
Option D is invalid because this is not a practice for SQS queues.
The AWS Documentation mentions the following.
Long polling helps reduce the cost of using Amazon SQS by eliminating the number of empty responses (when there are no messages available for a ReceiveMessagerequest) and false empty responses (when messages are available but aren't included in a response).
For more information on long polling in SQS, please refer to the below link-
https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-long-polling.htmlWhen an application interacts with an Amazon Simple Queue Service (SQS) queue, it can do so using either short polling or long polling. Short polling involves the application repeatedly sending requests to the SQS queue to check for new messages. This approach can result in a lot of empty responses being returned when there are no new messages, which can lead to inefficient use of system resources.
On the other hand, long polling involves the application sending a request to the SQS queue and waiting for a response for a specified period of time, known as the long poll timeout. If a new message arrives in the queue during this time, it is returned to the application immediately. If no new message arrives during this time, the SQS queue waits until the long poll timeout expires before returning an empty response. Long polling reduces the number of requests made by the application and can result in more efficient use of system resources.
Therefore, option A - Use long polling - is the correct answer to this question, as it can help reduce the number of empty responses returned to the application when checking the SQS queue for new messages. Setting a custom visibility timeout (option B) can also be useful, as it determines how long a message remains invisible to other consumers after being retrieved by an application. However, it is not directly related to the issue of empty responses being returned.
Option C - Use short polling - is not recommended in this scenario, as it can result in the application making many requests to the SQS queue and receiving a lot of empty responses. Finally, option D - Implement exponential backoff - can be useful in scenarios where an application is experiencing errors or timeouts when interacting with an SQS queue. However, it is not directly related to the issue of empty responses being returned.