Skip to content
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

Update ecosystem2.config.js for cluster mode #151

Merged
merged 1 commit into from
Oct 17, 2024

Conversation

rvolz
Copy link
Contributor

@rvolz rvolz commented Oct 9, 2024

Enables pm2 to have direct access to the app and to control it better than before.

Using npm to start the app caused pm2 to fork it, and therefore pm2 had only control over the npm process, but not the kiwi app itself. To get rid of npm:

  • replace the npm call with the script script: "./src/launch.mjs"
  • add the npm modules to the node path NODE_PATH: "./node_modules"
  • add the -r switch to node_args node_args: "-r dotenv/config --max-old-space-size=XXXX"

Since cluster mode can scale the app, it is important to add instances: 1 to disable scaling.
Another advantage of this approach is, that we now can use max_memory_restart: "XXXXM" to tell pm2 to restart the app when the memory limits are reached.

Enables pm2 to have direct access to the app and to control it better.
@rvolz
Copy link
Contributor Author

rvolz commented Oct 9, 2024

Update: the only change I could see when running the kiwi node in cluster mode was that the main thread caused more system load.

@TimDaub
Copy link
Member

TimDaub commented Oct 17, 2024

This is a great find, thanks!

@TimDaub TimDaub merged commit c050cbf into attestate:main Oct 17, 2024
1 check failed
orkunsahin referenced this pull request Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants