How to know when a queue is getting close to prefetch capacity? (_before_ it reaches capacity) #10566
Unanswered
Victor-N-Suadicani
asked this question in
Questions
Replies: 1 comment 8 replies
-
Queues do not have a "prefetch" capacity. Channels do. I cannot think of a client that keeps track of and exposes the number of outstanding deliveries on a channel. |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
TL;DR: How do I auto-scale my service before the queue starts rising?
More details:
For auto-scaling, we are currently examining queue sizes when determining when to scale. Basically we check if any queues in the
rabbitmq_queue_messages_ready
metric is above 0 - if it's above 0, that means messages are waiting in queue and we need to scale to keep up. When the queue is back down to 0 and has stayed there for a while, we scale down.However, this is not ideal as scaling is not instant, so the message that is waiting in queue will wait for longer than most of the other messages. Scaling down is also not ideal, as the queue size being 0 could still quickly go to >1 again, if the current consumers are near capacity. So scaling can be "swingy".
What I would prefer is to get some kind of metric that shows the current utilization of the prefetch on a queue across all consumers. For an example, imagine I have a queue and I have 3 consumers taking messages from that queue. Each consumer has a certain prefetch (let's say 8 for the sake of example, but in principle I don't know what the prefetch is ahead of time).
What I would like is to get a percentage of how many unacked messages are in flight compared to the total prefetch capacity. So for my 3 consumers with 8 prefetch each, there can be up to 24 messages in flight before a message would wait in queue. I would like to have a metric that would say 50% when there are 12 messages in flight, 100% when there are 24 messages in flight and 75% for 18 messages in flight, for instance.
If I had such a metric, I imagine I could autoscale much better, as I would be able to scale before I reach capacity (for instance starting the scaling at 75% capacity and downscaling again when at 25% capacity, or something along those lines).
I have tried examining the
rabbitmq_queue_consumer_capacity
metric, but this seems to be 1 constantly and only falls once a message is queued (i.e. capacity has been exceeded). So this is not an early signal either and doesn't help me more than therabbitmq_queue_messages_ready
metric.Is there a way to achieve what I want? Keep in mind I don't know the prefetches for all the consumers ahead of time, so this would need to be built into the metric somehow. If it's not possible currently, would it be feasible to add a feature request for this?
I hope this makes sense (feel free to ask follow-up questions) and any advice/help is appreciated! :)
Beta Was this translation helpful? Give feedback.
All reactions