Multiple nodes in a flow

Newbie question:

is it a bad thing to have multiple instances of the same node in the same flow ?

IE:

  • multiple inject nodes

  • multiple MQTT publish and subscribe nodes

  • multiple debug nodes

etc

Or is it really just a case of "good practise" to try and reduce the number of nodes (and/or)... reducing nodes speeds the flow up so that's what you want to aim for ?

EG : i have a flow that is related to the snips AI. So anything Snips related i keep in the same flow. However that makes the flow rather large the more i add to it.the more i seem to double up on certain nodes. But dragging wires everywhere ( in a messy state) seems wrong so i use the same node ( like my RMPRO node) multiple times. Just curious if thats a practise i should try to avoid in order to better myself

Not at all. Of course, if several nodes are doing the same thing, you may wish to reduce the number but it generally doesn't make a lot of difference - with one caveat given below.

With things like the MQTT nodes, I tend to use a single node with a link node so that I can send data to it from lots of places but that is more of a preference than a requirement.

The caveat is that, if you have multiple wires from a single output, all but the first wire will likely get copies of the msg object. This is generally what you would want as it prevents unexpected interactions between the different flow elements, however, in some extreme cases this can have a more significant overhead. Generally something you don't have to worry about though.

You can also make good use of subflows if you find that you have a pattern of nodes/wires that you use repeatedly.

I don't know that there is really a single good practice, it really depends on what you are doing. Obviously, you want your flows to be a simple as possible for the given need but over-simplifying can be just as bad since it can make the flows really hard to follow when you come back to them.

I don't think it is that simple I'm afraid. If you have performance issues, that can be a hard problem to track down with Node-RED since it is so complex.

Well link nodes are one way to help here. It can really simplify the layout of your flows.

As mentioned, subflows are the way to go if you have a repeated section of flow.

1 Like

awesome thanks for the reply. I love to learn and progress so appreciate answers like that. Cheers

2 Likes