Search code examples
node.jsprocessor

Any benefits when clustering node.js application server in single core computer


This question is meant for single core only therefore multiple cores are out.

I am running Node.js application as HTTP server on single core computer using Express.js. Assuming that my server is able to handle 1000 concurrent requests, would clustering brings about any better in response speed ?

Does process context switch has much impact on performance in this case ?


Solution

  • would clustering brings about any better in response speed ?

    You are aware of the fact that in clustered mode, your application will be running behind a load balancer, that will in turn take some CPU and memory to manage and forward the network traffic. Then, what's left of the resources, will be used to distribute the network load.

    Apart from a few, rare and easily avoidable cases such as @Cristyan mentions—in which case your load balancer can be an orchestrator managing most of the stuff, like Kubernetes—running a Node.js app in cluster does not make sense to me, on a single CPU core. If the process has to wait for an item, it has to wait for it! Asynchronously you can make it work on other requests, but even in this case, other processes would want to take a share of CPU too.