Is it safe to run multiple isolated instances of NodeBB and use LB to distribute load?

Moved Developer FAQ
  • I use a k8s deployment and scale it up according to my need to run the cluster instead of using the official guide of using built-in worker cluster forking mode, so I think that maybe there will be some problem if I run that with k8s, and I think the most notable potential problem would be the websocket requirement? Because it is a stateful protocol, there can be some disassociation problem of message ordering/context difference.

    I also see that I can add a Redis pubsub, and would that help solving this problem?

  • @stevefan1999-personal Considerations when scaling NodeBB are detailed here: https://docs.nodebb.org/configuring/scaling/

    ... but possibly not in the most digestable way. In summary, here's what you need:

    • Redis configured in config.json so it will be used as pubsub and for storing user sessions (volatile data)
    • One of the workers needs isPrimary set to true in config.json, conversely, the other instances need jobsDisabled set to false
    • For socket.io, you will need to make sure to use a ip hashing strategy when routing requests from the load balancer. A typical round-robin style means the socket.io handshake will fail since it ends up hitting different servers.


Suggested Topics


  • 4 Votes
    1 Posts
    35 Views
  • 0 Votes
    1 Posts
    49 Views
  • 1 Votes
    2 Posts
    73 Views
  • 0 Votes
    3 Posts
    195 Views
  • 1 Votes
    1 Posts
    231 Views