pm2 running at 100% CPU - how to debug
Asked Answered
B

0

8

Last couple of weeks, I am struggling with pm2 100% CPU usage which hangs my node server.

I tried reading logs but I didn't find any issue there.

My node version: 6.9.1
PM2 is : 2.4.4.
OS: Ubuntu 14.04
On an average my cpu usage is : ~5

Manually I am restarting all apps - pm2 restart all.

pm2.log: fluid_admin@instance-2:~$ tail -15 .pm2/pm2.log

2017-04-12 09:55:30: Starting execution sequence in -fork mode- for app name:fluid-prod id:0
2017-04-12 09:55:30: App name:fluid-prod id:0 online
2017-04-14 13:53:21: Stopping app:fluid-prod id:0
2017-04-14 13:53:21: Stopping app:nedbserver id:1
2017-04-14 13:53:21: App [nedbserver] with id [1] and pid [32557], exited with code [0] via signal [SIGINT]
2017-04-14 13:53:21: pid=32574 msg=failed to kill - retrying in 100ms
2017-04-14 13:53:21: pid=32557 msg=process killed
2017-04-14 13:53:21: Starting execution sequence in -fork mode- for app name:nedbserver id:1
2017-04-14 13:53:21: App [fluid-prod] with id [0] and pid [32574], exited with code [0] via signal [SIGINT]
2017-04-14 13:53:21: App name:nedbserver id:1 online
2017-04-14 13:53:21: pid=32574 msg=process killed
2017-04-14 13:53:21: Starting execution sequence in -fork mode- for app name:fluid-prod id:0
2017-04-14 13:53:21: App name:fluid-prod id:0 online

App is running on GAE, OS is : Ubuntu 14.04.

My CPU usage when PM2 is high

I have moved from forever to pm2 6 months back. till recent time, it was working file but now I am frequently having this issue.

I don't know deal this problem. Can some one help me how to debug this issue.

It happened again. Output of TOP commands PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
25059 fluid_a+ 20 0 1260364 105532 8236 R 99.7 17.5 58:27.27 node fluid/server/tools/www + 1 root 20 0 33520 3208 1792 S 0.0 0.5 0:04.82 /sbin/init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 [kthreadd]

Script to start my app:

pm2 stop fluid-prod pm2 start \ -n fluid-prod \ -e /path/to/fluid-error.log \ -o /path/to/fluid-out.log \ $(dirname $0)/www -- --max-memory-restart 200M --env=production

Breen answered 15/4, 2017 at 3:15 Comment(8)
are you using chokidar or watching file system changes?Kimberli
No. pm2 ls says watching is disabled for all my projects.Breen
Please post your pm2.json file or whatever you use to run it. This problem sometimes is connected to the "watch" for file changes. If you have "watch" set, disable it, then check. If not we need to see exactly the parameters you are using to run PM2Elizebethelizondo
# pm2 management pm2 stop fluid-prod pm2 start \ -n fluid-prod \ -e /home/fluid_admin/production/fluid-error.log \ -o /home/fluid_admin/production/fluid-out.log \ $(dirname $0)/www -- --max-memory-restart 120M --env=productionBreen
It happened again. Please help me debug this.Breen
@Breen I"m having the same issue with PM2 when all my CPUs are at 100%. Have you managed to fix it?Glazunov
Have you check memory usage when CPU i higth compared when it 's normal?Tiphani
Also, have you check if your logs increse in size during High CPU usage compared to normal?Tiphani

© 2022 - 2024 — McMap. All rights reserved.