Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.54k stars 2.62k forks source link

pm2 using 100% CPU #4853

Closed DudeThatsErin closed 1 year ago

DudeThatsErin commented 4 years ago

What's going wrong?

When running 1 pm2 start command CPU usage jumps from 15% to 60-100%+ usage. I was running 5 all night and it consistently stayed around 104%.

How could we reproduce this issue?

Run 1 of the pm2 start commands and check CPU usage.

Supporting information

--- PM2 report ----------------------------------------------------------------
Date                 : Sun Sep 13 2020 14:25:53 GMT+0000 (Coordinated Universal Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 4.4.1
node version         : 10.19.0
node path            : /usr/local/bin/pm2
argv                 : /usr/bin/node,/usr/local/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : root
uid                  : 0
gid                  : 0
uptime               : 2min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 4.4.1
node version         : 10.19.0
node path            : /usr/local/bin/pm2
argv                 : /usr/bin/node,/usr/local/bin/pm2,report
argv0                : node
user                 : root
uid                  : 0
gid                  : 0
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : AMD EPYC 7601 32-Core Processor
cpus nb              : 1
freemem              : 66519040
totalmem             : 1028882432
home                 : /root
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬──────────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name                 │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼──────────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │ applecard-modmail    │ default     │ N/A     │ fork    │ 12432    │ 2m     │ 0    │ online    │ 0.1%     │ 11.2mb   │ root     │ disabled │
└─────┴──────────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/root/.pm2/pm2.log last 20 lines:
PM2        | 2020-09-13T14:07:33: PM2 log: pid=660527 msg=process killed
PM2        | 2020-09-13T14:07:33: PM2 log: PM2 successfully stopped
PM2        | 2020-09-13T14:22:56: PM2 log: ===============================================================================
PM2        | 2020-09-13T14:22:56: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
PM2        | 2020-09-13T14:22:56: PM2 log: Time                 : Sun Sep 13 2020 14:22:56 GMT+0000 (Coordinated Universal Time)
PM2        | 2020-09-13T14:22:56: PM2 log: PM2 version          : 4.4.1
PM2        | 2020-09-13T14:22:56: PM2 log: Node.js version      : 10.19.0
PM2        | 2020-09-13T14:22:56: PM2 log: Current arch         : x64
PM2        | 2020-09-13T14:22:56: PM2 log: PM2 home             : /root/.pm2
PM2        | 2020-09-13T14:22:56: PM2 log: PM2 PID file         : /root/.pm2/pm2.pid
PM2        | 2020-09-13T14:22:56: PM2 log: RPC socket file      : /root/.pm2/rpc.sock
PM2        | 2020-09-13T14:22:56: PM2 log: BUS socket file      : /root/.pm2/pub.sock
PM2        | 2020-09-13T14:22:56: PM2 log: Application log path : /root/.pm2/logs
PM2        | 2020-09-13T14:22:56: PM2 log: Worker Interval      : 30000
PM2        | 2020-09-13T14:22:56: PM2 log: Process dump file    : /root/.pm2/dump.pm2
PM2        | 2020-09-13T14:22:56: PM2 log: Concurrent actions   : 2
PM2        | 2020-09-13T14:22:56: PM2 log: SIGTERM timeout      : 1600
PM2        | 2020-09-13T14:22:56: PM2 log: ===============================================================================
PM2        | 2020-09-13T14:22:56: PM2 log: App [applecard-modmail:0] starting in -fork mode-
PM2        | 2020-09-13T14:22:56: PM2 log: App [applecard-modmail:0] online

Please copy/paste the above report in your issue on https://github.com/Unitech/pm2/issues

I am trying to get help on Reddit & Discord as well and this is what I posted there... tl;dr Linode & Vultr CPUs go to 100% while running pm2 without --watch... Any ideas why? i think it is kubernetes as that seems to be top 1 & 2 items and I didn't install it so it seems like pm2 uses kubernetes. So, I have narrowed down my 100% CPU usage to pm2 using kubernetes: https://kubertnetes.io/

I updated PM2 just now and it is still at 100%. If I uninstall PM2, My CPU usage drops down to 20-30%. This originally happened on my Vultr VPS so one of the reasons why I left is because they couldn't/wouldn't help me fix this and I was trying to uninstall kubernetes and couldn't. So, I moved to Linode. No issues with linode until installing pm2 and running anything without the --watch command. It makes no sense.

If I uninstall pm2, my CPU usage drops to 20-30% from 104-106%. I don't want to get charged for this extra CPU usage. :/

I've done exhaustive google searches (and will continue until this is fixed). I have updated pm2. I have tried updating kubernetes or uninstalling it but I always get some version of this:

root@localhost:~# kubeadm upgrade node

Command 'kubeadm' not found, but can be installed with:

snap install kubeadm

Any idea why this is?

Here is my htop: https://prnt.sc/ugbxo9

Also, this is my pm2 list... as you can see all of these show 0% CPU usage. https://prnt.sc/ugc2lb

raphaelluiz128 commented 4 years ago

I confirm it. Please help. In one day later it's is 10 to 14%, but now is in the most time it's 70% to 100%. I sleep in one day later and in the next day when i use my computer i observed it.