title: What is Node.js cluster best practice?
body: <p>Is it better to write our server logic before forking workers or after?</p>
  
  <p>I'll give two examples below to make it clear.</p>
  
  <p>example #1:</p>
  
  <pre><code>const express = require("express");
  const cluster = require('cluster');
  const app = express();
  
  app.get("/path", somehandler);
  
  if (cluster.Master)
    // forking workers..
  else
    app.listen(8000);
  </code></pre>
  
  <p>or example #2:</p>
  
  <pre><code>const cluster = require('cluster');
  
  if (cluster.Master)
    // forking workers..
  else {
    const express = require("express");
    const app = express();
  
    app.get("/path", somehandler);
  
    app.listen(8000);
  }
  </code></pre>
  
  <p>What is the difference?</p>