-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Idle workers eventually exhaust memory and crash #45386
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
A workaround is explained in the documentation:
Source: https://symfony.com/doc/5.4/messenger.html#deploying-to-production |
|
This is not a problem on Linux? Can you please elaborate? Does the issue occur on Windows in the |
Fair point, it happens on Windows/debug and not on Linux/prod. Therefore the issue could be with the environment and not the platform. |
I thought to the debugger after seeing this other issue: #45974 |
Hey, thanks for your report! |
Still relevant. |
Hey, thanks for your report! |
Hello? This issue is about to be closed if nobody replies. |
Actually I don't know why I called this a “workaround”, this is a recommendation from the doc. Can Symfony monitor and adjust the used memory to prevent an overflow automatically? From my understanding, this issue is too hard to tackle, and defining limits so that workers don't run indefinitely is a simple yet effective solution. |
We were running symfony workers for weeks without restarting, didn't have issues. Look for issue in your application. One common issue is that you are running it under |
Please don't post without reading. |
So your complaint is that it leaks memory in dev environment? I tried to fight it in symfony/monolog-bundle#165, but since then I've kinda accepted that You might want to try to remove monolog-bundle to see if after you still have memory leak problem. |
Hey, thanks for your report! |
Friendly ping? Should this still be open? I will close if I don't hear anything. |
Hey, I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen! |
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected
5.4.4
Description
An idle worker subscribed to one queue and processing no messages, running via
bin/console messenger:consume -vv
, will, eventually, simply crash and die with an error similar to the following:That is, a worker process that purportedly does absolutely nothing, quietly consumes more and more memory until it dies.
How to reproduce
Ensure at least one message queue is configured, e.g.
Run the worker for the default (only) queue:
bin/console messenger:consume -vv
Eventually the process will crash. In my example, I am using
memory_limit = 256M
, but obviously smaller limits will allow quicker reproduction.Possible Solution
A worker should not consume resources indefinitely, especially when it isn't even processing any messages! Most memory acquired should subsequently be dereferenced so it can be freed. Judicious use of
unset()
ornull
assignments may be necessary in some cases.Additional Context
Before I discovered the Symfony Messenger component, I wrote my own PHP queue worker and never had to consider running out of memory. It processes hundreds of thousands of messages per day and has an uptime of over 6 months with exactly the same PHP memory limits as the Symfony worker which dies within a few hours processing nothing. Clearly something is wrong here.
The text was updated successfully, but these errors were encountered: