-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Azure Storage Queue scaler is reporting wrong number of messages in queue #2385
Comments
Hi @jungopro |
Hi @jungopro I was unable to reproduce the issue. Note that the scaler code also peeks at the queue to try to get an accurate number in order not to use the approximation if a definite number can be obtained. |
I've just run into the same problem, and it's a big one for my use case. The scaler peeks messages, and peek returns the visibile messages in the queue. Let's say I enqueue 10 messages. If the time needed to process the message is high (e.g: a few hours), Keda will peek 0 messages and will try to scale in to 0 pods while the pods are still working. Proposed solution: |
I am total Azure (Storage) noob, but in general, if it takes a few hours to process a message, then ScaledObject might not be the right option, you should try to use ScaleJob. |
Hi @zroubalik, thanks for your answer.
Those two ways are suggested to handle a scenario in which the queue service has no clue over "when the message processing has been completed". Azure Storage Queue does have that information, as I explained earlier. I am reluctant to port my code from Deployments to Jobs, because
Are you interested in a pull request? |
Hey @antonio-policastro |
Oh, I see. Thanks, i completely missed that you were already using ApproximateMessagesCount when the queue has more than 32 messages. I believe that the scaler should always use ApproximateMessagesCount and never Peek, because Peek can't see hidden messages. From docs:
|
I'm not sure about it, peek returns the value with accuracy. ApproximateMessagesCount (at least in .NET SDK) could return more messages than actual count |
Right. Approximate may return >0 count when in fact there aren't any
messages at all.
This looks more and more like something that we can resolve with a scaler
parameter that will determine whether to use peek or not
…On Tue, Mar 1, 2022 at 2:34 PM Jorge Turrado Ferrero < ***@***.***> wrote:
I'm not sure about it, peek returns the value with accuracy.
ApproximateMessagesCount (at least in .NET SDK) could return more messages
than actual count
—
Reply to this email directly, view it on GitHub
<#2385 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AATJ7GSL2JAHS5X5HKN2V7LU5YFGJANCNFSM5JMYOAVQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID:
***@***.***>
|
A scaler parameter would solve my problem (and jungopro's too), and it wouldn't be a breaking change. Upvote! Thanks everyone for your prompt answers. |
hey @antonio-policastro |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
This issue has been automatically closed due to inactivity. |
Did anything happen with this? I am in exactly the same situation as jungopro both with the scaling issue with visible messages, and the viability of scaled jobs. Not including invisible messages doesn't seem right. If I have KEDA set to scale 5 messages per pod, and I have 5 messages in progress, it would take another 6 messages to make KEDA request a second pod. It also results in the race condition observed here were if all of the in progress messages are not completed within the cooldown time frame, KEDA will scale in while they are still processing. Having the option to use approximate message count instead seems ideal. On a side note: when using Azure functions on an App Service Plan, you can scale based on storage queue length. The implementation Azure has used for this is approximate message count, and does not offer any other method of scaling based on queue length. |
I am not sure if my earlier comment will trigger this issue to be reopened, so I raised a feature request as well. |
Report
Hello
I think the azure_queue monitor is not reading the number of messages in the queue as it should
Looking at the code here I think that when Keda calculates the "visible messages" as 0 it returns 0, even though the actual number of messages in the queue is much higher
For example:
We see "showing 0 of 128503 messages in queue" in the portal, and Keda is also reporting 0 for the metric (even though the actual count is 128k) - see the right side in the screenshot
When we work with the c# SDK for azure storage we're getting the right numbers - see left side in the screen shot (csharp code below):
Expected Behavior
keda should report the actual # of messages in queue
Actual Behavior
keda is reporting 0 messages in queue
Steps to Reproduce the Problem
Logs from KEDA operator
No response
KEDA Version
2.4.0
Kubernetes Version
1.19
Platform
Other
Scaler Details
Azure storage queue
Anything else?
No response
The text was updated successfully, but these errors were encountered: