title: Benchmarkt socket.io
body: <p>I want to benchmark my socket.io server. I want to test how many parallel connections and messages  the server can handle.</p>
  
  <p>But my socket.io server crash after some minutes when I start the benchmark with about 200 websockets.</p>
  
  <p>I tried to use the cluster module of node.js to share the process to the cores. When I use the cluster module some connections become disconnected after some time.</p>
  
  <p>The server that I use for the test is a virtual server on the amazon cloud with this properties:</p>
  
  <ul>
  <li>7 GB of memory</li>
  <li>20 EC2 Compute Units (8 virtual cores with 2.5 EC2 Compute Units each)</li>
  <li>1690 GB of instance storage</li>
  <li>64-bit platform</li>
  <li>I/O Performance: High</li>
  <li>API name: c1.xlarge</li>
  </ul>
  
  <p>Here is the code of the benchmark-client:</p>
  
  <pre><code>var fs = require('fs');
  var io = require("socket.io-client");
  var host = "http://localhost:3000";
  var timeLog = fs.createWriteStream(__dirname+'/public/time.log',{flags:'a',mode:0666,   encoding:'encoding'});
  var count = 200;
  var sockets = [];
  var total = 0;
  var countTime = 0; 
  var echo = exports;
  echo.start = function() {
      fs.writeFile('public/time.log',"",function(err){
          if(err) throw err;
      });
  
      for(var i=0;i&lt;count;i++){
          var socket = io.connect(host,{"force new connection":true});
          sockets.push(socket);
          //console.log(i);
          socket.on("message",function(message){
              countTime++;
              time = new Date().getTime()-message;
              total+=time;
              timeLog.write(time+"\n");
              socket.send(new Date().getTime());
          });
          socket.on("disconnect",function(){
              console.log("disconnect");
          });
      }
  
      parallelSockets();
      var j = 0;
  }
  
  function parallelSockets(){
      for(var i = 0 ;i&lt;count;i++){
          sockets[i].send(new Date().getTime());
      }
  }
  </code></pre>
  
  <p>And here the code of the socket.io-server:</p>
  
  <pre><code>socket.on('message',function(message){
      start = new Date().getTime();
      socket.send(message);
      end = new Date().getTime() - start;
      logfile.write(end+"\n");
  });
  </code></pre>
  
  <p>Is there any security mechanisms on socket.io that blocks so many parallel messages and connections form a client?</p>
  
  <p>Can anybody help me?</p>