Similar questions have been asked, as to why a nodejs cluster forking only delegates to one worker on a windows machine. We know the answer is that the RR algorithm is disabled on windows, but so then, how can you enable it?
I have a hint:
1) https://stackoverflow.com/a/43971478/8804567
The Docs say " cluster.schedulingPolicy can also be set through the NODE_CLUSTER_SCHED_POLICY environment variable. Valid values are 'rr' and 'none' "
I'm wondering where exactly do I make this configuration. The code:
const cluster = require('cluster');
const http = require('http');
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();
}
} else {
// Workers sharing same TCP connection
http.createServer((req, res) => {
console.log(`worker ${process.pid} working`);
res.writeHead(200);
res.end('hello world\n');
}).listen(2019);
console.log(`Worker ${process.pid} started`);
}
Any help, guidance or comments in relevancy are very much appreciated, seriously!
Thanks community!