# Performance / Efficiencies - best practice?

**URL:** https://discourse.nodered.org/t/performance-efficiencies-best-practice/23310
**Category:** General
**Created:** [19 March 2020 09:17 UTC](https://discourse.nodered.org/t/performance-efficiencies-best-practice/23310 "2020-03-19T09:17:50Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [19 March 2020 09:17 UTC](https://discourse.nodered.org/t/performance-efficiencies-best-practice/23310/1 "2020-03-19T09:17:50Z")

</div>

Having a lot of mqtt (out)nodes in my flows (must sound familiar), I was wondering if there is a best practice / best optimisation of (mqtt) node use.

Is there a performance impact/optimisation of using a lot of mqtt out nodes versus using a single mqtt-out node that are all linked using link nodes ?

I guess it does not apply only to mqtt, but in general, is there a degrade/gain to reuse single out-nodes via links nodes ?

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [19 March 2020 09:29 UTC](https://discourse.nodered.org/t/performance-efficiencies-best-practice/23310/2 "2020-03-19T09:29:26Z")

</div>

Adding the link nodes does mean the message has to go through more 'hops' between nodes before it gets published. But I doubt you'd notice the difference to be honest.

From a memory standpoint, if you are replacing N MQTT nodes with 1 MQTT node, but adding in (N+1) Link nodes, then overall you will have more node objects in the flow. Again, I doubt whether that is a difference you'd be able to measure unless you are doing things at a pretty massive scale.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [19 March 2020 09:40 UTC](https://discourse.nodered.org/t/performance-efficiencies-best-practice/23310/3 "2020-03-19T09:40:30Z")

</div>

It is important that all the nodes use the same mqtt config node. But I have little doubt you have done that already. Worth saying though for others that may see this.

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [19 March 2020 09:50 UTC](https://discourse.nodered.org/t/performance-efficiencies-best-practice/23310/4 "2020-03-19T09:50:54Z")

</div>

> [@Colin](#):
>
> It is important that all the nodes use the same mqtt config node

@colin Why? what is the reason?

---

<div class="post-metadata">

### Author: ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)
#### Post date: [19 March 2020 09:54 UTC](https://discourse.nodered.org/t/performance-efficiencies-best-practice/23310/5 "2020-03-19T09:54:51Z")

</div>

Since the broker connection is kept open and shared between all user nodes it wouldn't make much of a difference, since all messages have to be handled in the same NodeJS process anyway. 🤔

What could have an impact is the usage of wildcards vs. distinct topics (on a larger scale).

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [19 March 2020 09:55 UTC](https://discourse.nodered.org/t/performance-efficiencies-best-practice/23310/6 "2020-03-19T09:55:25Z")

</div>

Each config node represents a separate connection to the broker.

if you want to maximise efficiency, use the same config node so you only have one connection to the broker.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [19 March 2020 10:04 UTC](https://discourse.nodered.org/t/performance-efficiencies-best-practice/23310/7 "2020-03-19T10:04:23Z")

</div>

Sorry I should have mentioned that, but yes I assumed a single config.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [19 March 2020 10:07 UTC](https://discourse.nodered.org/t/performance-efficiencies-best-practice/23310/8 "2020-03-19T10:07:42Z")

</div>

Just in case there is some confusion over terminology when you create an MQTT In/Out node there are actually two nodes involved. The In/Out node that you see on the flow and the config node that it uses to connect to the mqtt broker. On the In/Out node configuration is a drop down box to select the server (ie broker), each broker maps to a config node. So in the dropdown there should generally only be one entry for each MQTT broker that you wish to connect to,

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [2 April 2020 10:07 UTC](https://discourse.nodered.org/t/performance-efficiencies-best-practice/23310/9 "2020-04-02T10:07:44Z")

</div>

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