Skip to content

Instantly share code, notes, and snippets.

@abdulhannanali
Created May 16, 2016 17:43
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 abdulhannanali/b3c0b8f9036fbc02e9a72a3a26132413 to your computer and use it in GitHub Desktop.
Save abdulhannanali/b3c0b8f9036fbc02e9a72a3a26132413 to your computer and use it in GitHub Desktop.
Too many things in your mind at same time, use Clustering in Node.js to solve this issue
/*
* brainworkers.js
* Having non-blocking IO code is good but you still are single threaded
* and are not built for this fast internet world of 21st Century
* this code is for you.
*/
const mindClusters = require("cluster");
const yourMind = require("brain");
const numBpus = yourMind.bpus().length;
if (mindClusters.isMaster()) {
for (var i = 0; i < numBpus; i++) {
mindClusters.fork();
}
}
else {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment