I am seeing really poor distribution of connections across a "cluster".

For example (count of connections served on left, PID on right):
$ node test.js | awk '/connection/{print$2}' | sort | uniq -c
    438 4687
    300 4688
   1008 4690
    293 4692
    671 4693
   3939 4697
   1026 4698
   2325 4699

This is on linux 2.6.32 with node 0.8.4.

Is this expected behavior?

Each connection is outputting a short string.
$ nc localhost 8765
Howdy there!

The distribution above is across 10,000 connections.
$ seq 10000 | xargs -n1 -I@ -P8 nc localhost 8765 > /dev/null

This is the source for "test.js".
'use strict';

var cluster = require('cluster');
var net = require('net');
var workerCount = 8;

if (cluster.isMaster) {
  for (var i = 0; i < workerCount; ++i) {
    cluster.fork().on('online', function() {
      console.log('Worker ' + this.process.pid + ' online.');
    }).on('exit', function(code, signal) {
      console.log('Worker ' + this.process.pid + ' died (code:' + code +
          ', signal:' + (signal || 'none') + ').');
    });
  }
} else {
  var server = net.createServer(function(stream) {
    console.log('Worker ' + process.pid + ' received connection.');
    stream.end('Howdy there!\n', 'ascii');
  });

  server.listen(8765, function() {
    console.log('Worker ' + process.pid + ' listening.');
  });
}

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to