# Parallel run of Subflows

**URL:** <https://discourse.nodered.org/t/parallel-run-of-subflows/32000>\
**Category:** General\
**Created:** [25 August 2020 19:45 UTC](https://discourse.nodered.org/t/parallel-run-of-subflows/32000 "2020-08-25T19:45:52Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThisisIO](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@ThisisIO](https://discourse.nodered.org/u/ThisisIO)\
**Post date:** [25 August 2020 19:45 UTC](https://discourse.nodered.org/t/parallel-run-of-subflows/32000/1 "2020-08-25T19:45:52Z")

</div>

Hello,

i'm trying to handle with messages that comes in parallel to subflow.  
Here is exmaple  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/e/4e2cc1e79eb7826585aa478567e93f90e82a2ecd.png)  
4 messages comes at same time to one subflow.  
I would like to make a delay for messages. For example 1 messag in 3 sec.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/8/38aff7af9347cf3b4a777ca0c1ffe6fb1655212d.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/0/30b6673706e23388d47cbd19d2efe9b0e3437b4c.png)  
But in this case all the messages comes output of sublow at the same time without any delay  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/7/87519a61f03d74080c7b2d67de3cfe32a77a57bb.png)

Please advice how do realise it?

Thanks a lot!

---

<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:** [25 August 2020 19:50 UTC](https://discourse.nodered.org/t/parallel-run-of-subflows/32000/2 "2020-08-25T19:50:22Z")

</div>

> [@ThisisIO](#):
>
> 4 messages comes at same time to one subflow.

At the moment, you have four separate instances of the subflow. That is not the same thing as having one instance of the subflow handling multiple messages.

---

<div class="post-metadata">

**Author:** ![ThisisIO](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@ThisisIO](https://discourse.nodered.org/u/ThisisIO)\
**Post date:** [25 August 2020 19:51 UTC](https://discourse.nodered.org/t/parallel-run-of-subflows/32000/3 "2020-08-25T19:51:56Z")

</div>

> [@knolleary](#):
>
> At the moment, you have four separate instances of the subflow. That is not the same thing as having one instance of the subflow handling multiple messages.

How to change the to one?

---

<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:** [25 August 2020 19:53 UTC](https://discourse.nodered.org/t/parallel-run-of-subflows/32000/4 "2020-08-25T19:53:02Z")

</div>

> [@ThisisIO](#):
>
> How to change the to one?

Each time you drag a copy of the subflow into the workspace you are creating a new instance of the subflow.

If you only want one, then you should only have one subflow instance in your workspace.

---

<div class="post-metadata">

**Author:** ![ThisisIO](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@ThisisIO](https://discourse.nodered.org/u/ThisisIO)\
**Post date:** [25 August 2020 19:54 UTC](https://discourse.nodered.org/t/parallel-run-of-subflows/32000/5 "2020-08-25T19:54:28Z")

</div>

If it is not possible? No way to solve it? The messages comes from different flows...

---

<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:** [25 August 2020 19:57 UTC](https://discourse.nodered.org/t/parallel-run-of-subflows/32000/6 "2020-08-25T19:57:09Z")

</div>

It sounds like you want to have a flow that is called from multiple places.

One option would be to use Link nodes to pass messages from your different flows to the flow you want to handle the messages - and not to use Subflows which aren't designed for this scenario.

---

<div class="post-metadata">

**Author:** ![ThisisIO](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@ThisisIO](https://discourse.nodered.org/u/ThisisIO)\
**Post date:** [25 August 2020 19:59 UTC](https://discourse.nodered.org/t/parallel-run-of-subflows/32000/7 "2020-08-25T19:59:12Z")

</div>

> [@knolleary](#):
>
> It sounds like you want to have a flow that is called from multiple places.

Yes, you are right - like function. To make a queue for TTS Speaker.  
You mean these Link nodes?  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/7/d702bbbde93164e1343dab82cbfb2687f3f3a26b.png)  
?It is like a shortcut for sublow?

---

<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:** [25 August 2020 20:00 UTC](https://discourse.nodered.org/t/parallel-run-of-subflows/32000/8 "2020-08-25T20:00:30Z")

</div>

Yes, those are the link nodes I am referring to.

This guide explains the differences between subflows and link nodes - [https://nodered.org/docs/developing-flows/flow-structure#making-reusable-flows](https://nodered.org/docs/developing-flows/flow-structure#making-reusable-flows)

---

<div class="post-metadata">

**Author:** ![ThisisIO](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@ThisisIO](https://discourse.nodered.org/u/ThisisIO)\
**Post date:** [25 August 2020 20:01 UTC](https://discourse.nodered.org/t/parallel-run-of-subflows/32000/9 "2020-08-25T20:01:39Z")

</div>

Thanks a lot!  
Will try now!

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [25 August 2020 20:37 UTC](https://discourse.nodered.org/t/parallel-run-of-subflows/32000/10 "2020-08-25T20:37:06Z")

</div>

Also maybe see [https://flows.nodered.org/flow/cea8afa28b7a93ebdc0f](https://flows.nodered.org/flow/cea8afa28b7a93ebdc0f)  
Not a subflow but a simple queue for TTS example

---

<div class="post-metadata">

**Author:** ![ThisisIO](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@ThisisIO](https://discourse.nodered.org/u/ThisisIO)\
**Post date:** [25 August 2020 20:48 UTC](https://discourse.nodered.org/t/parallel-run-of-subflows/32000/11 "2020-08-25T20:48:09Z")

</div>

Thanks i use exactly it! But as i said the problem was in multipy instances

---

<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:** [25 August 2020 21:06 UTC](https://discourse.nodered.org/t/parallel-run-of-subflows/32000/12 "2020-08-25T21:06:00Z")

</div>

> [@ThisisIO](#):
>
> as i said the problem was in multipy instances

When you have multiple instances of a subflow then each delay node is a separate node, so each one limits the rate of output of messages passing through it, but as each one node sees only one message then the delay nodes have no effect.

What are you actually trying to achieve with multiple instances of the same subflow being given the same messages?

---

<div class="post-metadata">

**Author:** ![ThisisIO](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@ThisisIO](https://discourse.nodered.org/u/ThisisIO)\
**Post date:** [25 August 2020 23:16 UTC](https://discourse.nodered.org/t/parallel-run-of-subflows/32000/13 "2020-08-25T23:16:03Z")

</div>

> [@Colin](#):
>
> What are you actually trying to achieve with multiple instances of the same subflow being given the same messages?

Thanks, already solved with Link Node. See above

---

<div class="post-metadata">

**Author:** ![ThisisIO](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@ThisisIO](https://discourse.nodered.org/u/ThisisIO)\
**Post date:** [26 August 2020 22:19 UTC](https://discourse.nodered.org/t/parallel-run-of-subflows/32000/14 "2020-08-26T22:19:22Z")

</div>

> [@knolleary](#):
>
> Yes, those are the link nodes I am referring to.
> 
> This guide explains the differences between subflows and link nodes - [https://nodered.org/docs/developing-flows/flow-structure#making-reusable-flows](https://nodered.org/docs/developing-flows/flow-structure#making-reusable-flows)

It works for me realy perfeсt! Thanks one more time!  
Now i got other but much smaller problem. As i understood Links do not works with Subflows, when i set Link unside Subflow it do not link. Is there a way to solve it?

---

<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:** [27 August 2020 07:27 UTC](https://discourse.nodered.org/t/parallel-run-of-subflows/32000/15 "2020-08-27T07:27:39Z")

</div>

> [@ThisisIO](#):
>
> As i understood Links do not works with Subflows

You can use links within a subflow. You can't link into a subflow of course, because node-red wouldn't know which instance of the subflow you wanted to link into, and if you want to link out of a subflow then you can use an additional output instead.

---

<div class="post-metadata">

**Author:** ![ThisisIO](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@ThisisIO](https://discourse.nodered.org/u/ThisisIO)\
**Post date:** [27 August 2020 08:32 UTC](https://discourse.nodered.org/t/parallel-run-of-subflows/32000/16 "2020-08-27T08:32:12Z")

</div>

> [@Colin](#):
>
> You can use links within a subflow. You can't link into a subflow of course, because node-red wouldn't know which instance of the subflow you wanted to link into, and if you want to link out of a subflow then you can use an additional output instead.

Thanks!  
I made it this way, with output, works like a charm!

---

<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:** [10 September 2020 08:32 UTC](https://discourse.nodered.org/t/parallel-run-of-subflows/32000/17 "2020-09-10T08:32:13Z")

</div>

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