Redis, Memcache, mongoDB contrast

Source: Internet
Author: User
Tags install php memcached mongodb redis

A comparison of Redis, Memcache, and MongoDB is made from the following dimensions.
1. Performance
are relatively high, performance should not be a bottleneck for us.
In general, TPS is about the same as Redis and Memcache, more than MongoDB.
2, the convenience of the operation
Memcache data structure is single. (Key-value)
Redis is rich, data manipulation, Redis better, less network IO times, but also provides List,set,
Storage of data structures such as hashes.
MongoDB supports rich data expression, index, most similar relational database, support query language is very rich.
3. Size of memory space and amount of data
Redis has added its own VM features after the 2.0 release, breaking the limits of physical memory, and setting the key value to
Period of time (similar to memcache)
Memcache can modify the maximum available memory, using the LRU algorithm. Memcached agent software magent, such as establishing
10 sets of 4G Memcache cluster, which is equivalent to 40G. Magent-s 10.1.2.1-s 10.1.2.2:11211-b
10.1.2.3:14000 MongoDB is suitable for storage of large data volume, depends on operating system VM to do memory management, eat memory is also more severe, service
Don't be with other services.
4. Availability (single point of issue)
For a single point of problem,
Redis, which relies on clients for distributed reads and writes, and master-slave replication, each time the primary node is reconnected from the node to the entire
A snapshot, no incremental replication, due to performance and efficiency issues,
Therefore, the single point problem is more complicated, the automatic sharding is not supported, and the dependent program is required to set the consistent hash mechanism.
An alternative is to use your own proactive replication (multiple storage) without the replication mechanism of Redis itself, or change to
How incremental replication works (you need to implement it yourself), consistency issues and performance tradeoffs
The Memcache itself does not have the data redundancy mechanism, also does not need, for the fault prevention, relies on the mature hash or the ring
Algorithm to solve the jitter problem caused by single point of failure.
MongoDB supports Master-slave,replicaset (internal using Paxos election algorithm, automatic fault recovery), auto sharding mechanism, blocking the failover and segmentation mechanism to the client.
5. Reliability (persistent)
For data persistence and data recovery,
Redis Support (snapshot, AOF): dependent on snapshots for persistence, AOF enhances reliability while providing performance impact
Ring
Memcache not supported, usually used in cache, improve performance;
MongoDB supports persistent reliability from the 1.8 release with the binlog approach
6. Data consistency (transactional support)
Memcache in concurrent scenarios, using CAs to ensure consistent redis transaction support is weak and can only guarantee continuous execution of each operation in a transaction
MongoDB does not support transactions
7. Data analysis
MongoDB has built-in data analysis capabilities (MapReduce), others do not support
8. Application Scenario
Redis: More performance operations and calculations with smaller data volumes
Memcache: For reducing database load in dynamic systems, improving performance, caching, improving performance (for read-write
Less, for a large amount of data, you can use sharding)
MongoDB: The main solution to the massive data access efficiency problem.
Table comparison:
Memcache Redis type in-memory database memory Database
Data type does not need to have a fixed data type when defining value
There are strings, lists, collections, and ordered collections
Virtual memory does not support support
Expiration policy support Support
Distributed Magent Master-slave, one master-one from or one master multi-slave
Storage data security does not support storage to DUMP.RDB using save
Disaster recovery does not support append only file (AOF) for data recovery
Performance
1. Type--memcache and Redis all store data in memory, so it is a memory database. Of course, memcache can also be used to cache other things, examples, and so on.
2. Data type--memcache You specify the byte length of the data when you add data, and Redis does not.
3. Virtual memory-When the physical memory is exhausted, you can swap some long-unused value to disk.
4. Expiration policy--memcache is specified when set, such as set Key1 0 0 8, which never expires. Redis can pass
For example expire settings, such as expire name 10.
5, distributed-set memcache cluster, using Magent to do a master more from; Redis can do a master multi-slave. are available
With one master one from.
6, storage data security--memcache power cut off, the data is gone; Redis can save to disk on a regular basis.
7, disaster recovery--memcache Ibid, Redis lost can be restored by AOF.
Memecache Port 11211
Yum-y Install memcached
Yum-y Install Php-pecl-memcache
/etc/init.d/memcached start memcached-d-P 11211-u memcached-m 64-c 1024-p/var/run/memcached/memcached.pid
-D Start a daemon
-P Port
-M allocated memory is M
-C Max running concurrency number-pid of P Memcache
0 compression (whether memcache_compressed) 30-second failure time
Delete 5 is a timeout

Redis, Memcache, mongoDB contrast

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.