0
가능한 중복 : Node.js를 이후
node.js on multi-core machinesNode.js를 singler 스레드 모델
레버리지 여러 개의 코어를 Node.js를 할 수있는 방법, 단일 스레드 모델을 사용한다? 다중 코어를 사용하지 않고도 CPU 사용량이 충분하지 않다고 생각합니다. 맞습니까?
가능한 중복 : Node.js를 이후
node.js on multi-core machinesNode.js를 singler 스레드 모델
레버리지 여러 개의 코어를 Node.js를 할 수있는 방법, 단일 스레드 모델을 사용한다? 다중 코어를 사용하지 않고도 CPU 사용량이 충분하지 않다고 생각합니다. 맞습니까?
당신은 핵심 cluster 모듈을 사용할 수 있습니다
var cluster = require('cluster');
var http = require('http');
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 {
// Workers can share any TCP connection
// In this case its a HTTP server
http.createServer(function(req, res) {
res.writeHead(200);
res.end("hello world\n");
}).listen(8000);
}
http://stackoverflow.com/a/8685968 –