The difference Redis and MongoDB

Redis and MongoDB difference (Interview good enough)

The project is using MongoDB, but why does the fact it was not much selection, they also considered, but that the large amount of data, so the use of MongoDB.

Recently thought Why MongoDB, to check what, summary summary:

Before also used redis, was used to store some hot data, the amount is not large, but the operation is very frequent. The project is now using MongoDB, currently one million data, there would be ten million, one hundred million.

On Redis and MongoDB is concerned, we generally called a cache Redis, MongoDB database. This is the proper way of rational evidence-based,

Redis main data stored in memory, the "cache" properties much greater than its properties "data storage", where the additions and deletions to the data change search operation just as simple as a variable;

MongoDB is a "data storage" system, CRUD can add a lot of conditions like flexible SQL database, which is very popular during the interview with.

Click to view: MongoDB database SQL syntax syntax compared with existing relational

The comparison between Mongodb and Redis application

MongoDB and Redis are NoSQL, using the structured data store. In use both scenarios, there are some differences, which is mainly due to the
process both in the memory map, the persistence of the different treatment methods. MongoDB suggested cluster deployment, more consideration to the cluster program, Redis
and more emphasis on the written order of the process, while supporting the cluster, it is limited to the master - slave mode.

index MongoDB(v2.4.9) Repeat (v2.4.17) Compare Description
Implementation language C++ C/C++ -
protocol BSON, custom binary Telnet class -
performance Rely on memory, TPS higher Rely on memory, TPS is very high Redis is better than MongoDB
Operability A wealth of data representation, the index; most similar to a relational database that supports a rich query language Data-rich, less IO MongoDB is better than Redis
Memory and storage Suitable for large amount of data storage, system-dependent virtual memory management, file storage mirroring; memory share is relatively high, the official recommendations of the independent deployment system 64 (32-bit maximum limits 2.5G file, there is no change limits 64) Redis2.0 the increase virtual memory characteristics, to break physical memory limit; timeliness of data can be set up, similar to memcache Different application point of view, have their own advantages
Availability Support master-slave, replicaset (internal use paxos election algorithm, automatic failover), auto sharding mechanism to shield the client failover and slicing mechanism Rely on the client to implement a distributed read and write; master-slave replication, reconnect each node from the master node must rely on the entire snapshot, no incremental replication; does not support auto-sharding, need to rely on the program to set a consistent hash mechanism MongoDB than the Redis; on of a single point, simple application MongoDB, relatively transparent to the user, the Redis more complex, the need to proactively address the client. (MongoDB typically use replica sets and sharding binding function, replica sets focus on high reliability and high availability, and sharding focused on performance, easy to expand)
reliability From the 1.8 version, using binlog way (MySQL also uses this mode) support persistence, increase reliability Dependent snapshots persistence; AOF enhanced reliability; while enhancing reliability, performance affect access MongoDB is better than Redis
consistency It does not support things by itself guarantee the client Support things, relatively weak, only guarantee the operation of the execution order of things Redis is better than MongoDB
data analysis Built-in data analysis functionality (mapreduce) not support MongoDB is better than Redis
Scenarios Massive data access efficiency improvement A small amount of data and calculation of performance MongoDB is better than Redis

Guess you like

Origin blog.csdn.net/Lijunhaodeboke/article/details/91957858