Node-RED freezes for a few seconds

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.

Best regards,
Gonçalo Cruz

Hi and welcome.

Ok, you declared which NR you are using.

Good.

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.

That MAY help determining where the problem is.

Good luck.

What do you mean by node-red freezing?

Hello and thank you for replying.

To answer your questions:

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.

Hello and thank you for replying.

Please check my answer to @Trying_to_learn.

Ok, so what are you looking at to see data?

For clarity: dashboard is the GUI side of Node-red in this instance.

8GB ram seems ok. But there again: How much memory does the OS use?

Which OS is on the OEM device?
I'm hoping/guessing Ubuntu/Linux flavor?

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.

Ok.

But it is a kind of Double edged sword.

How much Dashboard stuff is shown - when active?

As example.

Charts, graphs, gauges, what?

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?

I only suggested that as if you say you have no dashboard and it is not locking up in that mode...

And are storing things in flow context (flow variables).

If you are storing TOO MUCH data you will/COULD run out of memory.

Is the data stored in arrays or is it just simple stuff like batteryVoltage, and that kind of stuff?

I'm just trying to think of ways to see what the OEM device is doing with memory too.

So is it Ubuntu or ....?

you could maybe try htop (if you can get it installed) and run it to see what's happening under the hood of the device.

@Trying_to_learn the guy can tell the server is pausing because the LED stops flashing. It is nothing to do with the dashboard.

@goncalo.cruz if you disable all flow tabs, except one with the led flashing does it still pause? I presume you mean a real led, not a dashboard led.

I suggested a dashboard LED - node. (Or any other thing)

It shouldn't be too much of a load and could be an indication if the program/machine is not flowing smoothly.

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.

1 Like

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.).

It is to see if Node-Red is running smoothly or not.

I am at the bottom of the barrel for ideas on what to do.

Hello Colin.

If I disable all flow tabs, except the one with the LED blinking, it seems that it doens't pause. And yes, I meant a real LED and not a Dashboard LED.

Seems @TotallyInformation has explained what I was trying to say a lot better.

That is good, it suggests something in your flows is causing the freeze. Enable it a bit at a time till you find the culprit.

Hello @TotallyInformation and thank you for replying.

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.