-
Notifications
You must be signed in to change notification settings - Fork 441
[RabbitMQ] High resource usage in AmqpConsumer::receiveBasicGet() #116
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
Comments
Sorry, just realized I'm wrong: I'm using enqueue/amqp-ext 0.4.11 in the original branch, but 0.4.13 in my new branch, this is then a regression, I'd say. |
Confirmed, 0.4.12 and 0.4.13 are currently broken for me, 0.4.11 works as expected. |
We had been using basic.consume method til we found a bug php-amqp/php-amqp#281 in AQMP extension. The bug was a serious one cuz you can get a message which is not yours (from another queue). That's why I fixed it by making basic.get a default solution. A day later (It was really fast) the bug was fixed in the extension. So now we have to strategies available:
The receive method could be controlled by <?php
new \Enqueue\AmqpExt\ AmqpConnectionFactory([
'receive_method' => 'basic_get', // or 'basic_conume',
]); |
@dkarlovi if you want to use basic_conume you have to set the |
That's indeed a good idea to add a usleep there |
@makasim how do I enable |
Ups... I forgot to add the option to the factory. |
So the problem is: you could get a message from the wrong queue? This doesn't seem to affect me as I'm using only one queue currently, this might change if I go to implement #65, but not relevant for now. I've fixed my composer constraint to <= 0.4.11 so it's not a deal breaker for me currently, can wait for a proper fix here in both Enqueue and php-amqp. |
Uh oh!
There was an error while loading. Please reload this page.
TLDR
recieveBasicGet()
(the default receive method) is using a lot of CPU and other resources as it's callingAMQPQueue::get()
as fast as it can, unbound. Should be able to switch receive method to consume and/or fix this one.I'm switching my Dockerized app from usingphp:7.1-alpine
toalpine:3.6
and installingphp7*
packages required (Dockerfile), Alpine now supports PHP 7.1 and it should make my process somewhat more streamlined.Problem is, Enqueue seems to work WAY worse in the new environment. What I mean is, resource usage goes through the roof as soon as I start a consumer (note, there are no messages produced or consumed here, it's just idle wait). When using RabbitMQ's web management console, I see my consumer's connection doing 500KB/s traffic (as I said, no messages produced, it's waiting for something to happen).I cannot quite pinpoint why this happens as the PHP version is the same, PHP modules are the same, codebase (including Enqueue) is exactly the same, etc. Obviously, this means I shouldn't report this bug here. :)What does stand out is the code inrecieveBasicGet()
, it's basically calling a non-blockingAMQPQueue::get()
without any restrictions. I'm guessing this is the core cause of this problem as I'm able to avoid this completely if I addusleep(10000)
torecieveBasicGet()
or switch the receive method tobasic_consume
(both of which I'm unable to do without changing the vendor source).The text was updated successfully, but these errors were encountered: