npm and node_index.js high CPU load

Having issues with your DietPi installation or found a bug? Post it here.
User avatar
novitibo
Posts: 120
Joined: Mon Feb 29, 2016 5:11 pm

npm and node_index.js high CPU load

Post by novitibo »

Is there any way to throttle down CPU load for npm and node_index.js?
After Node-red instalation CPU load for those two services is jumping to 100% every 2 seconds. :?
User avatar
Joulinar
Posts: 4830
Joined: Sat Nov 16, 2019 12:49 am

Re: npm and node_index.js high CPU load

Post by Joulinar »

Hi,

you could use tools like cpulimit

https://linoxide.com/linux-how-to/limit ... ses-linux/
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
novitibo
Posts: 120
Joined: Mon Feb 29, 2016 5:11 pm

Re: npm and node_index.js high CPU load

Post by novitibo »

Great idea!
...but how low can we go with that, not to effect node-red too much (I use node-red just for two flows, scheduled for 2 seconds time frame per day)?

Are those two services needed just for node-red or also for some other software from dietpi list?
User avatar
Joulinar
Posts: 4830
Joined: Sat Nov 16, 2019 12:49 am

Re: npm and node_index.js high CPU load

Post by Joulinar »

honestly I don't know. I never used such a tool and usually there is a need for such CPU load. Otherwise the application would not behave like this? I guess you would need to play with it to find fitting values.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
novitibo
Posts: 120
Joined: Mon Feb 29, 2016 5:11 pm

Re: npm and node_index.js high CPU load

Post by novitibo »

ok, I'll try&report here.
Tnx!
User avatar
novitibo
Posts: 120
Joined: Mon Feb 29, 2016 5:11 pm

Re: npm and node_index.js high CPU load

Post by novitibo »

test so far...
root@DietPi:/home/tibo# cpulimit -e node -l 40
Process 31076 detected
Process 31076 dead!
Warning: no target process found. Waiting for it...
Process 31107 detected
Process 31107 dead!
Warning: no target process found. Waiting for it...
Process 31150 detected
Process 31150 dead!
Warning: no target process found. Waiting for it...
Process 31181 detected
Process 31181 dead!
Warning: no target process found. Waiting for it...
Process 31224 detected
Process 31224 dead!
Warning: no target process found. Waiting for it...


it looks like node process changes PID all the time, so cpulimit cannot limit the process only by ID :(
User avatar
Joulinar
Posts: 4830
Joined: Sat Nov 16, 2019 12:49 am

Re: npm and node_index.js high CPU load

Post by Joulinar »

that could mean node is crashing all the the time and restarting? Otherwise I could not imagine why it is changing process id again and again
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
novitibo
Posts: 120
Joined: Mon Feb 29, 2016 5:11 pm

Re: npm and node_index.js high CPU load

Post by novitibo »

you are right.
that explains CPU load jumping.
but what causes that...
strange...
if dietpi-services stop node-red is executed, node and npm does not stop at all...
User avatar
Joulinar
Posts: 4830
Joined: Sat Nov 16, 2019 12:49 am

Re: npm and node_index.js high CPU load

Post by Joulinar »

you could have a look to journalctl -u node-red
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
novitibo
Posts: 120
Joined: Mon Feb 29, 2016 5:11 pm

Re: npm and node_index.js high CPU load

Post by novitibo »

nothing strange there:

Jan 25 22:52:29 DietPi node-red[16635]: 25 Jan 22:52:29 - [info] Stopped flows
Jan 25 22:52:29 DietPi systemd[1]: node-red.service: Succeeded.
Jan 25 22:52:29 DietPi systemd[1]: Stopped Node-RED (DietPi).

npm and node_index.js still high CPU load
Post Reply