Over the last few months, I've been using Node-RED in the context of EVSE (Electric Vehicle Supply Equipment) development.
I'm using Node-RED (v3.0.2) in a Docker container installed in an OEM device.
For context, in the flows I've been developing there are both Modbus and CAN communication with external devices such as Energy Meters, Temperature Sensors, etc.
So far, so good. The problem is that from time to time I notice that Node-RED freezes for a few seconds (somewhere between 2 and 5 seconds).
I've already contacted the manufacturer of the OEM device and reported this problem. We spent several days analyzing my flows and they were able to replicate the same problem on their side.
They said they hadn't detected any problems with CPU or RAM usage and that this was a Node-RED problem.
Over time, I noticed that by simplifying my flows and removing Debug nodes, the number of freezes decreased. However, the problem wasn't completely solved.
I'd like to know if anyone has experienced this problem and if you have any hints as to how can I solve it.
Thank you for your attention.
The flows.... How complicated are they?
Big?
A lot of / many tabs?
What kind of stuff are you showing on the (excuse the pun) Dashboard?
Charts? Graphs?
How much memory does this OEM device have?
How do you know NR is Freezing?
2 - 5 seconds COULD simply be no data is arriving and so there is nothing to show (do?) and so it LOOKS frozen.
Maybe put a flashing LED on the dashboard so you know NR is working.
Have it blink every second.
The flows are not complicated at all. I just initialize flow variables, perform some Modbus/CAN readings and process the information returned. There are around 12 tabs working simultaneously. This behavior even happens with 2 tabs only.
At the moment, I'm not working with a Dashboard, so there are no Charts or Graphs.
These are the main specifications of the OEM device: i.MX 6Quad Core 4 x 1 GHz, 2 GB RAM, 8 GB eMMC
I know that NR is freezing, because I noticed that I was getting Timeouts from time to time in the Modbus readings. I then connected a Modbus sniffer to the bus to check whether it was the devices that were slow to respond or NR that was slow to send the request. In fact, it was the NR that didn't get around to making the reading. So I created a flow where every second I set an LED to blink and every few minutes it would stop blinking. This time coincided with the Timeouts of the Modbus readings.
Initially, yes I was using the Dashboard to check my readings. After validation, I deactivated the Dashboard so as not to have any impact on the problem I'm reporting. I have all the data stored in flow variables.
At the moment, I can't tell you how much memory the OS is using because I don't have access to that information. I'll have to ask the manufacturer.
The OEM device is using Linaro Linux.
Storing all the data in flow variables could be a problem - depending on how much and fast.
You COULD be running out of memory and the machine has to flush stuff.... Or something.
So....
Put a new group on the dashboard and make it a blinking light.
That is all and so shouldn't be much of a load.
Watch if it has any problems in blinking regularly.
When the Dashboard is active, I have about 5 tabs showing only numbers from the Modbus/CAN readings. I don't have any Charts, Graphs or Gauges.
However, in all my tabs in NR I have several variables of Flow and Global type and they are being update every second or even faster depending on the variable in question. This is because I'm developing Object-Oriented and in each flow I communicate with a type of device, I create a structure that can be used in other flows.
How can I check the problem lies with the Flow variables?
There are command line tools that you could execute from node-red to find memory usage. But actually, you probably need to think more about a couple of things:
SWAP - if the OS is causing SWAP space to be used, that can be very slow. I don't think this is the issue but it could be.
Garbage Collection - this is quite a high possibility if you are pushing the node.js stack hard - for example by reorganising large objects. GC can certainly cause a node.js app to pause.
Do you have access to the Node-RED log? If so, you might need to turn up the logging and possibly even turn on audit. This will have a noticeable impact on performance of course but may well help you see where the issue lies.
The problem happens even without the dashboard, I don't understand your point.
I'm storing some data, but I wouldn't say it's enough for the system to run out of memory.
Yes, I'm using arrays but with a fixed size.
As I told you, it is Linaro (Lightweight Linux Distro.).
Thanks for the hints. It could be a good starting point for my problem.
Unfortunately, I don't have access to the Node-RED logs. I've already asked the OEM manufacturer to give me access to the Node-RED logs, as this makes it difficult to detect the issue.
We regularly see posts related to systems with embedded node red that either cannot be updated with the current node-red or do not make vital information accessible to the user. Personally I would not use such a system unless I had no choice. I realise that does not help you though.