How to scale Node-RED horizontally across a cluster of nodes?

3,926 views
Skip to first unread message

Narendra Naidu

unread,
Jul 21, 2016, 3:12:52 PM7/21/16
to Node-RED
Is it possible to scale out Node-RED horizontally on a cluster of nodes? Could not find any documentation on the same. My scenario is to handle millions of events per second and process them in real time using Node-RED.

Julian Knight

unread,
Jul 21, 2016, 4:02:04 PM7/21/16
to Node-RED
Nice idea but I don't think that is quite the focus of NR I'm afraid. I think there are other flow-based tools that might be capable of this though.

Ben Hardill

unread,
Jul 21, 2016, 4:30:08 PM7/21/16
to Node-RED
What are the inputs and outputs to your flow.

If it's HTTP end points then this will be trivial to do using normal load balancing techniques

Other input types will require different approaches

On Thursday, 21 July 2016 20:12:52 UTC+1, Narendra Naidu wrote:

Dean Cording

unread,
Jul 21, 2016, 5:44:36 PM7/21/16
to Node-RED
When you say "scale out Node-RED horizontally", what do you mean - slicing a flow across several Node Red instances, or having multiple Node Red instances implement the same flow in parallel and combining the results?

Dave C-J

unread,
Jul 21, 2016, 5:59:12 PM7/21/16
to node...@googlegroups.com
thanks Julian - I guess I better tell the guys using 40+ instances in parallel to provide a fast feed into a transactional database they should stop using Node-RED then.

Julian Knight

unread,
Jul 21, 2016, 6:57:31 PM7/21/16
to Node-RED
Yup! :-}

Nicholas O'Leary

unread,
Jul 21, 2016, 7:22:13 PM7/21/16
to Node-RED Mailing List
Narendra - so you've had a variety of responses so far. Let me throw in my view as this is something I'm having to think about currently.

"Is it possible to scale out Node-RED horizontally on a cluster of nodes?"

It depends.... we don't have an automatically mechanism today that will manage that for you, but there is nothing to stop you running the same set of flows multiple times on multiple instances. The question is then how you meaningfully spread the workload across them. As Ben said, if it is all HTTP initiated, then you can use traditional load balances to do that. If it is some of protocol, such as MQTT, then it really will depend on the exact circumstances.

There are other considerations, for example the flows need to be pretty much stateless - or designed to store any shared state in an external service. Also, when you have multiple instances running and you hit deploy in the editor, how exactly do all of the instances get updated. Again, a whole area I'm looking at.

I really want to get away from this mindset that Node-RED is for prototyping trivial things - we know that isn't the case, but equally we know we have work to do in some areas.

Nick 



--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
For more options, visit https://groups.google.com/d/optout.

Narendra Naidu

unread,
Jul 22, 2016, 2:30:11 PM7/22/16
to Node-RED
Thanks Nick. I have understood how Node-RED can be scaled when we have Http input using a load balancer.

But how can we scale MQTT? Let's consider a scenario where in all devices/gateways publish to a single topic and I need to process the events across many machines. I would be storing state externally on Redis.
Can we have a load-balanced set of MQTT listeners on different node-RED instances?

Ben Hardill

unread,
Jul 22, 2016, 3:42:08 PM7/22/16
to Node-RED
Load balancing MQTT is a bit harder.

Pub/Sub Messages are normally delivered to all clients that subscribe to a given topic. This means that if you have a cluster of Node-RED instances that all run the same flow then they will all subscribe to the same topic so they will all process the same message.

There are a few potential work arounds to this:

1) each node subscribes to a different topic, assuming that the topic structure  is partitioned in such a way that it can be used to split up the incoming messages between clients this works pretty well
   
    e.g. given a topic structure that looks like base/a/...., base/b/....., base/c/..... then you could have

    Node-RED instance 1 subscribe to base/a/#
 
    Node-RED instance 2 subscribe to base/b/#

    and so on


2) Some brokers (IBM Message Sight and HiveMQ) support something called shared subscriptions (though in different ways) which means that messages are delivered to only one client each.

3) You put a single instance of Node-RED at the front that subscribes to the topic and then uses HTTP to distribute the messages to the cluster

Valter Junior

unread,
Aug 2, 2017, 2:39:41 PM8/2/17
to Node-RED


Em quinta-feira, 21 de julho de 2016 16:12:52 UTC-3, Narendra Naidu escreveu:
Is it possible to scale out Node-RED horizontally on a cluster of nodes? Could not find any documentation on the same. My scenario is to handle millions of events per second and process them in real time using Node-RED.


To solve this scaling issue in our platform, we have a NR application called Router which receives via http rest all events with no Load-Balance upfront, then we turn those incoming urls into routing-keys. To the incoming message we add the routing-key and a callback routing-key (which represents the address of queue this instance of Routers is listening) and send them to a RabbitMQ cluster which routes all messages to their respectives NR flows. Once those messages come from a queue , scaling horizontally become easy. At the and of each flow we send those messages back to RabbitMQ with the callback-routing. Router receives those messages back and return the response.

We are now considering other forms to take better advantage from cpu, by using something like bee-queue or some js server which simulate multi threading. We are even considering some serveless options. 
Suggestions are always welcomed.  ;)

Valter Junior

unread,
Aug 2, 2017, 2:55:26 PM8/2/17
to Node-RED
"I really want to get away from this mindset that Node-RED is for prototyping trivial things"

 We are working hard in this subject. We are building a great platform having node-red as our base. And a entire ecosystem that gonna assist node-red in this task. 

Jéan Roux

unread,
Aug 3, 2017, 5:10:02 PM8/3/17
to Node-RED
Are your bit you need in flows stateless? Put those flows in Docker, add many replicas, and let Docker run the NR service many times over in a searm. It runs beautifully on Docker Swarm mode.

Rowan Shedden

unread,
Sep 20, 2017, 12:54:21 AM9/20/17
to Node-RED
Hi Nick,

did you ever manage to figure out how to update all the instances of a cluster running node red, when you want to deploy new or updated flows? Ideally, just deploying in one node red instance would replicate over the cluster.

Cheers,
Rowan

Dennis Noto

unread,
Sep 20, 2017, 1:47:43 PM9/20/17
to Node-RED
Yes, I took the route to build kubernetes clusters for node-red to get scalability.  My flows externalize global vars to Redis to keep the flows stateless.  If interested, see my repo for configurations - https://github.com/dennisnotojr/UCG-Repo/tree/master/UCG/Configurations/Kubernetes 
Reply all
Reply to author
Forward
0 new messages