Created
June 13, 2016 02:51
-
-
Save tanner0101/ca7aa7f639c291f05a10e570a0cc739c to your computer and use it in GitHub Desktop.
Express Benchmark
This file contains hidden or 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
var cluster = require('cluster'); | |
if(cluster.isMaster) { | |
var cpuCount = require('os').cpus().length; | |
for(var i = 0; i < cpuCount; i += 1) { | |
cluster.fork(); | |
} | |
cluster.on('exit', function(worker) { | |
console.log('Worker %d died, replacing', worker.id); | |
cluster.fork(); | |
}); | |
} else { | |
var app = require('./app.js'); | |
app.app.listen(app.port, function() { | |
console.log('Benchmarking worker %d listening on %d', cluster.worker.id, app.port) | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment