title: How many events can socket.io handle?
body: <p>I was trying Socket.io (server and client) for my personal project. As it is my first try with node.js even javascript and mongodb I am bit confused about performance of my server.</p>
  
  <p>I have created a complex real time system with many events and many rooms. Server have very limited events but clients have too many events. These events are distributed under rooms. </p>
  
  <p>For example - </p>
  
  <ul>
  <li><p>Room R1 >>
  Event R1E1,
  Event R1E2,
  Event R1E3....
  Event R1EN</p></li>
  <li><p>Room R2 >>
  Event R2E1,
  Event R2E2,
  Event R2E3....
  Event R2EN</p></li>
  </ul>
  
  <p>All the data is stored in mongodb. Working awesome.</p>
  
  <p>But issue arise when few clients (5-8) with 10-15 events registered start sending data. Server initially works fine but after couple of minutes it stops responding. Clients stay connected even server is not responding.  Requests are pile up. Sometime server receive last sessions request.</p>
  
  <p>It all start when the ultimate device start registering events. <strong>So I want to know how many events a socket.io can handle ?</strong></p>
  
  <p><strong>P.S.</strong> Here what I think "event" is -</p>
  
  <pre><code>io.on('event', function(msg){
      console.log( msg);
  });
  </code></pre>
  
  <p><strong>Edit 2</strong></p>
  
  <p>As I studied about node.js, a node is basically a process which runs on a single thread, if it requires to process other things it starts another node (an async thread), leaves new thread alone doing it's process and return to main thread running. If we want to process some sequences of process we use "async/await". </p>
  
  <p>In my case I am using async at only one place when client first connect. Here I query 3 different collections of mongodb and return the data on an event.</p>
  
  <p>My server is currently running on a MacBook pro (16 GB RAM, i7 6th gen quad core). It should handle at least 4-6 concurrent threads.</p>
  
  <p>I have created a load test, 100000 different events distributed under 1000 rooms with 5 request per second querying db. It was working fine. Almost 40% RAM and 250% CPU was max laod.</p>
  
  <p>My connection to db is persistent mean I connect to db as soon as server starts and keep that connection reference alive.</p>
  
  <p><strong>So what is the issue?</strong></p>