An open API service indexing awesome lists of open source software.

https://github.com/xiaoxiaojx/get_cpus_length

Get os.cpus().length to match Linux container CPU quota.
https://github.com/xiaoxiaojx/get_cpus_length

cluster containers cpus k8s kubernetes nodejs

Last synced: 2 months ago
JSON representation

Get os.cpus().length to match Linux container CPU quota.

Awesome Lists containing this project

README

        

# get_cpus_length

Get os.cpus().length to match Linux container CPU quota.

```diff
const getCpusLength = require("get_cpus_length");

+ console.log("CpusLength: ", getCpusLength());
- console.log("CpusLength: ", require("os").cpus().length);
```

## Installing
NPM Version
```bash
npm install get_cpus_length
```
or
```bash
yarn add get_cpus_length
```

## why
When your kubernetes is set up [Resource Management for Pods and Containers](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/), this problem occurs [Not correct os.cpus().length inside the docker container with cpus limited. #28762](https://github.com/nodejs/node/issues/28762).