Incorrect number of threads shown from node.js os.cpus() when clustering in AWS EC2

329
July 08, 2017, at 3:40 PM

Is there a way to get access to all 324 threads in the AWS c4.8xlarge instance from node.js? Is there another way to get the number of threads besides os.cpus() ?

We are using a CPU-optimized AWS instance of size c4.8xlarge which has 36 virtual CPUs each with 9 cores, which is a total of 324 threads (36 x 9).

When we run this script to measure the number of threads, it shows 36, but it does not show any information about the 9 cores on each vCPU.

 const cluster = require('cluster');
 const numCPUs = require('os').cpus().length;
 if (cluster.isMaster) {
   console.log(`Master ${process.pid} is running`);
   // Fork workers.
   for (let i = 0; i < numCPUs; i++) {
     cluster.fork();
   }
   cluster.on('exit', (worker, code, signal) => {
     console.log(`worker ${worker.process.pid} died`);
   });
 } else {
     console.log("Number of cores: " + numCPUs);
     process.exit(0);
 }

This is a problem because we run this script on another machine that has 1 CPU and 8 hyper-threaded cores and it reports 16 CPUs (which is correct).

Answer 1

According to various sources (including a blog article on Amazon's site), a 'c4.8xlarge' has 18 hyperthreaded cores, totalling 36 vCPUs (which are hyperthreaded cores).

Rent Charter Buses Company
READ ALSO
How can I pass value out of anonoymous function [duplicate]

How can I pass value out of anonoymous function [duplicate]

This question already has an answer here:

247
Mongodb: Invalid Command error

Mongodb: Invalid Command error

I'm developing web application using node js and mongo dbInitially I got this error - failed to connect to [localhost:27017]

426
Using sequelize and mysql, unable to update stuff

Using sequelize and mysql, unable to update stuff

I am making an app that includes updating posts from the pastThere is a separate page for this and a route to go with it

337
Express validator: how to skip validation when I get blank string otherwise check if mongoId?

Express validator: how to skip validation when I get blank string otherwise check if mongoId?

I'm using Express validator package to validate data coming from client, what I want to do is validate a "_id" parameter only if it's not blank ?

353