<p>Right now I am struggling with debugging of NodeJs application which is clustered and is running on Docker. Found on this <a href="https://www.docker.com/blog/keep-nodejs-rockin-in-docker/" rel="nofollow noreferrer">link</a> and this information in it:</p>
<blockquote>
<p>Remember, Node.js is still single-threaded in most cases, so even on a
single server you’ll likely want to spin up multiple container
replicas to take advantage of multiple CPU’s</p>
</blockquote>
<p>So what does it mean, clustering of NodeJs app is pointless when it is meant to be deployed on Kubernetes ?</p>
<ol>
<li>EDIT: I should also say that, by clustering I mean forking workers with <code>cluster.fork()</code> and goal of the application is to build simple REST API with high load traffic.</li>
</ol>

Juraj Zovinec
<p>Short answer is yes..</p>
<p>Containers are just mini VM's and kubernetes is the orchestration tool that manages all the running 'containers', checking for health, resource allocation, load etc.</p>
<p>So, if you are running your node application in a container with an orchestration tool like kubernetes, then clustering is moot as each 'container' will be using 1 CPU or partial CPU depending on how you have it configured. Multiple containers essentially just place a new VM in rotation and kubernetes will direct traffic to each.</p>
<p>Now, when we talk about clustering node, that really comes into play when using tools like PM2, lets say you have a beefy server with 8 CPU's, node can only use 1 per instance so tools like PM2 setup a cluster and will route traffic along each of the running instances.</p>
<p>One thing to keep in mind though is that your application needs to be cluster OR container ready. Meaning nothing should be stored on the ephemeral disk as with each container restart that data is lost OR in a cluster situation there is no guarantee the folders will be available to each running instance and if you cluster with multiple servers etc you are asking for trouble :D ( this is where an object store would come into play like S3)</p>
