Created
June 11, 2012 10:01
-
-
Save seriousManual/2909389 to your computer and use it in GitHub Desktop.
replicating process.send not working anymore. after a while messages sent from worker do not reach the master instance when under heavy load (~7000req/s).
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
var cluster = require( 'cluster' ) | |
,http = require( 'http' ); | |
if ( cluster.isMaster ) { | |
for (var i = 0; i < 8; i++) { | |
var worker = cluster.fork(); | |
worker.on( 'message', function() { | |
console.log( Math.random() ); | |
} ); | |
} | |
} else { | |
http.createServer(function (req, res) { | |
process.nextTick( function() { | |
process.send( {} ); | |
console.log( process.pid + ': sending' ); | |
res.end( 'hello :) ' ); | |
} ); | |
} ).listen( 1337 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi - did you ever figure this out?