Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

Just looking for what people see as the main differences when choosing between the two.

like image 620
fancy Avatar asked Jun 22 '11 20:06

fancy


People also ask

Which is better Redis or MongoDB?

Redis is faster than MongoDB because it's an in-memory database. This makes it a great choice for building complicated data structures quickly. MongoDB, however, suits most medium-sized businesses that need a reliable database. It's relatively simple and easy to use and, as we mentioned earlier, very scalable.

How many times max Redis is faster than MongoDB?

The general answer is that Redis 10 - 30% faster when the data set fits within working memory of a single machine.

Why is Redis better than others?

When storing data, Redis stores data as specific data types, whereas Memcached only stores data as strings. Because of this, Redis can change data in place without having to re-upload the entire data value. This reduces network overhead.


1 Answers

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.

like image 129
Tomasz Nurkiewicz Avatar answered Oct 16 '22 00:10

Tomasz Nurkiewicz