# Advice needed on Pi CPU usage

**URL:** <https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279>\
**Category:** General\
**Created:** [27 March 2021 12:13 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279 "2021-03-27T12:13:16Z")\
**Posts on this page:** 20\
**Page:** 5

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [11 April 2021 12:27 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/82 "2021-04-11T12:27:06Z")

</div>

Apologies for the backticks... I'm still a bit dumb here!!

Like this?: `Testing` ... Just learnt something - Thanks!!!!

> [@TotallyInformation](#):
>
> You do need to start taking out nodes with TCP or UDP connections one at a time until you track down the issue.

Would Disabling them be sufficient, or, would disabling the flow that they are on also suffice?

Tia  
E

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [11 April 2021 12:29 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/83 "2021-04-11T12:29:41Z")

</div>

> [@eddee54455](#):
>
> Like this?: `Testing` ... Just learnt something - Thanks!!!!

And this:

```auto
` ` `
some code - but without the spaces between the ticks of course
` ` `

```

> [@eddee54455](#):
>
> Would Disabling them be sufficient, or, would disabling the flow that they are on also suffice?

It should be enough. Though to be safe, you could export the single node then delete it. You can reimport later, just use a sensible naming convention for the saved files.

For nodes that use configuration nodes though, don't forget about those.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [11 April 2021 12:33 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/84 "2021-04-11T12:33:30Z")

</div>

Are you seeing thousands of lines altogether?  
If there are thousands then there might be indications as to what is using them all up.  
Feel free to PM the file to me if you want me to have a look but don't want to make it public.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [11 April 2021 12:34 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/85 "2021-04-11T12:34:56Z")

</div>

The problem with disabling, for example MQTT is that it will presumably dramatically change what happens as there will be no data, so whatever is the problem may no longer happen, even if it is not directly related to the MQTT comms.

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [11 April 2021 13:01 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/86 "2021-04-11T13:01:57Z")

</div>

Seeing Lots.... (Not understanding much, but seeing lots nevertheless!!)

Not worried about sending here, nothing incriminating that I can see in it!

[Colin.txt](https://discourse.nodered.org/uploads/short-url/5pDbSIBRnQH6TYU5c6tU77eEBuy.txt) (979.8 KB)

Here you go!!

Ed

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [11 April 2021 13:04 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/87 "2021-04-11T13:04:30Z")

</div>

Yes, I know. But it should show which node is causing the issue. A case of trial and error since there appear to be no other clues at this time.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [11 April 2021 13:10 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/88 "2021-04-11T13:10:24Z")

</div>

Ouch! You have a LOT running there. MySQL, Apache, REDIS, Pure-FTP, some kind of Python server, some kind of PHP server. But you are also running a Linux desktop and a remote VNC session. That is a lot of load even for a 4GB Pi4.

But the node entries are the most interesting. The many TCP sockets are clearly the problem. That doesn't appear to be related to MQTT. So something else is creating the sockets.

Can you please share with us, all of the node types you have installed and all the ones that you have instances of in use? You can process the flows file to get that.

* * *

Hmm, and don't forget that if you are using a MySQL node, that is creating connections as well - in fact, that would be my guess as to what is causing the issues.

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [11 April 2021 13:15 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/89 "2021-04-11T13:15:11Z")

</div>

Before I go B to the W and start disabling things... Does this look "generally ok"?

![screenshot-192.168.0.118_1880-2021.04.11-15_08_28](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/2/a20ecb78255b779c2e90479a0c48624e6dee0e36.png)

 ![screenshot-192.168.0.118_1880-2021.04.11-15_09_06](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/f/efd1717d1b40a89347056b2eddb099f481d1c00e.png)

And looking at this:  
 ![screenshot-192.168.0.118_1880-2021.04.11-15_07_14](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/3/a3aeaefd79608ad6c530016a6ca3ddc7ddc4251f.png)

Particularly the number behind that little mosquito.... It might take me a while!!

Ta  
E

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [11 April 2021 13:21 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/90 "2021-04-11T13:21:52Z")

</div>

> [@TotallyInformation](#):
>
> Ouch! You have a LOT running there. MySQL, Apache, REDIS, Pure-FTP, some kind of Python server, some kind of PHP server. But you are also running a Linux desktop and a remote VNC session. That is a lot of load even for a 4GB Pi4.

It is.... but.... in defence, I have kept strict tabs on CPU/Mem/Swap use.... CPU around 20% avg, mem around 30% avg, swap 0% normally... or very low... The Pi is "perky" to say the least and more than quick on average!

> [@TotallyInformation](#):
>
> Can you please share with us, all of the node types you have installed and all the ones that you have instances of in use? You can process the flows file to get that.

Would be glad to! Could you give me a pointer as to what is needed to process the flows file?

Regds  
E

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [11 April 2021 13:22 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/91 "2021-04-11T13:22:29Z")

</div>

Did you see my comment about MySQL as well?

What is "chronos"?

Yes, you certainly have your work cut out I'm afraid. But I don't see any way around it.

By the way, you will get a better picture from `lsof` if you do `lsof | grep "^node"` as that shows you all of the connections that Node-RED is doing and will show some more detail. Alternatively, use `sudo lsof -c node` to see the connections opened by the node process or `sudo lsof -p 14996` (there is a lot more you can do: [lsof(8) - Linux manual page (man7.org)](https://man7.org/linux/man-pages/man8/lsof.8.html).

I think that, if we want to dig deeper on these connections, we need to use `netstat` next.

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [11 April 2021 13:30 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/92 "2021-04-11T13:30:40Z")

</div>

> [@TotallyInformation](#):
>
> Did you see my comment about MySQL as well?

I did, Logging for Emoncms if I remember correctly... (Cleared all data about a week back, maybe a bit longer, no difference to stability per se... The data files went back 3 or more years, 4gb, now a couple of weeks old and sitting at 130Mb)

> [@TotallyInformation](#):
>
> What is "chronos"?

Pretty much just a "Time Based Filter":

 ![screenshot-192.168.0.118_1880-2021.04.11-15_27_28](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/e/0efc9321e53969d5430279a7220f534374955ceb.png)

 ![screenshot-192.168.0.118_1880-2021.04.11-15_29_37](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/a/6a4e567f11bc4d93ac7f55246d7236ee9b66bda4.png)

Just sends me a reminder based on the time...  
E

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [11 April 2021 13:36 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/93 "2021-04-11T13:36:36Z")

</div>

Hopefully you only have the one mqtt connection set up like that - otherwise if you have multiple with the same clientID (InvPI) then they will knock each other off the broker - which would then lead to a lot of hanging tcp sockets. If in doubt don't set the clientID and let the system randomly assign one.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [11 April 2021 13:39 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/94 "2021-04-11T13:39:24Z")

</div>

Sorry, I keep updating my comments - see my update on using netstat.

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [11 April 2021 13:42 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/95 "2021-04-11T13:42:04Z")

</div>

Yep, its only the one client.... It was set as no clientID originally (earlier today) and I "tied it down" to this setting, in case it was a problem... No difference though...

Tnx  
E

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [11 April 2021 13:43 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/96 "2021-04-11T13:43:58Z")

</div>

> [@TotallyInformation](#):
>
> I think that, if we want to dig deeper on these connections, we need to use `netstat` next.

No problem at all!!.... I am just uber grateful for all the help!!

Just point me in the direction to go!!

Tia  
Ed

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [11 April 2021 14:01 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/97 "2021-04-11T14:01:27Z")

</div>

First of all, make sure you've checked out Dave's last post and corrected that if it applies. If it does, you can ignore everything else probably.

Other wise, lets try starting with `sudo netstat -ap` - likely to produce a LOT of data so feed it to a file. See if you can spot the same socket connections. You may be able to match the `I-Node` number in this output to the inode column in your previous file output from lsof. For example "28721882". I don't have any open sock entries on any of my systems so I can't test that for you.

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [11 April 2021 14:32 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/98 "2021-04-11T14:32:24Z")

</div>

Ok...Waaaaaaay past being out of my depth here.... Sorry...

I hope I have done this right... I dumped them to two files....

[Tif.txt](https://discourse.nodered.org/uploads/short-url/hmTbgST53bZZWlIAWcMcyb8kLLf.txt) (193.4 KB) [Tif2.txt](https://discourse.nodered.org/uploads/short-url/ndmRt8SCaF6DgUWfypiVlWaeMfJ.txt) (360.0 KB)

Had a look into them ..... and uhhhh..... I'm the monkey with the Macbeth book....

E

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [11 April 2021 14:58 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/99 "2021-04-11T14:58:39Z")

</div>

And here is a list of nodes in use in all flows at the moment(According to Pallette):

```auto
Nodes in use (According to Pallette):

node-red
    change
    comment
    debug
    delay
    exec
    function
    inject
    json
    link in
    link out
    mqtt in
    mqtt out
    mqtt-broker
    split
    join
    status
    switch
    trigger

node-red-contrib-advanced-ping
node-red-contrib-bigtimer
node-red-contrib-chronos
    chronos-config
    chronos-filter
node-red-contrib-cpu
node-red-contrib-isonline
node-red-contrib-mqtt-json
node-red-contrib-moment
    moment
node-red-contrib-os
node-red-contrib-schedex
node-red-contrib-string
node-red-contrib-telegrambot
node-red-contrib-toggle
node-red-contrib-ui-led
node-red-contrib-ui-multistate-switch
node-red-dashboard
    ui_base
    ui_button
    ui_dropdown
    ui_gauge
    ui_group
    ui_numeric
    ui_slider
    ui_spacer
    ui_switch
    ui_tab
    ui_text
    ui_text_input
    ui_toast
node-red-node-emoncms
node-red-node-openweathermap
node-red-node-pi-gpio
node-red-node-ping
node-red-node-rbe
node-red-node-smooth

```

In response to the nodes in use.....

E

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [11 April 2021 15:20 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/100 "2021-04-11T15:20:24Z")

</div>

I see you are using an ancient, effectively undocumented, contrib node for MQTT -  
node-red-contrib-mqtt-json. I would ditch that for a start. You can get the same effect with the standard MQTT node by selecting the output as parsed JSON in the node config. There has been a lot of work on MQTT in the last three years.

Uninstall that node after you have moved everything over.

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [11 April 2021 15:25 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/101 "2021-04-11T15:25:59Z")

</div>

Thanx Colin... Will start doing it now.... Hold thumbs!! (About 130 nodes to replace...Maybe a few more, maybe a few less...)

[Previous page](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279.md?page=4)

[Next page](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279.md?page=6)
