Created
November 26, 2014 01:31
-
-
Save kkemple/ef88b1eee150bad367ca to your computer and use it in GitHub Desktop.
node clustering (to maximize cpu usage)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var cluster = require('cluster'); | |
if (cluster.isMaster) { | |
var cpuCount = require('os').cpus().length; | |
for (var i = 0; i < cpuCount; i++) { | |
cluster.fork(); | |
} | |
cluster.on('exit', cluster.fork); | |
} else { | |
require('./server'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment