Comparison of Memcached and Redis

Source: Internet
Author: User
Tags memcached

Copyright belongs to the author.
Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.
Seamon
Links: http://www.zhihu.com/question/19645807/answer/12605611
Source: Know

They are in-memory database, the data is stored in memory, through TCP direct access, the advantage is fast, high concurrency, the disadvantage is that the data type is limited, the query function is not strong, generally used as a cache.

To improve performance, the data saved in memcached is stored in memcached 's built-in memory storage space. Because the data exists only in memory, restarting the memcachedand restarting the operating system will cause all data to disappear. Additionally, when the content capacity reaches the specified value, the unused cache is automatically deleted based on the LRU (Least recently used) algorithm. the memcached itself is a server designed for caching, so there is not too much consideration for permanent data issues.


Compared to memcached:

1. Redis has a persistence mechanism that can periodically persist the data in memory to the hard disk.

2, Redis has the Binlog function, can write all operations to the log, when the Redis failure, can follow the Binlog data recovery.

3, Redis support virtual memory, can limit the size of RAM, when the data exceeds the threshold, the most infrequently used data in memory is saved to the paging file of the hard disk by an algorithm like LRU.

4. Redis native supports more data types and uses more space for imagination.

5, a friend mentioned in front of a consistent hash, used in Redis sharding, generally in the load is very high need to expand the level of use. We have not used this aspect of the function, the general project, stand alone enough to support the concurrency. Redis 3.0 will launch cluster, which is more powerful.

6, Redis more advantages, please visit the official website inquiry.

The two years of Redis fire, Redis is often used as a memcached challenger to be mentioned on the desktop. The comparison between Redis and memcached is ubiquitous. However, does Redis really go beyond memcached in terms of functionality, performance, and memory efficiency?

The following is an answer from the Redis author on StackOverflow, and the corresponding question is "is memcached a dinosaur in comparison to Redis?" (Is it really outdated compared to redis,memcached?). )

  • You should don't care too much about performances. Redis is faster per core with small values, but memcached was able to use multiple cores with a single executable and TCP p ORT without help from the client. Also memcached is faster with big values in the order of 100k. Redis recently improved a lot of big values (unstable branch) but still memcached are faster in this use case. The point here Is:nor one or the other would likely going to be your bottleneck for the query-per-second they can deliver.
  • There is no need to be overly concerned about performance, because both are already high enough in performance. Since Redis uses only single cores, and memcached can use multicore, on average, Redis has a higher performance than memcached for storing small data on a per-core scale. In more than 100k of data, memcached performance is higher than Redis, although Redis has recently been optimized for the performance of storing big data, but it is slightly inferior to memcached. Having said so much, the conclusion is that no matter which one you use, the number of requests per second will not be a bottleneck. (such as bottlenecks may be in the network card)
  • Should care about memory usage. For simple key-value pairs memcached are more memory efficient. If You use Redis hashes, the Redis is more memory efficient. Depends on the use case.
  • If you want to say that memory usage efficiency, using simple key-value storage, memcached memory utilization is higher, and if Redis uses hash structure to do key-value storage, because of its combined compression, its memory utilization will be higher than memcached. Of course, this is related to your application scenario and data characteristics.
  • You should care about persistence and replication, and the other features only available in Redis. Even if your goal is to build a cache it helps a upgrade or a reboot your data is still there.
  • If you have requirements for data persistence and data synchronization, it is recommended that you choose Redis because neither of these features memcached. Choosing Redis is also wise, even if you just want the cached data to be not lost after upgrading or rebooting the system.
  • Your should care is about the kind of operations for you need. In Redis there is a lot of complex operations, even just considering the caching use case, you often can does a lot more in A single operation, without requiring data to being processed client side (a lot of I/O is sometimes needed). This operations is often as fast as plain GET and SET. So if you don ' t need just get/set and more complex things Redis can help a lot (think at timeline caching).
  • And, of course, you have to talk about your specific application needs in the end. Redis has more data structures and supports richer data operations than memcached, usually in memcached, you need to get the data to the client for similar modifications and set it back. This greatly increases the number of network IO and the volume of data. In Redis, these complex operations are often as efficient as the general get/set. So, if you need caching to support more complex structures and operations, Redis is a good choice.

Memcached persistence can refer to the third-party plugins developed by Sina Corporation:

Http://www.cnblogs.com/codersay/p/4301669.html (supported operation is simple, careful consideration)

Comparison of Memcached 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.