Home > Database > Redis > body text

What is the difference between MongoDB and Redis

青灯夜游
Release: 2019-06-18 10:50:55
Original
59595 people have browsed it

What is the difference between MongoDB and Redis

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

Redis is an open source (BSD licensed), in-memory data structure storage system that supports multiple types of data structures and can be used as a database, cache, and message queue broker.

What is the difference between MongoDB and Redis

1. Memory management mechanism

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

MongoDB data is stored in memory, which is implemented by Linux system mmap. When the memory is not enough, only hot data is put into the memory, and other data is stored on the disk.

2. Supported data structures

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

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

3. Data volume and performance:

When the physical memory is enough, redis>mongodb>mysql

When the physical memory is not enough, both redis and mongodb will Use virtual memory.

In fact, if redis wants to start virtual memory, it is obvious that you must either add a memory stick or change the database.

However, mongodb is different. As long as the business can guarantee the read-write ratio of hot and cold data, hot data will have less mmap exchange in physical memory.

mongodb can still guarantee performance.

4. Performance

mongodb relies on memory and has high TPS; Redis relies on memory and has very high TPS. Redis is better than MongoDB in terms of performance.

5. Reliability

mongodb has adopted the binlog method (MySQL also uses this method) since version 1.8 to support persistence and increase reliability;

Redis Relying on snapshots for persistence; AOF enhances reliability; while enhancing reliability, it affects access performance.

MongoDB is better than Redis in terms of reliability.

6. Data analysis

mongodb has built-in data analysis function (mapreduce); Redis does not support it.

7. Transaction support

Redis transaction support is relatively weak and can only ensure that each operation in the transaction is executed continuously; mongodb does not support transactions.

8. Cluster

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

Recommended related video tutorials: "MongoDB Tutorial", "Redis Tutorial"

The above is the detailed content of What is the difference between MongoDB and Redis. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template