MongoDB best configuration for a Forum with more than 100k users and 200k topics.



  • I migrated a big forum to nodeBB+mongodb and I'm making some test, but for example I see that the home page is very slow to load and that node process consume a lot of resources.

    There are some tuning to do on the mongo side?
    Anything to do on the NodeBB side?


  • Admin

    What kind of load does the server have?

    Mongodb runs better if all indices fit in ram(http://docs.mongodb.org/manual/tutorial/ensure-indexes-fit-ram/). So make sure your server has enough ram.

    If there are lots of users accessing the forum you can spin up more NodeBB processes using the cluster setting.

    How many categories and recent replies are you displaying on the home page? The more you display the slower it will get.



  • @baris said:

    What kind of load does the server have?

    Node is consuming 99% of 1 CPU, but I'm the only user navigating the forum.
    It's on a test environment, not production.

    Mongodb runs better if all indices fit in ram(http://docs.mongodb.org/manual/tutorial/ensure-indexes-fit-ram/). So make sure your server has enough ram.

    24GB of Ram. I think it's enough.

    If there are lots of users accessing the forum you can spin up more NodeBB processes using the cluster setting.

    Do you have some docs on the cluster settings? This is all https://docs.nodebb.org/en/latest/scaling/?
    There's something more?

    How many categories and recent replies are you displaying on the home page? The more you display the slower it will get.

    I'm using the default settings.
    From where I can choose what to display?
    I also see that the admin categories panel is very slow.
    Doing some shell command from Mongo

    [root@gt1 ~]# mongo
    MongoDB shell version: 2.6.5
    connecting to: test
    \> db.collection.totalIndexSize()
    \> use nodebb
    switched to db nodebb
    \> db.collection.totalIndexSize()
    \> db.collection.stats()
    {
        "ok" : 0,
        "errmsg" : "not authorized on nodebb to execute command { collstats: \"collection\", scale: undefined }",
        "code" : 13
    }

  • Admin

    Yeah 24gb should be more than enough unless you have more indices than that which is unlikely.

    Those errors in the cli look like you have a user and password setup but you are not authorizing. You will need to run db.auth(username, password) before running the commands.

    As for cluster you can either run nodebb with ./nodebb start cluster=4 to start 4 nodebb processes or you can put that setting your config.json file as "cluster": 4.

    Is the cpu constantly at 99% even when not doing anything? Or is it on certain routes?



  • Thanks @baris for your reply.

    Now I have 2 issues:

    writin db auth I get

    2014-11-06T08:28:27.812+0100 ReferenceError: nodebb is not defined
    

    Enabling clustering with cluster=8 cause I have 8 cores NodeBB start having lots of issues.
    Options not savings, a message appearing/disappearing continuosly with a reference to unable to connect or similar (I can't read the message cause it's firing too fast.
    In the admin there is a spinner running all the time in the nav bar.

    If I disable clustering it starts working again.



  • Now I fixed the auth issue, but the problem remains with the command

     > MongoDB shell version: 2.6.5
     connecting to: test
     > use nodebb
     switched to db nodebb
     > db.auth('myuser','mypass')
     1
     > db.collection.totalIndexSize()
     > db.collection.stats()
    { "ok" : 0, "errmsg" : "Collection [nodebb.collection] not found." }


  • Ok. The problem was the .collection

    > db.stats()
    {
        "db" : "nodebb",
        "collections" : 5,
        "objects" : 10950579,
        "avgObjSize" : 559.5723418825617,
        "dataSize" : 6127641136,
        "storageSize" : 7159541760,
        "numExtents" : 28,
        "indexes" : 9,
        "indexSize" : 2563102416,
        "fileSize" : 10666115072,
        "nsSizeMB" : 16,
        "dataFileVersion" : {
                "major" : 4,
                "minor" : 6
        },
        "extentFreeList" : {
                "num" : 0,
                "totalSize" : 0
        },
        "ok" : 1
    }

  • Admin

    You can also run db.objects.stats() if I'm not mistaken.



  • The problem is on the Category cause I have a lot of them.

    What about the other issue with the cluster=8?


  • Admin

    @andreapernici said:

    Options not savings, a message appearing/disappear

    For cluster to work properly you will need to configure redis for socket.io.

    You can add a redis block into config.json with the default settings.



  • @baris mmm I'm using mongo.

    I have to configure also redis together with mongo?

    There is some more extensive docs about it specific to nodebb?

    I found this https://github.com/deedw/mong.socket.io but it is already inside the nodebb packages or I have to install it and then put the configuration inside the nodebb config.json?


  • Admin

    @andreapernici Officially, socket.io contains only an in-memory session adapter (which for obv. reasons won't work with a clustered setup), and a redis session adapter.

    So if you're clustering w/ Mongo, you'll have to set up Redis alongside, and have both mongo and redis configuration hashes in your config.json



  • Ok. I understand.

    I think it's correct. One of the thing I thought about NodeBB was that a good approach was to use Redis for notification etcetc and Mongo for the rest.

    In this case to make a summary:

    • install nodebb on Mongo.
    • create a Redis instance.
    • configure the json file with both mongo and redis references.

    If you have some example feel free to share :D



  • Out of curiosity, why don't you use Redis? the new redis cluster feature let you shard data to multiple servers.


  • Banned

    This post is deleted!



Looks like your connection to NodeBB was lost, please wait while we try to reconnect.