Skip to content

Instantly share code, notes, and snippets.

Anthony Ettinger chovy

Block or report user

Report or block chovy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@learncodeacademy
learncodeacademy / cluster.md
Created Oct 9, 2014
Node Cluster - Enhance your node app by using all the cores of your processor.
View cluster.md

Here's all you have to do to add clustering to your node.js application.

  • save this code as cluster.js, and run cluster.js instead of server.js (or /bin/www, or whatever it's called for your project)
  • the only line you'll need to change is the last line - it needs to point to the location of your server.js file
var cluster = require('cluster');

if (cluster.isMaster) {
  // Count the machine's CPUs
  var cpuCount = require('os').cpus().length;
You can’t perform that action at this time.