Difference between Redis and Memcache

Source: Internet
Author: User

1. In Redis, not all data is stored in the memory, which is the biggest difference from Memcached.

2. Redis not only supports Simple k/v data, but also provides storage of data structures such as list, set, and hash.

3. Redis supports data backup, that is, data backup in master-slave mode.

4. Redis supports data persistence. Data in the memory can be stored on the disk and loaded again during restart.

Redis has many database features, or is a database system, while Memcached is just a simple K/V cache.

Let's take a look at the comparison between Redis authors and memcache.

 

Source: Is memcached a dinghuur in comparison to Redis? (Compared with Redis, is Memcached really outdated ?)

 

You shoshould not care too much about performances. redis is faster per core with small values, but memcached is able to use multiple cores with a single executable and TCP port without help from the client. also memcached is faster with big values in the order of 100 k. redis recently improved a lot about big values (unstable branch) but still memcached is faster in this use case. the point here is: nor one or the other will likely going to be your bottleneck for the query-per-second they can deliver.

There is no need to worry too much about performance, because the performance of both is high enough. Because Redis only uses a single core, while Memcached can use multiple cores, Memcached has higher performance on average when Redis stores small data. Memcached has higher performance than Redis in data of more than kb. Although Redis has recently optimized its performance in storing big data, it is inferior to Memcached. The conclusion is that no matter which one you use, the number of requests processed per second will not become a bottleneck. (For example, the bottleneck may be on the NIC)

 

You shoshould care about memory usage. For simple key-value pairs memcached is more memory efficient. If you use Redis hashes, Redis is more memory efficient. Depends on the use case.

For memory usage efficiency and simple key-value storage, Memcached memory usage is higher. If Redis uses the hash structure for key-value storage, due to its combined compression, the memory usage is higher than that of Memcached. Of course, this is related to your application scenarios and data features.

 

You shoshould care about persistence and replication, two features only available in Redis. Even if your goal is to build a cache it helps that after an upgrade or a reboot your data are still there.

If you have requirements on data persistence and data synchronization, we recommend that you choose Redis because Memcached does not have these two features. Even if you just want to upgrade or restart the system and the cache data will not be lost, it is wise to choose Redis.

 

You shoshould care about the kind of operations you need. in Redis there are a lot of complex operations, even just considering the caching use case, you often can do a lot more in a single operation, without requiring data to be processed client side (a lot of I/O is sometimes needed ). this operations are often as fast as plain GET and SET. so if you don't need just GET/SET but more complex things Redis can help a lot (think at timeline caching ).

At last, we have to talk about your specific application requirements. Compared with Memcached, Redis has more data structures and supports richer data operations. Generally, in Memcached, you need to get the data to the client for similar modifications and then set it back. This greatly increases the number of network I/O operations and data volumes. In Redis, these complex operations are generally as efficient as general GET/SET operations. Therefore, if you need the cache to support more complex structures and operations, Redis will be a good choice.


1. Redis and Memcache both store data in the memory and are memory databases. However, memcache can also be used to cache other things, such as clips and videos.2. Redis not only supports Simple k/v data, but also provides storage of data structures such as list, set, and hash.3. Virtual Memory-Redis can swap some unused values to the disk when the physical memory is used up4. Expiration Policy-memcache is specified at set time. For example, set key1 0 0 8 never expires. Redis can be set through expire, for example, expire name 105. Distributed-set the memcache cluster and use magent for one master and multiple slaves. redis can perform one master and multiple slaves. Both can be master-slave6. Storage Data Security-after memcache is suspended, data is lost. redis can be regularly stored on disks (persistent)7. Disaster Recovery-data cannot be recovered after memcache is suspended; after redis data is lost, data can be restored through aof.8. Redis supports data backup, that is, data backup in master-slave mode.

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.