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.


  • Admin

    @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 your config.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 to mongo, NodeBB will save application data in MongoDB, and auto-detects Redis availability and uses it for session data if at all possible.



  • @julian so it should work by just adding the redis to the config?
    Even if the current system is all mongo?

    We'll test next week and see how it goes.


  • Admin

    Yeah it will work by just adding the redis section. Let us know if you run into any issues.



  • @baris thanks, we'll do some internal testing on Monday.


  • Plugin & Theme Dev

    @tekojo don't forget to install redis, connect-redis & socket.io-redis modules

    npm install redis connect-redis socket.io-redis



  • @pichalite we are running a cluod system, where we actually need to add those to packages. Basically a similar situation as with the heroku install. (Btw That's a really good page in the docs)


 

Suggested Topics

  • 2
  • 1
  • 4
  • 4
  • 3
| |