# How do I achieve clustering and load balancing with Node-red native capabilities

**URL:** <https://discourse.nodered.org/t/how-do-i-achieve-clustering-and-load-balancing-with-node-red-native-capabilities/16672>\
**Category:** General\
**Created:** [14 October 2019 04:45 UTC](https://discourse.nodered.org/t/how-do-i-achieve-clustering-and-load-balancing-with-node-red-native-capabilities/16672 "2019-10-14T04:45:37Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [23 October 2019 17:14 UTC](https://discourse.nodered.org/t/how-do-i-achieve-clustering-and-load-balancing-with-node-red-native-capabilities/16672/5 "2019-10-23T17:14:55Z")

</div>

If the N node-red instances are each running on its own server (e.g. s1, s2, and s3) using the standard port # (i.e. 1880), the the load balancing can be defined by adding the same DNS hostname for all three servers. Individual requests will randomly end up at one of the three endpoints if DNS is configured properly.

If the N node-red instances are all running on the same server, each instance will need to be configured with its own port # (e.g. 18801, 18802, and 18803) -- then you can set up a simple nginx reverse proxy listening on the original port #1880, forwarding traffic to one of the three instances, using a configuration similar to this:

```auto
server {

  listen 1880;
  server_name nodered.example.com;

  location / {
    proxy_pass http://nr-cluster;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
  }

}

upstream nr-cluster {
   server nr1.example.com: 18801;
   server nr2.example.com: 18802;
   server nr3.example.com: 18803 down;
}

```

... unless I misunderstood your question, and you really want to pass `msg` objects from one instance's flow to the next -- in which case MQTT pub/sub will probably do what you need.

---

_[View the full topic](https://discourse.nodered.org/t/how-do-i-achieve-clustering-and-load-balancing-with-node-red-native-capabilities/16672)._
