Node.js + socket.io determine maximum amount of clients per instance

I am asked to perform rough calculation of how many connections can single socket.io instance handle on a large EC2 instance (16Gb Ram, 4 Core Xeon).

I updated sample of simple socket.io benchmark.

Serever:

var io = require('socket.io').listen(80);
var exec = require('child_process').exec; 

io.configure(function() {
  io.set('log level', 1);

  var transport = process.argv.length >= 2 ? process.argv[2] : null;
  if (transport) {
    io.set('transports', [transport]);
  }
});

var payload = "Payload: Payload line item " +
"Payload: Payload line item " +
"Payload: Payload line item " +
"Payload: Payload line item " +
"Payload: Payload line item " +
"Payload: Payload line item " +
"Payload: Payload line item " +
"Payload: Payload line item " +
"Payload: Payload line item " +
"Payload: Payload line item " +
"Payload: Payload line item " +
"Payload: Payload line item " +
"Payload: Payload line item " +
"Payload: Payload line item " +
"Payload: Payload line item " +
"Payload: Payload line item " +
"Payload: Payload line item " +
"Payload: Payload line item " +
"Payload: Payload line item ";

var users = 0;

function roundNumber(num, precision) {
  return parseFloat(Math.round(num * Math.pow(10, precision)) / Math.pow(10, precision));
}

setInterval(function() { 
  io.sockets.emit("message", payload);
  console.log("Users: " + users);
}, 3000);

io.sockets.on('connection', function(socket) {

  users++;  

  socket.on('disconnect', function() {
    users--;
  })
});

Client

var io = require('socket.io-client');

var message = "o bispo de constantinopla nao quer se desconstantinopolizar";

var receivedMessages = 0;

function user(shouldBroadcast, host, port) {
  var socket = io.connect('http://' + host + ':' + port, {
    'force new connection': true
  });  

  socket.on("message", function(){    
    receivedMessages += 1;
  })
};

var argvIndex = 2;

var users = parseInt(process.argv[argvIndex++]);
var rampUpTime = parseInt(process.argv[argvIndex++]) * 1000; // in seconds
var newUserTimeout = rampUpTime / users;
var shouldBroadcast = process.argv[argvIndex++] === 'broadcast' ? true : false;
var host = process.argv[argvIndex++] ? process.argv[argvIndex - 1]  : 'localhost';
var port = process.argv[argvIndex++] ? process.argv[argvIndex - 1]  : '3000';

for(var i=0; i<users; i++) {
  setTimeout(function() { user(shouldBroadcast, host, port); }, i * newUserTimeout);
};

setInterval(function() {

 console.log("Messages received: " + receivedMessages);
 receivedMessages = 0;

}, 3000);

I ran this sample, client was started on medium instance, server on large. And I got result amount of received messages around 4500 per 3 seconds.

But the network, cpu and ram usage was in range of 2-10%.

Is it possible to increase the number of served connections?

Server OS is Windows Server 2008 R2.

It's most likely the latency between your client and server, and it could also be a limitation on the the number of outgoing connections from your client, and the OS limit on incomming connections on your server. Be aware that windows have a way lower limit than other operating systems.

Also you would expect the CPU, RAM and bandwidth usage to be low, since the operation you are doing is neither calculation, ram or bandwidth heavy.

Please look at Apache Bench as a way of testing your server, instead of writing a client which may or may not be an optimal implementation: https://en.wikipedia.org/wiki/ApacheBench

In any case, use more client computers, from different networks, so you can rule our local switches or routers as bottlenecks