Does the latest Node.js version(4.2.3) supports multi threading now? Hard to find useful answers as most relevant discussions are from years ago.
How would a node.js cloud server handle node.js Web App requests? Say a 2-Core server runs a node.js app, does that mean no matter how heavy the traffic is, they all go through via a single core and the other core is always idle?
If the answer is yes, any recommendations of some third party libs could possibly achieve multi-threading for node.js Web Apps?
Thanks for the helps. In addition to the above question. I adopted the cluster code into an Express.js web app, it turns out the else block is not executed in the below code section. var app = require('../app'); var debug = require('debug')('NewExpress:server'); var http = require('http'); var cluster = require('cluster'); var numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('exit', function(worker, code, signal) {
console.log('worker ' + worker.process.pid + ' died');
});
} else {
/**
* Get port from environment and store in Express.
*/
var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);
/**
* Create HTTP server.
*/
var server = http.createServer(app);
/**
* Listen on provided port, on all network interfaces.
*/
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
}
Any ideas how should I implement cluster in here?