Why Redis is higher than Memcached's bigger

Source: Internet
Author: User
Tags memcached string format redis labs



GitHub version Address: Https://github.com/cncounter/translation/blob/master/tiemao_2014/Redis_beats_Memcached/Redis_beats_ Memcached.md



Redis is a new universal storage system, and memcached still has its field of application






Memcached or Redis? This has been a controversial topic in modern high-performance Web applications. When Web applications that are based on relational databases need to improve performance, using caching is the first choice for the vast majority of architects, and naturally, memcached and redis are often preferred.


Common features

Memcached was originally developed by Brad Fitzpatrick for the LiveJournal website in 2003. And then rewrite it again in C (the first edition for Perl) and open to the public, which has become the cornerstone of modern web system development. The current development direction of memcached is to improve stability and performance optimization, rather than adding new feature features.



Redis was created in 2009 by Salvatore Sanfilippo, and until today Sanfilippo remains the only developer and code maintainer of Redis. It's also not surprising that Redis is also known as the "Memcached enhanced version (Memcached on steroids)", because part of Redis is built on the experience summary of Memcached. Redis has more features than memcached, which makes it more flexible, more powerful and more complex.



Memcached and Redis are used by many enterprises and a large number of production systems, supporting a variety of language development of the client, has a rich SDK. In fact, in the Internet Web development language of the dot scale, there is basically no support for memcached or Redis.



Why are memcached and Redis so popular? Not only is it extremely high performance, but also because they are relatively simple. It's pretty easy for programmers to get started using memcached or Redis. It may take only a few minutes to install and set up and integrate into the system. So it takes a little bit of time and effort to boost system performance immediately-usually by an order of magnitude. A simple solution can make a huge performance benefit: It's just too sour to imagine.


Memcached Applicable Scenarios





Because Redis is an emerging solution that offers more features, Redis is generally a better choice than memcached. Memcached may be a better choice in two specific scenarios.



, such as HTML code snippets. Memcached's memory management is not as complex as Redis, so the performance is higher because memcached's metadata metadata smaller , The extra overhead is relatively small. The only supported data type for memcached is the string  string, which is ideal for caching read-only data because the string does not require additional processing.



The second scenario is that memcached is easier to scale horizontally than Redis . The reason for this is that it is simple to design and function, and memcached easier to extend. The message shows that Redis will have built-in reliable cluster support [but has been skipping tickets] in the upcoming version 3.0 (read CA release notes).


Redis comes in


You should prefer Redis unless you are under environmental constraints (such as legacy systems), or if your business complies with the 2 above scenarios. Using Redis as a cache, system efficiency can be greatly improved by tuning cache content.



lru (Least Recently used, least recently used) algorithm, Also prioritize old blocks of data that are about the same size as new data. In contrast, Redis allows fine-grained control over expired caches, with 6 different strategies to choose from. Redis also employs a number of more complex memory management methods and recycling strategies.



Redis provides greater flexibility for cached objects . While the memcached limit is 250 bytes, the value is limited to 1 MB and can only be communicated through a plain text string. The key and value size limits for Redis are all megabytes (MB), which is binary safe "without data loss, regardless of encoding". With 6 data types, Redis makes caching and managing caches smarter and easier, opening up an infinite world for application developers.



Redis stores the fields and values of an object with a hash, and can be managed by a single key, compared to storing the object in string format.



See what you need to update an object with memcached:


    1. Get the entire string
    2. Deserializing objects
    3. Modify the value in it
    4. Serialize the object again
    5. Replace the entire string with a new string in the cache


And every update is going to do these things.



The use of Redis hashing can significantly reduce resource consumption and improve performance. Other Redis data types, such as list or Set, can be used to implement more complex cache management patterns.



Another significant advantage of Redis is that the data it stores is opaque, which means that the data can be manipulated directly on the server side. Most of the more than 160 commands can be used for data manipulation, so processing data through a server-side script call is a reality. These built-in commands and user scripts allow you to handle data tasks directly and flexibly without having to transfer data to another system over the network for processing.



Redis provides optional/adjustable data persistence to quickly load the cache after a crash/restart. Although we generally believe that the data in the cache is unstable and instantaneous, it is valuable to persist the data to disk in the cache system. Loading the warm-up immediately after a reboot takes a short time and reduces the overhead of the primary database system.



Finally, Redis provides master-slave replication (replication). The Replication can be used to implement a highly available cache system that allows for uninterrupted service in the event of some server downtime. Assuming that a cache server crashes, only a small number of users and programs are affected in a short time, and in most cases, there is a proven solution to ensure the availability of cached content and services.



Today's open source software is always providing the best practical technology solutions. When you need to use caching to improve application performance, Redis and memcached are the best product-level solutions. But given its rich features and advanced design, the vast majority of the time Redis should be your first choice.



Author's profile : Itamar Haber (@itamarhaber) is the chief developer of Redis Labs, which provides fully managed memcached and Redis cloud services for developers. With years of experience in software product development, Xeround, Etagon, Amicada, and M.N.S Ltd. as management and leadership positions. Itamar get Northwestern and Tel-aviv universitiesd Ogg-recanati, Master of Business Administration, and science in computer BS.



Related reading:


    • Improve Java Enterprise application performance with memcached, Part 1: Architecture and Configuration
    • Using memcached to improve Java Enterprise Application performance, Part 2: Database-based WebApp
    • Cache contention: Azure and AWS Upgrade caching services


Original link: Why Redis beats Memcached for caching



Original Date: 2014-10-15



Translation Date: 2014-10-23



Translators: Anchor




Why Redis is higher than Memcached's bigger


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.