title: What is the difference between Child_process and Worker Threads?
body: <p>I am trying to understand <code>Threading</code> in NodeJS and how it works.</p>
  
  <p>Currently what i understand:</p>
  
  <p><strong>Cluster:</strong> -</p>
  
  <ul>
  <li>Built on top of Child_process, but with TCP distributed between clusters.</li>
  <li>Best for distributing/balancing incoming http requests, while bad for cpu intensive tasks.</li>
  <li>Works by taking advantage of available cores in cpu, by cloning nodeJS webserver instances on other cores.</li>
  </ul>
  
  <p><strong>Child_process:</strong> </p>
  
  <ul>
  <li><p>Make use also of different cores available, but its bad since it costs huge amount of resources to fork a child process since it creates virtual memory.</p></li>
  <li><p>Forked processes could communicate with the master thread through events and vice versa, but there is no communication between forked processes.</p></li>
  </ul>
  
  <p><strong>Worker threads:</strong> </p>
  
  <ul>
  <li>Same as child process, but forked processes can communicate with each other using <code>bufferArray</code></li>
  </ul>
  
  <p>1) Why <code>worker threads</code> is better than <code>child process</code> and when we should use each of them?</p>
  
  <p>2) What would happen if we have 4 cores and clustered/forked nodeJS webserver 4 times(1 process for each core), then we used <code>worker threads</code> (There is no available cores) ?</p>