Go application CPU usage is higher than expected as the number of queues (streams) grows #11996
Replies: 1 comment 4 replies
-
I'm not sure why you believe that our team should consider a "high CPU usage" in your app a problem, however small, in RabbitMQ server. Even less sure why you expect to receive any kind of help without sharing your code (not a single function, a public repository with an executable way to reproduce). Should we guess what How Streams Can Affect ClientsStreams, just like classic queues and quorum queues, do consume some resources, even though streams is the most efficient data structure in certain terms (namely memory usage). Streams emit metrics and can perform periodic operations, just like queues. If a stream is not used, the only way it can affect an AMQP 0-9-1 client activity is the same way quorum queues or other classic queues would: by increasing context switching on the node. If the node only has one core available to it, this may have a visible effect on delivery rate, which means consumers that rely on polling may start spending more CPU time waiting for I/O. RabbitMQ was not designed for single core systems and will use all the cores available to it, given there are enough queue and stream replicas and connections (channels). There are dedicated documentation sections on Reducing CPU Usage for mostly idle RabbitMQ nodes (not clients) and Reducing Metrics Emission Frequency which is directly tied to the average number of context switches a node will perform. As for how to debug your app, we won't guess. |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
I have three node as rabbitmq cluster, and I also have three golang applications as distributed clients.
These applications lisnten on rabbitmq classic queue on vhost "messagebus".
And then I use this rabbitmq cluster to test stream queue on other vhost "/"(one producer send message(about 1.4 million msg) to stream and one counsumer consume it), it test ok
After my test, I found that it affects classic queue, I use top command to look up the golang application's CPU, it is too high.
Because of using golang, I use pprof to check the code, it shows below:
My guess is that the CPU usage is high due to constantly entering this 'select'.
But this Rabbitmq message channel should be blocked and monitored, and I confirmed that no message is sent to this queue. Why do messages keep coming?
the code like below:
Reproduction steps
...
Expected behavior
the CPU usage of the application should not too high.
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions