What is the difference between MongoDB and Redis? and Which one is better ?



  • Hello!! i'm very confuse and don't know What is the difference between MongoDB and Redis? and Which one is better ? ..


  • Global Moderator

    @SoPhat-VaThana

    Redis - Data is stored on RAM, backed up to the HDD/SSD of the server, RAM is a lot faster than HDDs or SSDs, but is also more expensive when it comes to large amounts of data. Servers with 20GB Ram would cost a lot more than a server with a 20GB SSD.

    Mongo - Data stored on HDD/SSD, can hold as much data as you have storage space, but is slightly slower than Redis

    If you have a large forum then Mongo would likely be the best solution, if you're just starting out, then Redis is better supported here, as more of us use it. You can technically use both, but again, only a select few would be able to assist you with that.



  • By taking the comparison into appropriate intuitive scale, RAM is a lot faster than SSD, and of course it is blazingly fast as compared to traditional HDD.

    Screen Shot 2014-11-22 at 12.56.42 PM.png

    As @a_5mith mentioned above, Redis stores data on the RAM while MongoDB stores them on disk. Most of the server providers (like Digital Ocean, RamNode, AWS EC2) use RAM capacity as the main pricing standard. Disk storage is provided in abundance, beyond what you need (usually). What I mean is that if you are running a NodeBB, it is quite sufficient to run it on a 512MB Digital Ocean instance, and for sure you don't need 20GB SSD disk space if you are running NodeBB alone.

    Some application might leverage the best of both (MongoDB and Redis), where in this setup the Redis will act as the caching DB while MongoDB as the main DB. Kinda the same as HDD+SSD hybrid setup. You store the most frequently used stuffs on the SSD for faster access (hot storage), while the less used ones on the HDD (cold storage).

    Discouse would be a good example here. It uses Redis as the caching DB and PostgreSQL as the main DB.

    Hope this explanation helps!

    By the way, to answer your question, it depends. If your system or application does the processing in real time, or you want it to be as fast as possible, Redis it is.



  • @aixnr said:

    Some application might leverage the best of both (MongoDB and Redis), where in this setup the Redis will act as the caching DB while MongoDB as the main DB. Kinda the same as HDD+SSD hybrid setup. You store the most frequently used stuffs on the SSD for faster access (hot storage), while the less used ones on the HDD (cold storage).

    It never occurred to me. It's a great idea, overall.



  • NodeBB have support for mongodb+redis, but it's still marked as "WIP" ^^'
    https://docs.nodebb.org/en/latest/configuring/databases.html#running-a-secondary-database



  • Ah i like the forward-thinking of the nodebb guys. :+1:



  • Also, @SoPhat-VaThana , i would recommend you Redis, this is stable (as of your machine won't run out randomaly xD) and really fast, and a forum, like this one, is less than 100mb of ram for the whole database i heard, so you can't see how scalable this are... ^^



  • @Technowix saw that before. NodeBB already broke through few stuffs, for example, multi-cpu support (because by default, NodeJS is single-thread, hence it works best on single core CPU setup). Maybe we have to wait a bit more for combo DB engine setup. Maybe @psychobunny has a say on this?


Log in to reply
 


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