Skip to content

Instantly share code, notes, and snippets.

@kkemple
Created November 26, 2014 01:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkemple/ef88b1eee150bad367ca to your computer and use it in GitHub Desktop.
Save kkemple/ef88b1eee150bad367ca to your computer and use it in GitHub Desktop.
node clustering (to maximize cpu usage)
'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