# Node execution within a subflow

**URL:** <https://discourse.nodered.org/t/node-execution-within-a-subflow/44768>\
**Category:** General\
**Created:** [26 April 2021 15:46 UTC](https://discourse.nodered.org/t/node-execution-within-a-subflow/44768 "2021-04-26T15:46:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tcr000](https://avatars.discourse-cdn.com/v4/letter/t/65b543/32.png) [@tcr000](https://discourse.nodered.org/u/tcr000)\
**Post date:** [26 April 2021 15:46 UTC](https://discourse.nodered.org/t/node-execution-within-a-subflow/44768/1 "2021-04-26T15:46:52Z")

</div>

I have an application where I need two function nodes to run as close in time as possible. I can place them on the same branch, but isn't it possible that an unrelated flow will execute in between these two nodes? If so, it I placed both nodes inside a subflow, would this guarantee that they run as close as possible in time? I do realize that things like garbage collection and Linux may make the time between any two nodes variable. I trying to do the best I can. If I need to, I can combine the code into one function block but I would like to avoid it.

Thanks,  
Tom

---

<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:** [26 April 2021 16:03 UTC](https://discourse.nodered.org/t/node-execution-within-a-subflow/44768/2 "2021-04-26T16:03:39Z")

</div>

Hi @tcr000

If the code is in two separate nodes then the runtime will be able to schedule other work when the message is passed from one to the other. Putting the nodes inside a subflow doesn't change that.

If it really is that critical, then putting the code into one node is the only way to be sure - plus you remove the overhead of sending the message between the nodes which doesn't happen for free in terms of time.

---

<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:** [25 June 2021 16:04 UTC](https://discourse.nodered.org/t/node-execution-within-a-subflow/44768/3 "2021-06-25T16:04:21Z")

</div>

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