| Issue | Severity | Resolution Time |
|---|---|---|
| Node.js PM2 High CPU Usage | Critical / High | 15 – 30 Minutes |

What is node.js pm2 high cpu usage?
Node.js PM2 high CPU usage occurs when a process consumes excessive processor resources, leading to performance degradation or server crashes. It is typically caused by infinite loops, memory leaks, or unoptimized worker threads within the PM2 process manager environment.
Step-by-Step Solutions
1. Identify the Culprit Process
Use the PM2 monitoring dashboard to see real-time CPU and memory metrics for every running process. This helps you isolate which specific application is “overheating” the server.
pm2 monit
2. Analyze Application Logs
Check the error and out logs to find recurring errors or infinite loops that might be pegging the CPU. Logs often reveal specific middleware or functions causing the spike.
pm2 logs [app_name] --lines 100
3. Update PM2 and Node.js
Outdated versions of PM2 or the Node.js runtime can contain performance bugs. Ensure you are running the latest stable versions to benefit from engine optimizations.
npm install pm2@latest -g
pm2 update
4. Check for Memory Leaks
A memory leak often forces frequent Garbage Collection cycles, which spikes CPU usage. Use the Node.js inspector or PM2’s `–max-memory-restart` flag to manage resource-heavy instances.
pm2 start app.js --max-memory-restart 500M
5. Optimize Cluster Mode
If you are running on a multi-core server, ensure PM2 is utilizing Cluster Mode correctly. Distributing the load across multiple instances prevents a single core from hitting 100% usage.
pm2 start app.js -i max