Skip to content

Implementing horizontal scaling in Node.js project

Course: Horizontal and vertical scaling, Indexes in DBs - chapter 3

You can start multiple node projects then? If there are 8 cores, then just start 8 projects?

node index.js
node index.js
node index.js
node index.js
node index.js
node index.js
node index.js
node index.js

This, ofcourse has a lot of problems

  1. Just ugly to do this, keep track of the processes that are up and down
  2. Processes will have port conflicts, you’ll have to run each process on a saparate port

This is where the cluster module comes into the picture

$1b

Notice different pids in different devices

Browser

Postman

Curl

💡 Try to figure out why there is stickiness in the browser. Why the request from the same browser goes to the same pid