Query on performance considerations

I have a generic query - are there performance guidelines that the flow implementer should keep in mind ? Example - when i search the forum i read function node is more expensive .

Implementation of few lines of code involving- if () && - kind of logic - then may need multiple switches and then more nodes. ... can be done with a single function node.
In which scenarios would function node be recommended ? (From performance perspective only).

So in case there are any guidelines - which nodes are generally more expensive in terms of performance .. it can help.

Thanks in advance.

It is best not to dwell on this until it is a problem. Premature optimisation is a pitfall you should avoid.

The function node is not that expensive unless you are doing a very simple assignment then a change node is less expensive.

If you are interested in checking your work as you go, this simple subflow can help you keep check: flow-timer. A simple subflow to measure time taken in parts of your flows. (flow) - Node-RED

Noted @Steve-Mcl .
Let me check the subflow and see if i need to already do some measurements for my flow.

Thank You for that.

A function node has to create a Node.JS "virtual machine" to wrap the code in. That makes the function node a lot safer, especially for people with limited JavaScript skills. However, there is a small processing overhead.

As Steve says, the change node will be more efficient for simple changes. However, if you use JSONata in a change node, that is almost certainly slower than a function node (but sometimes the logic is a lot simpler).

But as Steve also say's - performance on a low-code platform is generally a lot less important than being able to create and follow the logic. Forget about it until it starts to be a problem - which may be never, even on a limited capacity Pi.

2 Likes

Note - it only creates that nodejs virtual machine once... and then re-uses it - so the very first time it it slow - but after that the overhead is then only that of passing data in and back out... (which does have an overhead but much much smaller than the initial creation)... So yes... not really worth worrying about.
Note2 - any change node using the jsonata operation can also be slow.

1 Like

Thank You @dceejay. Yes as i checked the forums jsonata indeed seems can be performance killer at least as of current versions.

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