Created
May 16, 2016 17:43
-
-
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
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
/* | |
* 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