<p>Node.js has introduced the Cluster module to scale up applications for performance optimization. We have Kubernetes doing the same thing.</p>
<p>I'm confused if both are serving the same purpose? My assumption is clustering can spawn up to max 8 processes (if there are 4 cpu cores with 2 threads each) and there is no such limitation in Kubernetes.</p>

Rajneesh Mishra
<p>Kubernetes and the Node.js <a href="https://nodejs.org/api/cluster.html" rel="nofollow noreferrer">Cluster module</a> operate at different levels.</p>
<p>Kubernetes is in charge of orchestrating containers (amongst <em>many</em> other things). From its perspective, there are resources to be allocated, and deployments that require or use a specific amount of resources.</p>
<p>The Node.js Cluster module behaves as a load-balancer that forks N times and spreads the requests between the various processes it owns, all within the limits defined by its environment (CPU, RAM, Network, etc).</p>
<p>In practice, Kubernetes has the possibility to spawn additional Node.js containers (scaling horizontally). On the other hand, Node.js can only grow within its environment (scaling vertically). You can read about this <a href="https://en.wikipedia.org/wiki/Scalability#Horizontal_(scale_out)_and_vertical_scaling_(scale_up)" rel="nofollow noreferrer">here</a>.</p>
<p>While from a performance perspective both approaches might be relatively similar (you can use the same number of cores in both cases); the problem with vertically scaling <em>on a single machine</em> is that you lose the high-availability aspect that Kubernetes provides. On the other hand, if you decide to deploy several Node.js containers on different machines, you are much more tolerant for the day one of them is going down.</p>
