Wrong cpu count in lxd environment

According to reference docs, each container is provided with 2 vCpus. However when we run nproc or any other command to get cpu count, it is greater than 2.

Below are cpu counts displayed by nproc:

Travis CI - Test and Deploy with Confidence

s390x: 4
ppc64le: 8
arm64: 32

This leads to OOM kill for nodejs build & test tools which by default depend on cpu counts for parallel threads.

Example:

Travis CI - Test and Deploy with Confidence

che-thiea builds: here arm & ppc builds fail with OOM kill. The build uses lerna & jest tools which by default creates concurrent threads equal to number of cpus and there is no easy way to limit it.

Note: Most of nodejs build & test tools depend upon nodejs’s os library to get cpu counts which internally reads this information from procfs.

Not correct os.cpus().length inside the docker container with cpus limited. · Issue #28762 · nodejs/node · GitHub

1 Like