0 votes
in AWS by

As a developer, you are writing an application that will be hosted on an EC2 Instance. This application will interact with a queue defined using the Simple Queue service.

The messages will appear in the queue during a 20-60 second time duration. Which of the following strategy should be used to query the queue for messages effectively?

1 Answer

0 votes
by

Answer - C.

This is mentioned in the AWS Documentation.

Long polling offers the following benefits.

Eliminate empty responses by allowing Amazon SQS to wait until a message is available in a queue before sending a response.

Unless the connection times out, the response to the ReceiveMessage request contains at least one of the available messages, up to the maximum number of messages specified in the ReceiveMessage action.

Eliminate false empty responses by querying all-rather than a subset of-Amazon SQS servers.

Option A is invalid since this is used for storing undelivered messages.

Option B is invalid since this is used for First In First Out queues.

Option D is invalid since this is used when messages are immediately available in the queue.

For more information on long polling, please visit the following URL-

https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-long-polling.html

To effectively query the Simple Queue Service for messages, the best strategy to use in this scenario would be long polling (Option C).

Long polling is a technique that enables the client to send a request to the server, and the server will hold the request open until a message is available, or the connection times out. This method reduces the number of requests to the server and helps to minimize the cost of data transfer.

In the case of an EC2 instance interacting with an SQS queue, long polling is particularly useful when the duration for which messages appear in the queue is not fixed, as in this scenario, where the messages appear in the queue during a 20-60 second time duration. Long polling helps to ensure that messages are retrieved as soon as they are available, without the need for frequent polling requests.

Dead letter queues (Option A) are used to handle messages that cannot be processed successfully. If a message cannot be processed successfully after a certain number of retries, it is sent to a dead letter queue for further analysis. This feature is not directly related to the efficient retrieval of messages from the queue.

FIFO queues (Option B) are used when message order is important, and each message must be processed exactly once. While FIFO queues can be used to retrieve messages effectively, they do not provide any specific advantage for the scenario described in the question.

Short polling (Option D) is a technique where the client sends a request to the server and receives an immediate response, whether or not there are messages in the queue. Short polling can be useful when there is a high rate of message traffic, and messages are expected to be available frequently. However, in this scenario, where messages appear in the queue during a 20-60 second time duration, short polling would result in frequent requests being made, which could result in increased cost and slower message retrieval.

...