Headless Node Red Instance?

I think I know the answer to how to setup a headless instance of node red, but? Disable the admin API, Dashboard, and Editor. Am I forgetting anything? The node red instance will just execute a canned set of flows, publish status information, once setup, would not need the editor, dashboard, etc. Anything else that should be disabled?

why disable the admin API?

I came across of few references suggesting disable of the admin API as part of the over all strategy to lock down a node-red instance. Hence why I asked the question... What is the best practice for creating a headless or secure instance of node-red that runs flows and little else, i.e. no UI elements, no access other than what can be done via MQTT communication as part of said flows.

Set httpAdminRoot to null in your settings file and none of the admin side of things will be exposed.

Ah just that... and disable to the editor? To create a lite instance of node-red?

That is in the documentation I seem to remember. Never done it myself so I don't remember the details off the top of my head.

Sorry, missed your follow-up question. The Editor is part of the admin api - setting httpAdminRoot to null will disable the whole lot.

It depends what you mean by lite. It disables functionality but that is all, I believe. All the code is still there, just not doing anything.

Just disable of function is sufficient for what I want or need, anything that would lower the processor and memory resource use. Of course, as a retired enterprise IT infrastructure engineer... removal of function would be a priority, to remove code behind function is possible. :slight_smile: .

I am not sure it will lower the resource use, compared to just not using the editor. I many be wrong though.

If it just disables the editor, that ok, the resource use reduction would be wonderful.

Why will disabling it reduce the resource, compared to just not using the editor?

Given the code still loads, that would not, but the every act of using the editor, has overhead. So disable of the editor at least avoids its overhead when engaged. My PiZero devices are running at 88 to 93 percent memory load, even with the old/max parameter set appropriately. This is ok, given I will not have a large number of flows per device, but would like to get that percentage lower if possible. On the other hand, for example, python3 script that runs, then uses MQTT message back to Node Red, uses a fraction of the resources available. It would be an interesting question, if the Node-Red development team would consider creating a lite version of Node-Red, that just runs flows, nothing else by default. Of course flows would be loaded to this lite version via CLI or such, given no editor existing. However, given IoT devices are becoming more robust, there is also the question, is there a demand for such a lite instance?

Right, so disabling accomplishes nothing other than preventing you doing something you aren't going to do anyway.

How are you determining that you are running at 90% memory? It is not trivial on Linux to know how much is actually being used as Linux uses up as much as it can, caching disc and other data. That does not necessarily mean you are near the limit. What does
top
show? Are you running a GUI or browser on the Zero?

Right now just looking at total available - used = available, then available/total*100 in a meter object on dashboard tab scale 0 to 100. Not the most accurate method. I will refine it when I get a chance, after I get some other stuff done. Raspberry Pi4 with 4GB runs about 10%, PiZero with 512MB at 88 to 93 over time. Correct way is to query the process specific resources of course. All I have right now is a 1000 foot level estimate of the total system memory load.

You also have to look at the buff/cache memory. That is memory that the OS is using for buffers and caches, but which can be freed up if necessary for applications to use. On a Zero that can easily reach significant size and make it look as if you are running out. On mine that I am looking at here, for example, it is 170MB which is about 30% of the memory, and the system will make that available if applications need it.

You didn't say whether you are using a GUI. Also which OS have you installed? Raspbian Lite is the one to use to keep resources at a minimum.

We believe we have put in most of the hooks necessary to help partition up the runtime - but we haven't had time to exercise that... luckily this is an open-source project - so the larger WE are all part of the team :-)... so feel free to get experimenting.

2 Likes

Also note the max-old space parameter for node.js is (sort of) advisory - in that, that is the point at which the garbage collector kicks in more aggressively. So a) memory use can go higher (if there is nothing to collect), and b) it will tend to drift up to that limit if you have a busy machine as it won't cut in unless it needs to.

1 Like

Oh, I want to... Just have to learn more and get my flows done! Once I get all my sensors wrapped into Node Red, I want to get into the development more.

True, it reminds me of how .NET does resource collection, and it should given nodejs and .NET are managed frameworks, if you will.