Does PM2 Cluster Mode impact memory overhead when using the max instance setting?
19K reputation · 19 Apr 2022, 15:31 UTC
PM2 Cluster Mode utilizes the Node.js cluster module to distribute incoming connections across multiple worker processes. When the instances property is set to max in an ecosystem file, PM2 spawns a process for every logical CPU core detected on the host machine.
While this maximizes CPU utilization, each worker operates as a separate process with its own memory heap. In environments where CPU core counts are high but available RAM is limited, this scaling strategy may lead to resource exhaustion.
What is the expected memory overhead per worker process when scaling to the maximum number of cores? Does PM2 provide a mechanism to limit the total aggregate memory usage across the cluster without manually specifying a fixed instance count?