Skip to content

Run on specified processor cores #50541

Discussion options

You must be logged in to vote

Node.js itself does not provide a built-in way to set processor affinity.

on windows you can use start command along with the affinity option to launch your programs with the specified CPU affinity.
for example if you want ot run 3 different Node.js programs on separate groups of 8 cores, you can use the following commands in a batch file or directly in the cmd:

start /affinity 0xFF node program1.js
start /affinity 0xFF00 node program2.js
start /affinity 0xFF0000 node program3.js

Here's what the affinity masks mean:

  • 0xFF corresponds to the first 8 cores (cores 0 to 7).
  • 0xFF00 corresponds to the next 8 cores (cores 8 to 15).
  • 0xFF0000 corresponds to the last 8 cores (cores 16 to 23).

In P…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by borodadada
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants