Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What's the difference between MongoDB and Redis?

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces what is the difference between MongoDB and Redis. It is very detailed and has certain reference value. Friends who are interested must finish reading it.

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

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

What's the difference between MongoDB and Redis?

1. Memory management mechanism

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

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

2. Supported data structures

Redis supports a variety of data structures, including hash, set, list and so on.

MongoDB data structure is relatively simple, but supports rich data expression, index, most similar to relational database, and supports a wide range of query languages.

3. Data volume and performance:

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

Both redis and mongodb use virtual memory when there is not enough physical memory.

In fact, if redis is going to start virtual memory, it's obvious that you either add a stick of memory or you change the database.

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

Mongodb can still guarantee performance.

4. Performance

Mongodb is memory dependent and TPS is high; Redis is memory dependent and TPS is very high. Redis is superior to MongoDB in performance.

5. Reliability

Since mongodb version 1.8, binlog has been adopted (MySQL also uses this method) to support persistence and increase reliability.

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

MongoDB is superior to Redis in reliability.

6. Data analysis

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

7. Transaction support

Redis transaction support is weak and can only guarantee the continuous execution of each operation in the transaction; mongodb does not support transactions.

8. Cluster

MongoDB cluster technology is relatively mature, Redis has supported clusters since 3. 0.

These are all the contents of the difference between MongoDB and Redis. Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report