Clustering with Mongo?
-
Hi,
We got our forum migrated to NodeBB.
And now we are wondering about clustering.Our setup is NodeBB v0.6.x and Mongo as the database.
The docs say that Redis is necessary for clustering, but I can't find any info on how to add a Redis instance into an existing NodeBB+Mongo setup.
Anyone have experience on this?Also will the Redis requirement for clustering still be there in 0.7.0?
0.7.0 looks really promising, and we'll definitely update once it's stable. -
@tekojo Redis is required for clustering because socket.io stores session data in-memory (that is, tied to each NodeBB process).
So in a nutshell, user A doesn't always get sent to server X (depending on the load balancer setup, anyway), and in cases where a socket.io handshake is established only on one server and not the other, you get weird behaviour.
Socket.io has a Redis adapter, which can be used to store the sessions apart from NodeBB itself.
To define, add a
redis
section to yourconfig.json
:{ "database": "mongo", "port": [4569, 4570], "mongo": { .. your regular mongodb connection hash goes here }, "redis": { "host": "127.0.0.1", "port": "6379", "password": "", "database": "0" } }
... because
database
is set tomongo
, NodeBB will save application data in MongoDB, and auto-detects Redis availability and uses it for session data if at all possible.