title: How to verify Cluster working in node js?
body: <p>I am new to nodejs and currently playing with its features, one of the important feature I came across is <strong>Cluster</strong>, I tried to implement that for my sample application using expressjs, angular and nodejs.</p>
  
  <p>Cluster code:</p>
  
  <pre><code>var cluster = require('cluster');
  
  if (cluster.isMaster) {
      var cpuCount = require('os').cpus().length;
      for (var i = 0; i &lt; cpuCount; i += 1) {
          cluster.fork();
      }
  } else {
      var express = require('express');
      var app = express();
      var exportRouter=require('./routers/exportRouter');
      var process = require('process');
  
      fakeDB = [];
      app.use(express.static(__dirname + '/public'));
      app.use(require('./routers/exportRouter.js'));
  
      console.log('process Id :',process.pid);
      app.listen(3000, function(){
          console.log('running on 30000');    
      });
  }
  </code></pre>
  
  <p>I have added following code in my routers to block the event loop,so when I make first request It will block one nodejs worker. so if another user makes call while first node is blocked second worker should pick that up.</p>
  
  <p>router code : </p>
  
  <pre><code>var express = require('express');
  var exportRouter = express.Router();
  var process = require('process');
  
  exportRouter.get('/getMe',function(req,res){
      console.log('I am using process   ',process.pid);
      console.log('get is called');
      fakeDB.push(req.query.newName+' '+ process.pid);
      res.send(req.query.newName + ' ' + process.pid);
      console.log('New name received   ',fakeDB);
  
  
      console.log('New name received   ',fakeDB);
      var d = new Date().getTime();
      console.log('old ',d)
  
      var x = d+10000;
      console.log('should stop post ',x);
      while(true){
  
          var a = new Date().getTime();
          //console.log('new ',a)
           if(x&lt;a){
              break;
           }
      }
      console.log('I am releasing event loop for ',process.pid);
  
  });
  
  module.exports = exportRouter;
  </code></pre>
  
  <p>it does not serve other request using another worker and waits for blocked node worker.. BTW I am using node js version 0.12.7(64bit) and 4 cpus.</p>
  
  <p>THanks in advance..</p>