A container-friendly alternative to os.cpus().length. Both cgroups v1 and cgroups v2 are supported.

Overview

node-cpu-count

A container-friendly alternative to os.cpus().length. Both cgroups v1 and cgroups v2 are supported.

Installation

$ npm install node-cpu-count

Usage

cpuCount(min = 1, max = os.cpus().length): Promise<number>

Get available logical CPU count (CPU quota / CPU period for cgroups, fallback to os.cpus().length).

It always returns an integer by ceiling the result. The result can be used as the number of cluster workers.

min or max can be specified to determine the minimal and the maximum CPU count (which also overrides the fallback value).

cpuCountSync(min = 1, max = os.cpus().length): number

A synchronous version of cpuCount.

Examples

$ git clone https://github.com/lujjjh/node-cpu-count.git && cd node-cpu-count

$ docker run --rm -it -v $(pwd):/app node node /app/examples
8
8

$ docker run --rm -it -v $(pwd):/app --cpus=2 node node /app/examples
2
2

$ docker run --rm -it -v $(pwd):/app --cpus=2.1 node node /app/examples
3
3
You might also like...

The officially supported cloud storage plugin for Payload CMS.

Payload Cloud Storage Plugin This repository contains the officially supported Payload Cloud Storage plugin. It extends Payload to allow you to store

Dec 21, 2022

An obsidian plugin that allows code blocks executed interactively in sandbox like jupyter notebooks. Supported language rust、kotlin、python、Javascript、TypeScript etc.

An obsidian plugin that allows  code blocks executed interactively in sandbox like jupyter notebooks. Supported language rust、kotlin、python、Javascript、TypeScript etc.

Obsidian Code Emitter This plugin allows code blocks executed interactively like jupyter notebooks. Currently, support languages: Rust Kotlin JavaScri

Dec 28, 2022

A simple emotion picker that displays all the supported GitHub emojis :octocat:.

A simple emotion picker that displays all the supported GitHub emojis :octocat:.

github-emoji-picker A simple Emoji picker that displays all the emojis that GitHub supports. It is automatically generated from GitHub Emoji API and U

Dec 27, 2022

The invoker based on event model provides an elegant way to call your methods in another container via promisify functions

The invoker based on event model provides an elegant way to call your methods in another container via promisify functions. (like child-processes, iframe, web worker etc).

Dec 29, 2022

Container Image Signing & Verifying on Ethereum [Testnet]

Container Image Signing & Verifying on Ethereum [Testnet]

cosigneth An experimental decentralized application for storing and verifying container image signatures as an NFT on Ethereum cosigneth, is a decentr

Jul 4, 2022

Mailbox is the predictable states & transitions container for actors.

Mailbox is the predictable states & transitions container for actors.

Mailbox (turns XState Machine into a REAL Actor) Mailbox is an NPM module built on top of the XState machine, by adding a message queue to the XState

Aug 24, 2022

ContainerMenu is an API for BDSX that allows you to create fake interactive container menus !

ContainerMenu is an API for BDSX that allows you to create fake interactive container menus !

ContainerMenu - A BDSX API ContainerMenu is an API for BDSX that allows you to create fake interactive container menus ! Features Multiple containers

Oct 28, 2022

Pin any element within a container

jQuery.pin Ever wanted to pin something to the side of a text? Ever needed a subtle sticky element to quietly hang around as you scroll down? Jquery.P

Nov 30, 2022

Public repository of assets used during editions of AWS LATAM Container Roadshow event.

LATAM Containers Roadshow This is the official repository of assets related to LATAM Containers Roadshow, an all-day customer-facing event to highligh

Dec 6, 2022
The app's backend is written in Python (Flask) and for search it uses Elasticsearch. I used this app as candidate application for learning out how to build, run and deploy a multi-container environment (docker-compose).

foodtrucks-app-docker-compose The app's backend is written in Python (Flask) and for search it uses Elasticsearch. I used this app as candidate applic

Selçuk Şan 3 Oct 24, 2022
Sheetzapper imports your account value accross Zapper.fi supported wallets and dapps into a Google Sheet

Overview Sheetzapper imports your account value accross Zapper.fi supported wallets and dapps into a Google Sheet. This allows you to chart your net w

null 4 Nov 27, 2022
A decentralized protocol for indexing and querying data from DecentraMix's on chain contracts across all supported blockchains.

A decentralized protocol for indexing and querying data from DeMix contracts across all supported blockchains.

DecentraWorld Ecosystem 92 May 3, 2022
Jugglr is a tool for managing test data and running tests with a dedicated database running in a Docker container.

Jugglr Jugglr is a tool for managing test data and running tests with a lightweight, dedicated database. Jugglr enables developers, testers, and CI/CD

OSLabs Beta 74 Aug 20, 2022
A docker container with a wide variety of tools for debugging and setting up micro-services

Frame One Software Placeholder There are numerous times during the dev ops deployments, that a placeholder container is needed. In the past, Frame One

Frame One Software 8 May 29, 2022
Make text fit container, prevent overflow and underflow.

AutoTextSize Make text fit container, prevent overflow and underflow. The font size of the text is adjusted so that it precisely fills its container.

Sana Labs 10 Dec 30, 2022
A website for detecting name of bank from card number, supported all Iranian banks

Detect Iranian Bank Web A website for detecting name of bank from card number, supported all Iranian banks. This package contains SVG logo and brand c

Max Base 12 Oct 2, 2022
Multiple `.env` file supported.

Features Support multiple .env files and keep the inheritance Priority: local > not unassigned local mode > not unassigned mode e.g. .env.{{mode}}.loc

Tianyu Li 67 Oct 31, 2022
An Eleventy wrapper for type supported configurations

Shareable Eleventy configuration strap. The module can be dropped in to your .eleventy.js configuration file for Typed supported configuration options.

ΝΙΚΟΛΑΣ 5 Jun 17, 2022
automatic poits grabber for twitch, works with all supported langauges on twitch

Twitch Points Grabber It’s an extension for edge, is aviable in the microsoft Edge Add-ons. This extension will collect any channel points. Settings I

Claudio Menegotto 3 Nov 28, 2022