Skip to content

[amqp-bunny] High CPU usage since 0.9.10 #854

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No 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? No Sign in to your account

Closed
DamienHarper opened this issue May 20, 2019 · 7 comments
Closed

[amqp-bunny] High CPU usage since 0.9.10 #854

DamienHarper opened this issue May 20, 2019 · 7 comments

Comments

@DamienHarper
Copy link
Contributor

DamienHarper commented May 20, 2019

Since I updated to amqp-bunny from 0.9.9 to 0.9.10, I am experiencing constant very high CPU usage.

I tracked down the root cause: I haven't set any heartbeat option in enqueue.yml file and since version 0.9.10, it is assumed as heartbeat: 0 which causes the consumer to send heartbeat continuously (every 0s) to RabbitMQ rising up CPU usage to over 100% on each core.

Here is an excerpt of an enqueue.yml file causing constant high CPU usage:

enqueue:
    default:
        transport: '%env(ENQUEUE_DSN)%'
        client:
            prefix: ''
            app_name: 'My app'

Here is an excerpt of my enqueue.yml file solving the issue:

enqueue:
    default:
        transport: '%env(ENQUEUE_DSN)%'
        client:
            prefix: ''
            app_name: 'My app'
            driver_options:
                heartbeat: 60

Note: enqueue.yml format has changed since 0.9.8 but it is quite poorly documented or documentation has not been updated yet.

DamienHarper referenced this issue in php-enqueue/amqp-bunny May 20, 2019
When bunny doesn't see heartbeat key in bunnyConfig it set default value to 60 seconds.
So when one set hearbeat to zero, code ignore setting this key to bunnyConfig
@Steveb-p
Copy link
Contributor

@DamienHarper please make your PR against this repository (files for amqp-bunny are located in pkg/amqp-bunny directory).

The one you've made your PR for is read-only repository which is updated on each release via a spliting script.

Thanks :)

@DamienHarper
Copy link
Contributor Author

@Steveb-p I didn't make any PR, I just opened an issue (referencing the latest commit of the 0.9.10 release) to "help" people facing the same issue (high CPU usage) and keep track of the problem. It has been introduced in PR #820.

Setting a heartbeat value of 0 "spams" the RabbitMQ backend with heartbeat frames and keeps the CPU at 100% constantly so I don't think it's a good idea to let users do this.
Maybe @nightlinus (author of PR #820) or @makasim could share their opinion about this.

An easy solution is to revert PR #820, another one is to add documentation about the side effects of setting a 0 heartbeat and make sure that the default value is not 0 (when the heartbeat option is not explicitly defined in enqueue.yml).

@makasim
Copy link
Member

makasim commented May 21, 2019

The PR #820 has to reverted.

@nightlinus
Copy link
Contributor

nightlinus commented May 21, 2019

maybe explicitly distinguish zero value and no value? It would be more intuitive imo.

@DamienHarper
Copy link
Contributor Author

Thanks @makasim and @nightlinus for your quick feedback!
As long as we do not see any real benefit to set heartbeat to 0, I'd vote to revert PR #820 as an easy solution. How do you want to proceed now? I mean who does the revert?

@Steveb-p
Copy link
Contributor

@Steveb-p I didn't make any PR, I just opened an issue (referencing the latest commit of the 0.9.10 release) to "help" people facing the same issue (high CPU usage) and keep track of the problem. It has been introduced in PR #820.

Sorry, I misunderstood the reference. I thought it was a new PR. My bad.

As long as we do not see any real benefit to set heartbeat to 0, I'd vote to revert PR #820 as an easy solution. How do you want to proceed now? I mean who does the revert?

Feel free to PR the revert commit :) It doesn't matter in the end, does it :)

@DamienHarper
Copy link
Contributor Author

Done. PR #855

@makasim makasim closed this as completed May 21, 2019
No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants