Is it safe to run multiple isolated instances of NodeBB and use LB to distribute load?
-
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 totrue
inconfig.json
, conversely, the other instances needjobsDisabled
set tofalse
- 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.
- Redis configured in
Copyright © 2024 NodeBB | Contributors