Skip to content

Instantly share code, notes, and snippets.

@seriousManual
Created June 11, 2012 10:01
Show Gist options
  • Save seriousManual/2909389 to your computer and use it in GitHub Desktop.
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).
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 );
}
@seriousManual
Copy link
Author

Console Output:

In the beginning:

10608: sending
0.3034099249634892
10608: sending
0.9507054698187858
10608: sending
0.6182899745181203
12012: sending
0.9408613503910601
12012: sending
0.5858598363120109
12012: sending
0.5070851477794349
12012: sending
0.3285161308012903
12012: sending
0.34158987435512245
12012: sending
0.383258426329121
12012: sending
0.6457101181149483
12012: sending
0.5261366134509444
12012: sending
0.24766160757280886
12012: sending
0.3184074240271002
10608: sending
0.03642082237638533
12012: sending
0.8048785876017064
10608: sending
0.17279384401626885
12012: sending
0.13782942993566394
10608: sending
0.54879603930749
10608: sending
0.6018328433856368
10608: sending
0.1869669291190803

After ~20sec:

10608: sending
10608: sending
10608: sending
12012: sending
12012: sending
12012: sending
12012: sending
10608: sending
10608: sending
10608: sending
10608: sending
12012: sending
12012: sending
12012: sending
12012: sending
10608: sending
10608: sending
10608: sending
10608: sending
12012: sending
12012: sending
12012: sending
12012: sending
12012: sending
12012: sending
12012: sending
12012: sending
12012: sending
12012: sending
12012: sending
12012: sending
12012: sending
12012: sending
12012: sending
12012: sending
12012: sending
12012: sending
10608: sending
10608: sending
10608: sending
10608: sending
12012: sending
12012: sending
12012: sending

The Messages somehow are getting lost...

@srlowe
Copy link

srlowe commented Sep 29, 2014

Hi - did you ever figure this out?

@seriousManual
Copy link
Author

actually no, but they seem to have fixed it: nodejs/node-v0.x-archive#3413

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment