pm2 icon indicating copy to clipboard operation
pm2 copied to clipboard

PM2 (some processes in cluster) using 100% CPU in cluster mode

Open sherryt400 opened this issue 7 years ago • 5 comments

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 image

sherryt400 avatar Jun 11 '19 02:06 sherryt400

same issue with me, after cpu 100%, it will no process any request. i am not able to heapdump.

marutichintan avatar Jun 29 '19 05:06 marutichintan

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.

lrebelo avatar Sep 04 '19 13:09 lrebelo

First get to know how many CPU you have in your server, sudo lshw | grep -i cpu

  1. I suggest your update & upgrade to latest packages for your targeted OS, remove obsolete packages too
  2. Upgrade pm2 by pm2 update
  3. 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.

aungzanbaw avatar Oct 04 '19 04:10 aungzanbaw

In my case it was bad regular expression I was using in my code. So I reverted that and everything is ok now.

sherryt400 avatar Dec 02 '19 08:12 sherryt400

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.

stale[bot] avatar May 23 '20 22:05 stale[bot]