PM2 (some processes in cluster) using 100% CPU in cluster mode
What's going wrong?
I am using PM2 in cluster mode in 16 v-cores CPU with 16 instances. Out of 16 some of instances are using 100% CPU
How could we reproduce this issue?
I have read some issues related CPU usage problem but none of their solutions helped. I am attaching my pm2 process json file
{
"apps" : [{
"script" : "./bin/server.js",
"instances" : 16,
"exec_mode" : "cluster"
}]
}
Supporting information
PM2 version 3.5.0 Node version 9.11.1 Ubuntu Linux 16.04 x64
Here is Screen Shot

same issue with me, after cpu 100%, it will no process any request. i am not able to heapdump.
very close to this, but mine are not in cluster mode but I have 99 instances x 10 servers of the same application running (slightly different pm2 files for each) and after a few days(it varies from 7 to 20) the pm2 GOD will go full CPU hog(100%) and I can't do any pm2 commands or any linux command beyond reboot & top.
In some cases I have been able to stop all the pm2 clients with pm2 stop all but it does not help, the god process still consumes 100% cpu even though no process is 'active'.
The only solution so far is to restart the servers every week during (what is now) planned downtime.
First get to know how many CPU you have in your server,
sudo lshw | grep -i cpu
- I suggest your update & upgrade to latest packages for your targeted OS, remove obsolete packages too
- Upgrade pm2 by
pm2 update - According to your server spec start pm2 with cluster mode
pm2 start server.js -i 2
Number 2 in this context assume you have have 2 CPUs, you can do max for maximum utilization of your server. pm2 start server.js -i max. Try restart the server after that.
In my case it was bad regular expression I was using in my code. So I reverted that and everything is ok now.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.