Skip to content

Instantly share code, notes, and snippets.

@OrdinaryJellyfish
OrdinaryJellyfish / cluster.js
Created Sep 18, 2018
Simple Cluster example for Node.js
View cluster.js
const cluster = require('cluster')
const numCPUs = require('os').cpus().length
if (cluster.isMaster) {
console.log(`Master ${process.pid} is running`)
// Basic Multi-process Functionality
for (let i = 0; i < numCPUs; i++) {
cluster.fork()
}