public
Created

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).

  • Download Gist
gistfile1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
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 );
}

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...

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.