What are the differences between MongoDB and Redis? [closed] What are the differences between MongoDB and Redis? [closed] mongodb mongodb

What are the differences between MongoDB and Redis? [closed]


Data model

MongoDB

Document oriented, JSON-like. Each document has unique key within a collection. Documents are heterogenous.

Redis

Key-value, values are:

  • Lists of strings
  • Sets of strings (collections of non-repeating unsorted elements)
  • Sorted sets of strings (collections of non-repeating elements ordered by a floating-point number called score)
  • Hashes where keys are strings and values are either strings or integers

After Wikipedia.

Storage

MongoDB

Disk, memory-mapped files, index should fit in RAM.

Redis

Typically in-memory.

Querying

MongoDB

By key, by any value in document (indexing possible), Map/Reduce.

Redis

By key.


I just read a comparison between different NOSQL databases which I think sums it up pretty nicely:

MongoDB:

Best used: If you need dynamic queries. If you prefer to define indexes, not map/reduce functions. If you need good performance on a big DB. If you wanted CouchDB, but your data changes too much, filling up disks.

Redis:

Best used: For rapidly changing data with a foreseeable database size (should fit mostly in memory).


Redis is a key value store while mongofb is a document store.

Redis is awesome at storing unrelated pieces of information while mongodb is awesome at structuring or modeling information with relations between them.

I am not talking in absolute ways. They are both nosql databases and as such you can pretty much define the shape and colour of what you store but in practice, that is how they are usually used.