Just a simple question, but I can't seen to find the answer.
Is it possible to use the API, to get the queue size (the number of messages/jobs waiting to be processed) of an AWS SQS queue?
Preferably using cURL or the PHP SDK.
For a standard SQS queue, there is a limit of 120,000 inflight messages, and and 20,000 is the limit for FIFO queues. It's important to keep an eye on this limit because if you exceed it, you will be unable to process more messages until you reduce the number of inflight messages.
From the left navigation pane, choose Queues. From the queue list, select the queue that you created. From Actions, choose Send and receive messages. The console displays the Send and receive messages page.
Amazon CloudWatch consoleSign in to the CloudWatch console . On the navigation panel, choose Metrics. Select the SQS metric namespace. Select the Queue Metrics metric dimension.
If you require higher throughput, you can enable high throughput mode for FIFO on the Amazon SQS console, which will support up to 30,000 messages per second with batching, or up to 3,000 messages per second without batching.
I believe what you are looking for is get-queue-attributes, perhaps interrogating the ApproximateNumberOfMessages attribute.
You can retrieve Attributes of the Queue
and look for the relevant properties (See this link). You might want to look at both the following attributes.
ApproximateNumberOfMessages - Returns the approximate number of visible messages in a queue
ApproximateNumberOfMessagesNotVisible - Returns the approximate number of messages that have not timed-out and aren't deleted.
If you want to include the messages that are waiting to be added, you can consider the following property as well.
ApproximateNumberOfMessagesDelayed - Returns the approximate number of messages that are waiting to be added to the queue.
Finally do a summation of the values returned by the above properties and get the size of the current queue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With