Unusually High CPU Usage on Raspberry Pi 3 at Startup

Hi

I have successfully installed and run Node-RED on many Raspberry Pi systems to date, however my latest install has shown strange CPU activity at start-up.

Following start-up of a clean system build, with no other programmes, no extra nodes and no flows, initially top shows node-red ~200% CPU and 7.0% MEM then after around four minutes it drops to 0.0% CPU and 7.0% MEM. The same high / low sequence occurs every time the system is booted up.

Hardware : Raspberry Pi 3 Model B Plus Rev 1.3
OS : Linux 11 (bullseye) / 32 bit
Node-RED Core : 3.1.0
Node : v18.18.0
Npm : 9.8.1

the image was flashed using Raspberry Pi Imager v1.7.4 (I have tried with both HDD and SD - same result).

Installation sequence from new image:

sudo apt-get update
sudo apt-get upgrade
sudo reboot now
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
sudo systemctl enable nodered.service
sudo reboot now

I am no expert, but syslog does not seem to show any issues. A filtered dump using COMMAND=Node-RED looks normal to me...

Oct 10 13:04:52 Apollo systemd[1]: Started Node-RED graphical event wiring tool.
Oct 10 13:04:57 Apollo Node-RED[359]: 10 Oct 13:04:57 - [info]
Oct 10 13:04:58 Apollo Node-RED[359]: Welcome to Node-RED
Oct 10 13:04:58 Apollo Node-RED[359]: ===================
Oct 10 13:04:58 Apollo Node-RED[359]: 10 Oct 13:04:57 - [info] Node-RED version: v3.1.0
Oct 10 13:04:58 Apollo Node-RED[359]: 10 Oct 13:04:57 - [info] Node.js version: v18.18.0
Oct 10 13:04:58 Apollo Node-RED[359]: 10 Oct 13:04:57 - [info] Linux 6.1.21-v7+ arm LE
Oct 10 13:05:01 Apollo Node-RED[359]: 10 Oct 13:05:01 - [info] Loading palette nodes
Oct 10 13:05:05 Apollo Node-RED[359]: 10 Oct 13:05:05 - [info] Settings file : /home/pi/.node-red/settings.js
Oct 10 13:05:05 Apollo Node-RED[359]: 10 Oct 13:05:05 - [info] Context store : 'default' [module=memory]
Oct 10 13:05:05 Apollo Node-RED[359]: 10 Oct 13:05:05 - [info] User directory : /home/pi/.node-red
Oct 10 13:05:05 Apollo Node-RED[359]: 10 Oct 13:05:05 - [warn] Projects disabled : editorTheme.projects.enabled=false
Oct 10 13:05:05 Apollo Node-RED[359]: 10 Oct 13:05:05 - [info] Flows file : /home/pi/.node-red/flows.json
Oct 10 13:05:05 Apollo Node-RED[359]: 10 Oct 13:05:05 - [info] Creating new flow file
Oct 10 13:05:05 Apollo Node-RED[359]: 10 Oct 13:05:05 - [warn] Encrypted credentials not found
Oct 10 13:05:05 Apollo Node-RED[359]: 10 Oct 13:05:05 - [info] Starting flows
Oct 10 13:05:05 Apollo Node-RED[359]: 10 Oct 13:05:05 - [info] Started flows
Oct 10 13:05:05 Apollo Node-RED[359]: 10 Oct 13:05:05 - [info] Server now running at http://127.0.0.1:1880/

I only have one Raspberry Pi 3 available so cannot swap out the hardware but I tried sudo memtester 500 1 which didn't show any failures. It is worth noting though that the issue does not occur when installing the same clean build on a Pi 4!

Any thoughts?

What image did you flash with?

Looking at the log, it only took 8 seconds to start up.

Do you have anything else installed ?

Are you running the desktop version of the OS?

If running the desktop version, you could run the configurator and set it to boot to the command line and see if you have issues then

Hi zenofmud and thank you for your reply. Regarding your questions...

Raspberry Pi OS Lite (32bit) - bullseye

The installation described above had nothing installed apart from Node-RED (with no additional nodes and no flows). The installation sequence above lists the only commands executed after the Pi powered up with a new image. The ~4 minute high processor usage was observed by executing top as soon as I logged on after reboot.

No - Lite. It is headless. All installation / configuration is from a command line.

To check, I've just disabled Node-RED Autostart on Boot, re booted and run node-red-start. Seems to take approximately 7 seconds to start up...

Starting as a systemd service.
11 Oct 15:53:59 - [info]
Welcome to Node-RED

11 Oct 15:53:59 - [info] Node-RED version: v3.1.0
11 Oct 15:53:59 - [info] Node.js version: v18.18.0
11 Oct 15:53:59 - [info] Linux 6.1.21-v7+ arm LE
11 Oct 15:54:02 - [info] Loading palette nodes
11 Oct 15:54:05 - [info] Dashboard version 3.6.0 started at /ui
11 Oct 15:54:06 - [info] Settings file : /home/pi/.node-red/settings.js
11 Oct 15:54:06 - [info] Context store : 'default' [module=memory]
11 Oct 15:54:06 - [info] User directory : /home/pi/.node-red
11 Oct 15:54:06 - [warn] Projects disabled : editorTheme.projects.enabled=false
11 Oct 15:54:06 - [info] Flows file : /home/pi/.node-red/flows.json
11 Oct 15:54:06 - [warn] Encrypted credentials not found
11 Oct 15:54:06 - [info] Server now running at http://127.0.0.1:1880/
11 Oct 15:54:06 - [info] Starting flows
11 Oct 15:54:06 - [info] Started flows

Apart from the CPU anomaly at start up, the system seems to be running fine. I have subsequently proceeded to install Plex Media Server, Samba, three Node-RED nodes and a flow. All seems ok!
I have attached two screenshots from top. One immediately after start up (~200% CPU) the other ~4 minutes later. Now that Node-RED is doing "something" top shows CPU varying between 1.3% and 7.6%.

Although all seems well, I am just a bit nervous that the CPU anomaly at start up could indicate a problem which may cause issues in the future!

What happened if you shutdown NR and start with node-red dummy.flow?
This will create an empty flow.

Node RED has been installed on much much lower spec pieces of hardware!
unless you do something in your flows like an insane endless data loop - I really wouldn't worry.

I don't see node-red in that top, did it start ok?

I'd so, how big is your original flow?

Noted and thank you. I guess I don't like anomalies! I have other (older) systems and have checked them - CPU usage "normal" at start up; Raspberry Pi 4 - CPU usage "normal" at start up. Either something is different with or has changed within the OS or Node-RED re. Raspberry Pi 3 or I am doing something wrong. Just like to know.

If this is with a blank flow - I guess its "normal" :man_shrugging: , if you actually have flows, then you can export said flow, and we may be able to spot something - especially if you have inject nodes that fire at start up.

Yes it did start ok and the editor shows one empty flow.

Node-RED seems to come and go from the top list, I guess top ignores processes that aren't using resources(?). Here is htop output...

The flow is quite big (how big is big?). I use it on all of my Pi projects (including Pi Zero) to produce a dashboard showing system status...

This screenshot is how I noticed the CPU usage issue! Do note however, the issue manifested itself on an installation with NO additional nodes and no flows using top / htop to display CPU%

How do I post a flow on the forum?

Top right menu

```
JSON Here
```

Then we can import the flow - remember to remove anything sensitive (like API keys and alike)

Don't seem to have the right menu item???
In any case, the issue manifested itself on an installation with NO additional nodes and no flows. I can't see how my flow would have caused the problem.

Screenshot 2023-10-11 201551

Sorry - I thought you mean how to export a flow.
but I wouldn't worry if its with a blank flow

Sorry I didn't get back to you earlier, our three year old granddaughter fell asleep on my lap.

This should help:

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```)

``` 
   code goes here 
```

You can edit and correct your post by clicking the pencil :pencil2: icon.

See this post for more details - How to share code or flow json

Ok so either I am going mad or someone is playing tricks behind the (Raspberry Pi OS) scene!

I slept on the problem overnight and came up with a few things to try. Interestingly, four rebuilds later (with SD, HDD and a few build sequence changes) Node-RED installed perfectly every time! There was no excessive CPU usage on any of the builds.

HOWEVER in each build syslog was missing. Searching showed the file did not exist. Indeed /var/log/ contained very few files at all compared with similar builds. e.g. no kern.log, messages, auth.log, etc. I do not know what all of these file are for but seems to me that they ought to be there.

What I have discovered is that the image downloaded via Raspberry Pi Imager has changed from bullseye to bookworm between 9/10/23 (High CPU Usage) and today (Normal CPU Usage). Hmm.

There are differences in the nodered-install.log's generated between those dates showing this change of OS including the appearance of the line...

W: http://raspbian.raspberrypi.com/raspbian/dists/bookworm/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.

I've no idea whether this is significant or not!

In (my) conclusion the change of OS fixed the Node-RED issue but introduced the total lack of system logging.
O Joy!

Apparently rsyslog is not enabled in bookworm (google will bring up numerous references if you need it). So the log files are not generated. The 'solution' is to learn how to use journalctl for displaying logs. journalctl has been available for a long time. node-red-log, for example, uses it for displaying the node red log. Alternatively I expect it is possible to install and enable rsyslog.

Ah. Thanks for that. Looks like I have some learning to do!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.