Amazon SQS supports two modes of polling for available messages: short polling and long polling. With long polling, the consumer specifies a timeout of 1-20 seconds to wait for available messages.
According to the documentation:
By default, Amazon SQS uses short polling, querying only a subset of its servers (based on a weighted random distribution), to determine whether any messages are available for a response.
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 theReceiveMessage
action.- Eliminate false empty responses by querying all—rather than a subset of—Amazon SQS servers.
- Return messages as soon as they become available.
The above characteristics make long polling seem pretty good. So is there a use case where short polling is preferable?
In particular, for high-throughput queues, is short polling faster than long polling?