By default, Node.js cluster module uses a round-robin approach in the master process to distribute incoming connections among workers.
const cluster = require('cluster'); if (cluster.isMaster) { // create worker }
The correct method to create a worker is cluster.fork(). Other methods do not exist in the cluster API.
The blocking while loop in each worker delays response handling, causing some workers to be busy longer. This leads to uneven load because requests queue up on busy workers.
The master process forks two workers, so cluster.workers has two keys. The length of these keys is 2.
Custom load balancing can improve performance by sending requests to the least busy workers, optimizing CPU and memory usage beyond simple round-robin.
