Both MongoDB and Redis are NoSQL, using structured data storage. There are some differences between the two in the usage scene, which is mainly due to the process of the memory mapping, and the persistence processing method is different.
MongoDB recommended cluster deployment, more considering the cluster scenario, Redis is more emphasis on process sequential write, although the support cluster, but also limited to the master-slave mode.
Compare indicators |
MongoDB (v2.4.9) |
Redis (v2.4.17) |
Comparison notes |
Implementation language |
C++ |
C + + |
- |
Agreement |
BSON, Custom Binary |
Class Telnet |
- |
Performance |
Memory dependent, higher TPS |
Memory dependent, TPS very high |
Redis is better than MongoDB |
operability |
Rich data expression, index, most similar to relational database, support rich query statement |
Data-rich, less IO |
MongoDB is better than Redis |
Memory and Storage |
Suitable for large data volume storage, dependent on system virtual memory, image file storage, high memory consumption ratio, the official recommended independent deployment in 64-bit system |
REDIS2.0 supports virtual memory features (VMS) Beyond physical memory limits, data can be set to timeliness, similar to Memcache |
Different application scenarios |
Availability of |
Support Master-slave,replicatset (internal use of Paxos election algorithm, automatic failback), auto sharding mechanism, blocking the failover and slicing mechanism to the client |
Rely on the client to implement the distributed read and write, master-slave replication, every time from the node reconnect to the primary node to rely on the entire snapshot, no incremental replication; auto sharding is not supported, need to rely on the program to set the consistency hash mechanism |
MongoDB is better than Redis; On a single point problem, MongoDB application is simple, relative user transparent, Redis is more complex, need the client to actively solve. (MongoDB is typically combined with replicasets and sharding, replicasets focus on high availability and high reliability, sharding focus on performance, horizontal scaling) |
Reliability |
Support for persistence in Binlog mode (MySQL-like) since version 1.8 |
Rely on snapshots for persistence; AOF enhances reliability and enhances performance while impacting access |
|
Consistency |
Transactions are not supported, guaranteed by the client |
Support transactions, more brittle, only ensure that operations in the transaction are executed sequentially |
Redis is better than MongoDB |
Data analysis |
Built-in data analysis capabilities (MapReduce) |
Not supported |
MongoDB is better than Redis |
Application Scenarios |
Increased access efficiency for massive data |
Performance and operation of smaller data volumes |
MongoDB is better than Redis |
The comparison between MongoDB and Redis