Determining backend memory limit from container cgroup#588
Determining backend memory limit from container cgroup#588lognaturel merged 1 commit intogetodk:nextfrom
Conversation
|
Oops, branched off an old |
042e9de to
feefa39
Compare
|
Thanks so much for fixing the memory limit check! I'm surprised to see the issue related to pm2 workers. I see 4 node processes on the 2Gb servers I checked. Everything else was stock when you identified that problem? |
|
Hmm if that's the case, then further debugging is required! I wonder how pm2.config.js would be able to determine 4 workers from process.env, as setting without an export would mean the variable is not available in process.env. I tested this as part of my dev setup for working on Central, using I use the Dockerfiles and compose file from this repo, with the certs set to |
|
Also, updated my original comment to explain the rationale for adding the WORKER_COUNT as a configurable environment variable. It's especially important if running in Kubernetes. |
|
I just tested this on a temp cloud machine: The 4 workers started up. Now I'm puzzled why they don't start on my WSL Debian instance. Either way, this functionality seems to work fine currently, so there is no concern than this will cause users to go from 1 --> 4 workers on their deployment. Adding |
|
That's very strange! I'd prefer to split out the new env var, please:
Once that's split off the mem calculation change is ready to merge. |
feefa39 to
b786c92
Compare
|
Completely agree - PID 1 ideally shouldn't fork processes. Done 👍 |
|
Thank you! Good discussion all around. I'm glad you're liking the ideas at #347 (comment) 👍 |

Closes #577
* Original Comment *
Includes
WORKER_COUNTvariable instart-odk.sh, otherwise the value is not respected (see screenshots).pm2.config.jsusesprocess.env.WORKER_COUNT, but the variable is only available in the bash shell, not the pm2 command (it needs to be exported for that).vmstatcommand gets the total available memory on the host system.WORKER_COUNTfor the backend service.WORKER_COUNT..env.templateso users know it's an option.thento the same line asif(in line with shellcheck and bashate linter recommendations).Screenshots
Before: 4 workers determined, but only one runs
Log:

System info:

After: 4 workers determined, 4 workers run
Log:

System info:

What has been done to verify that this works as intended?
Why is this the best possible solution? Were any other approaches considered?
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Does this change require updates to documentation? If so, please file an issue here and include the link below.
WORKER_COUNTenvironment variable is available.Before submitting this PR, please make sure you have:
nextbranch OR only changed documentation/infrastructure (masteris stable and used in production)* Updated Comment *
WORKER_COUNTenv var configuration, as a better approach is running one process per container.