title: clustering in node.js is not working. Only one worker is always responding
body: <p>I am practising clustering in node.js I am having a two core CPU. I created two workers and each worker runs a simple http server. Server response callback will block for 5 sec to give next request to other worker. To verify workers are working parallel, I have opened multiple tabs in Firefox and refreshed each. problem is always(99%) only one worker is responding requests that was make by refreshing tabs. Only one request is being served by one worker and all other requests are blocked until that worker is finished. My code is here
  CODE:</p>
  
  <pre><code>var cluster = require('cluster');
  var http = require('http');
  
  
  
  if (cluster.isMaster) {
      var cpus = require('os').cpus().length;
      console.log('No of cpus:' + cpus);
      console.log(require('os').cpus());
  
      for (var i = 0; i &lt; cpus; i++) {
          cluster.fork();
      }
  
      cluster.on('fork', function(worker) {
          console.log('worker:' + worker.id + " is forked");
      });
      cluster.on('online', function(worker) {
          console.log('worker:' + worker.id + " is online");
      });
      cluster.on('listening', function(worker) {
          console.log('worker:' + worker.id + " is listening");
      });
      cluster.on('disconnect', function(worker) {
          console.log('worker:' + worker.id + " is disconnected");
      });
      cluster.on('exit', function(worker) {
          console.log('worker:' + worker.id + " is dead");
      });
  
  } else {
      http.createServer(function(req, res) {
  
          console.log('worker:' + cluster.worker.id + " going to send response ");
          res.writeHead(200);
          res.end("hello world. worker: " + cluster.worker.id);
          var stop = new Date().getTime();
          while (new Date().getTime() &lt; stop + 5000) {;
          }
      }).listen(8000);
  }
  </code></pre>
  
  <p>OUTPUT:</p>
  
  <pre><code>20 Aug 00:36:11 - [nodemon] restarting due to changes...
  20 Aug 00:36:12 - [nodemon] starting `node cluster.js`
  No of cpus:2
  [ { model: 'Intel(R) Core(TM)2 Duo CPU     E4500  @ 2.20GHz',
      speed: 2200,
      times: { user: 2264671, nice: 0, sys: 698343, idle: 5965109, irq: 98812 } },
    { model: 'Intel(R) Core(TM)2 Duo CPU     E4500  @ 2.20GHz',
      speed: 2200,
      times: { user: 2466000, nice: 0, sys: 502562, idle: 5959203, irq: 4609 } } ]
  worker:1 is forked
  worker:2 is forked
  worker:2 is online
  worker:1 is online
  worker:2 is listening
  worker:1 is listening
  worker:1 going to send response
  worker:1 going to send response
  worker:1 going to send response
  worker:1 going to send response
  worker:1 going to send response
  worker:1 going to send response
  worker:1 going to send response
  worker:1 going to send response
  worker:1 going to send response
  worker:1 going to send response
  worker:1 going to send response
  worker:1 going to send response
  worker:1 going to send response
  worker:1 going to send response
  worker:1 going to send response
  worker:1 going to send response
  worker:1 going to send response
  worker:1 going to send response
  worker:1 going to send response
  worker:1 going to send response
  </code></pre>
  
  <p>I have noticed one thing. If I force reload(ctrl+f5) the tab, then both workers is responding one after other.
  OUTPUT:</p>
  
  <pre><code>worker:1 going to send response
  worker:2 going to send response
  worker:1 going to send response
  worker:2 going to send response
  worker:1 going to send response
  worker:2 going to send response
  worker:1 going to send response
  worker:2 going to send response
  worker:1 going to send response
  worker:2 going to send response
  worker:1 going to send response
  worker:2 going to send response
  worker:1 going to send response
  worker:2 going to send response
  worker:1 going to send response
  worker:2 going to send response
  worker:1 going to send response
  worker:2 going to send response
  worker:1 going to send response
  worker:2 going to send response
  worker:1 going to send response
  worker:2 going to send response
  worker:2 going to send response
  worker:1 going to send response
  worker:2 going to send response
  worker:1 going to send response
  worker:2 going to send response
  worker:1 going to send response
  worker:2 going to send response
  </code></pre>
  
  <p>I am confused what,s happening here for normal refresh(f5) and force reload( ctrl + f5 ). help me to figure it out...!</p>