Home  >  Article  >  Database  >  What are the differences between redis and mongodb?

What are the differences between redis and mongodb?

尚
Original
2019-06-24 14:15:504548browse

What are the differences between redis and mongodb?

MongoDB is more similar to MySQL, supporting field indexes and cursor operations. Its advantage is that its query function is relatively powerful, it is good at querying JSON data, and can store massive data, but it does not support transactions.

Mysql's efficiency drops significantly when the amount of data is large, and MongoDB is more often used as a replacement for relational databases.

Mongodb eats more memory, because when mongo finds that there is not enough memory, it applies for memory at an exponential level of 2. Therefore, it is generally recommended to put mongodb separately.

In fact, it can be said that redis is more like a caching mechanism, cookie, and you can also set the expiration time of data. Of course, it can also be stored permanently (but it seems slightly inferior?). Mongodb is a document-based storage.

Memory management mechanism:

All Redis data is stored in memory and written to disk regularly. When the memory is not enough, you can choose the specified LRU algorithm delete data.

MongoDB is the same as mysql, except that the index file is placed in memory. Implemented by Linux system mmap, when the memory is not enough, only the hotspot data is put into the memory, and other data is stored on the disk.

Supported data structures:

Redis supports a wide range of data structures, including hash, set, list, etc.

MongoDB's data structure is relatively simple, but it supports rich data expressions and indexes. It is most similar to a relational database and supports a wide range of query languages.

Performance:

redis is more suitable for performance and operations with smaller amounts of data

mongodb has better performance under access to massive data

Reliability:

Both support persistence.

Cluster:

MongoDB cluster technology is relatively mature, and Redis supports clusters starting from 3.0.

Not applicable scenarios:

Ø Operations that require the use of complex sql

Ø Transactional systems

Applicable scenarios :

Best application scenario of Redis: Suitable for applications where data changes quickly and the database size can be met (suitable for memory capacity).

MongoDB: Best application scenarios: Suitable for situations that require dynamic query support; need to use indexes instead of map/reduce functions; need to have performance requirements for large databases; need to use CouchDB but it is full because the data changes too frequently memory application.

For more Redis-related technical articles, please visit the Redis Tutorial Column to learn!

The above is the detailed content of What are the differences between redis and mongodb?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn