# Can node-red node/flow run in parallel?

**URL:** https://discourse.nodered.org/t/can-node-red-node-flow-run-in-parallel/7678
**Category:** General
**Created:** [7 February 2019 02:13 UTC](https://discourse.nodered.org/t/can-node-red-node-flow-run-in-parallel/7678 "2019-02-07T02:13:22Z")
**Posts on this page:** 10
**Page:** 2

<div class="post-metadata">

### Author: ![fangzhu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fangzhu/32/5796_2.png) [@fangzhu](https://discourse.nodered.org/u/fangzhu)
#### Post date: [8 February 2019 11:09 UTC](https://discourse.nodered.org/t/can-node-red-node-flow-run-in-parallel/7678/21 "2019-02-08T11:09:31Z")

</div>

Thanks!  
So if both are doing java script logic, we have to wait for each other.  
But when one node is doing something else, like Db access, REST call, system call etc, the javascript code in the other code can be processed at the same time?

---

<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: [8 February 2019 11:10 UTC](https://discourse.nodered.org/t/can-node-red-node-flow-run-in-parallel/7678/22 "2019-02-08T11:10:51Z")

</div>

> [@fangzhu](#):
>
> But when one node is doing something else, like Db access, REST call, system call etc, the javascript code in the other code can be processed at the same time?

Exactly - that is how the node.js event loop works. If you want to find out more, there is a lot of material describing how the node.js event loop works and how to properly develop for it available online.

---

<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: [8 February 2019 11:14 UTC](https://discourse.nodered.org/t/can-node-red-node-flow-run-in-parallel/7678/23 "2019-02-08T11:14:18Z")

</div>

By the way, if you are having to join messages as in the Aggregator example you linked to, I would not do it the way the example does using a global context variable. Instead you can use the Join node, which is configurable to meet a number of requirements.

---

<div class="post-metadata">

### Author: ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)
#### Post date: [8 February 2019 16:48 UTC](https://discourse.nodered.org/t/can-node-red-node-flow-run-in-parallel/7678/24 "2019-02-08T16:48:12Z")

</div>

> [@Colin](#):
>
> I would not do it the way the example does

Agreed. There have been a couple of recent references to this Node-RED Design Patterns article, one aptly referring to it as "outdated." It might be really useful if the [Node-RED Cookbook](https://cookbook.nodered.org) could be expanded to include some higher-level recipes. These could be kept up to date with changes in the structure of NR and the capabilities of individual nodes. It could be both a source of templates for beginners and a focus of community discussion of "best practices."

---

<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: [8 February 2019 17:24 UTC](https://discourse.nodered.org/t/can-node-red-node-flow-run-in-parallel/7678/25 "2019-02-08T17:24:03Z")

</div>

> [@drmibell](#):
>
> It might be really useful if the [Node-RED Cookbook](https://cookbook.nodered.org) could be expanded to include some higher-level recipes

Yes. It would be helpful if the cookbook covered the basics as well. Alas no one is contributing to it, so it waits for me to find time.

---

<div class="post-metadata">

### Author: ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)
#### Post date: [8 February 2019 19:55 UTC](https://discourse.nodered.org/t/can-node-red-node-flow-run-in-parallel/7678/26 "2019-02-08T19:55:43Z")

</div>

> [@knolleary](#):
>
> Alas no one is contributing to it, so it waits for me to find time.

I didn't mean to ask you to work harder than you already do. I would be happy to find a way to contribute and have joined the #docs channel on Slack. It seems like there are some outstanding PRs for missing items in the Cookbook toc. How should I find the best place to put my oar in the water?

---

<div class="post-metadata">

### Author: ![fangzhu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fangzhu/32/5796_2.png) [@fangzhu](https://discourse.nodered.org/u/fangzhu)
#### Post date: [12 February 2019 03:05 UTC](https://discourse.nodered.org/t/can-node-red-node-flow-run-in-parallel/7678/27 "2019-02-12T03:05:25Z")

</div>

Is it possible to add the recipe of "how to create a Node-RED cluster", too.

---

<div class="post-metadata">

### Author: ![fangzhu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fangzhu/32/5796_2.png) [@fangzhu](https://discourse.nodered.org/u/fangzhu)
#### Post date: [13 February 2019 02:29 UTC](https://discourse.nodered.org/t/can-node-red-node-flow-run-in-parallel/7678/28 "2019-02-13T02:29:59Z")

</div>

Hi guys,  
Thanks for all.  
I found a link introducing the thread management of Node.js and this helped me to understand why my node cannot be run in parallel because it seems all code that was written on the event of "input" will block the event loop. I should be careful not to do many things before registering any call backs.

> **[Don't Block the Event Loop (or the Worker Pool) | Node.js](https://nodejs.org/en/docs/guides/dont-block-the-event-loop/)**
>
> Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.

---

<div class="post-metadata">

### Author: ![DanBo](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@DanBo](https://discourse.nodered.org/u/DanBo)
#### Post date: [10 June 2020 13:05 UTC](https://discourse.nodered.org/t/can-node-red-node-flow-run-in-parallel/7678/29 "2020-06-10T13:05:50Z")

</div>

Hi

You should read Google V8 code, to avoid messing up with all assumptions made within nodejs. You need to understand the api v8:isolate.

If you aren't ready for the extrem, you can still use node-ipc or thread-manage-service module ... to the cost of having to deal with author's own assumption of what parrallel is and suffer consequences.

If you want to do grid computation with strategy within node-red, I suggest you start to reject the concept of randomized access memory and learn computed access memory.

---

<div class="post-metadata">

### Author: ![DanBo](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@DanBo](https://discourse.nodered.org/u/DanBo)
#### Post date: [11 June 2020 10:18 UTC](https://discourse.nodered.org/t/can-node-red-node-flow-run-in-parallel/7678/30 "2020-06-11T10:18:34Z")

</div>

@fangzhu

It does looks like people use IPC to acheived this ... [https://flows.nodered.org/node/node-red-contrib-lyteworx-cluster](https://flows.nodered.org/node/node-red-contrib-lyteworx-cluster)

> **[node-red/node-red](https://github.com/node-red/node-red/wiki/Architecture:-Cluster---Multi-Process)**
>
> Low-code programming for event-driven applications - node-red/node-red

Overall, I advise you, to use a shared-memory database such sqlite and use 0mq on top of it. So you can construct whatever parrallel architecture you want ( fork, pool, jit, cascade, roll, spread-contract) with managing politics at a global level

You create a table for workers call ( HOST, FLOW-function, CACHE-PAGE-UID, Cache-Data ID IN, Cache Data ID out for reserve, CLUSTER UID, Credentials Token ) and you are good to go for all your applications

[Previous page](https://discourse.nodered.org/t/can-node-red-node-flow-run-in-parallel/7678.md?page=1)
