The comparison between MongoDB and Redis

Source: Internet
Author: User
Tags redis

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

Category: Redis

Http://www.cnblogs.com/chinesern/p/5581422.html

1\redis and Mongodb,mysql


Redis is a database that completely stores data in memory, uses disk for persistence purposes only, the Redis data all exists memory, writes to disk periodically, when memory is not enough, can choose the specified LRU algorithm to delete data, persistence is using RDB or aof way.


MongoDB is a document-type non-relational database, MongoDB is more like MySQL, support field index, cursor operation, the advantage is that the query is more powerful, good at querying JSON data, can store large amounts of data, but does not support transactions.


All of MongoDB's data is actually stored on the hard disk, and all the data to be manipulated is mapped to an area of memory in a mmap way.
MongoDB then modifies the data in this area to avoid fragmented hard disk operations.
As for the contents of mmap flush to the hard disk is the operating system, so if, MongoDB in memory after modifying the data, MMAP data flush to the hard disk before the system down, the data will be lost.


Mysql:
Both the data and the index are stored on the hard disk. To be swapped into memory when it is to be used. Ability to handle data that is far more than the total amount of memory.


Data volume and performance:
When the physical memory is sufficient, the Redis>mongodb>mysql
Both Redis and MongoDB use virtual memory when physical memory is not enough.
In fact, if Redis is going to start virtual memory, it's obviously either adding a memory bar, or you're changing the database.
However, MongoDB is not the same, as long as the business can guarantee that the hot and cold data read and write ratio, so that the thermal data in physical memory, mmap exchange less.
MongoDB is still capable of guaranteeing performance. Someone uses MongoDB to store data on the upper T.
Mysql,mysql doesn't have to worry about the amount of data that is related to memory.




Redis transaction support is weak and can only guarantee continuous execution of each operation in a transaction
MongoDB does not support transactions


MongoDB has built-in data analysis capabilities (MapReduce) and Redis does not support


Redis can only use single threads and performance is limited by CPU performance

The comparison between MongoDB and Redis

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.