-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
PM2/Vizion: Daemon out-of-heap memory issue when running with Vizion activated in large codebase with 50+ processes #5051
Comments
Some colleagues of mine are seeing the same issue when using pm2 to manage our development runtime, though we don't use an "ecosystem" file. PM2 4.4.0 doesn't have the issue, so I'd wager that this is at least partially related to the update of the |
I also encountered this problem. I found that closing vizion had no effect on my watch operation. I am not sure what the vizion module does. In the early stage when I just need to start a redis, it takes up 3G of memory. |
I found that vizion is used for parsing git repositories, and it seems that git repositories are used for automated deployment operations such as CI/CD. My requirements do not include this aspect and it is available after turning this option off. |
Same issue but different story.
PM2 has ~20 application, each app has
The interesting part is that this error appears in random app log, and sometimes this error message is truncated. Running The apps itself can't produce this error message because pm2 checks that their memory usage is smaller then a limit of 500 Mb. If app will use more memory, pm2 will restart the app. So the PM2 itself produces this error? But why it logs this error in random application's log ? I have updated NodeJS to 20.17.0, PM2 to 5.4.2, setup separate script to log the memory usage of PM2 apps. The workflow in the following:
Last valid output shows normal memory usage. There was no changes in codebase, nor in modules, nor in anything for months. Then this issue happens. But after updating the Node and PM2 this issue still happens on almost daily basis. Maybe this story will provide some clues to other readers. Otherwise, this is pointless info. |
I have disabled vision by default in the prochain release of PM2,
Or with bun:
Thanks |
Thanks @Unitech - though I'm the original poster, who raised this issue a few years ago, I don't have any means anymore unfortunately to give this a spin. Hope someone else who commented on this post can verify this. |
What's going wrong?
We're using PM2 to run around 50+ Node.js processes on several quite performant servers on AWS (EC2 | c4.4xlarge | 16vCPU | 30GB RAM) with code from a fairly large Git repository (118.7MB w/o node_modules and a history of ~38,000 commits).
This has been working without any performance issues, as long as the
.git
folder isn't present when runningpm2 start
with an ecosystem YAML file. PM2 daemon and the spawned processes worked well without CPU or memory issues.If the
.git
repository however is present and we attempt to run the samepm2 start
command with the mentioned ecosystem YAML file, the PM2 daemon crashes after 40s with the following stack trace:Which looks like the PM2 daemon itself runs out the default Node.js heap memory limit of 1.4GB.
We then due to some internet research encountered issues like #3403 and similar, which led us to try running PM2 with Vizion disabled by anotating the ecosystem entries with
vizion: false
. This ultimately kept the PM2 daemon from crashing even when the.git
folder was present in the project's directory.From our observations this issue only happens when the list of processes is fairly big, i.e. 50+ and the Git repository itself as well. Running PM2 with less processes caused the PM2 daemon to run out of memory slower (e.g. crash after 30mins instead of 40s).
Question:
Are there any known performance issues with Vizion when using PM2 with large Git repositories and large number of processes?
Perhaps it could make sense to either have Vizion disabled by default (I guess that would be a breaking change, though) or document a warning or some guidance in the PM2 documentation, as this side effect is not very easy to spot, and Vizion itself and what it does in PM2 is not very well documented. In fact I wasn't aware about Vizion at all, before we had this issue.
How could we reproduce this issue?
Unfortunately not easy to reproduce as this seems to only happen on a certain scale:
Run PM2 with 50+ processes in a large codebase (~118MB without node_modules / ~4500 files without node_modules / ~38k commits) with
.git
directory present and Vizion enabled (default).Wait a couple of minutes until PM2 is unresponsive and crashes due it reaching the heap memory limit
Supporting information
The text was updated successfully, but these errors were encountered: