Choose memcached or Redis?

Source: Internet
Author: User

Similarities between the two

Both memcached and Redis belong to in-memory , key- value data storage scenarios. They all belong to the NoSQL family in the data management solution and are based on the same key-value data model. Both sides choose to keep all the data in memory, which naturally makes them a very ideal buffer layer implementation scheme. From a performance perspective, the two types of data storage mechanisms also have a number of commonalities, including the ability to have almost the same characteristics (and metrics) , and a high degree of attention to workload data throughput and latency .

When to use memcached

Memcached was originally developed by Brad Fitzpatrick in 2003.

Compared to memcached,Redis is available later and has more features , so developers often see it as a default preferred scenario. But there are two types of special scenes that are still the memcached of the world. The first is the caching of small, static data , and the most representative example is the snippet of HTML code. Memcached's internal memory management mechanism, though not as complex as Redis's, is more effective -because memcached consumes less memory resources when it processes metadata . As the only one by one data types supported by memcached, strings are ideal for storing data that only needs to be read, because the string itself does not need to be processed further.

In addition to this,Memcached has an advantage over redis in terms of scale-out . Because of its design-oriented mindset and relatively simple function settings, the memcached is much less difficult to extend than Redis. But according to what we've learned, there are a number of tested and effective programs that can extend Redis up to multiple servers, and its upcoming release 3.0 (interested friends can click here to see their candidate release notes) will include a built-in clustering mechanism specifically for scale-out scenarios.

When should I use Redis

Redis was created by Salvatore Sanfilippo in 2009 and is known as the "enhanced version of Memcached". Unless you need to consider a particular constraint (such as dealing with a traditional application) for memcached, or if your actual use case belongs to one of the two previously mentioned scenarios, choose Redis directly and use it. With the excellent caching solutions that Redis brings, we have the power to handle the details of cache content and persistence-and the efficiency of overall execution.

Redis also gives us the greatest amount of flexibility in space, ensuring that administrators have an ample platform to handle cached objects. In this regard,memcached restricts the key name to 250 bytes, and the value is limited to less than 1MB and only applies to normal strings. In contrast,Redis sets the maximum limit for key names and values to 512MB, and supports a binary format that supports six types of data . The ability to cache and manipulate data more intelligently is tantamount to opening the door to endless possibilities for application developers.

  in contrast to saving an object as a serialized string, Redis allows developers to hash object fields and values in a hashed manner and manage them with a single key. the existence of the Redis hashing mechanism ensures that the developer does not have to go through the complex process of acquiring a complete string, deserialization, update value, Object re-serialization and using it to replace the full string within the cache after each value update-which also means reduced resource consumption and significant performance gains. Other data types supported by Redis, such as lists and sets--, can also be used to implement more complex cache management patterns.

  Another important advantage of Redis is that the data it holds is transparent, meaning that the server can manipulate the data directly. there are more than 160 available commands in Redis, most of which are used to implement data processing operations and embed logic into the data storage system through server-side scripting. These built-in commands and user scripts provide a great deal of flexibility to help you complete data processing tasks directly within Redis-without having to move data back and forth between other specialized processing systems on the network.

REdis also provides an optional and tailor-made data persistence scheme designed to re-boot cached content after a planned outage or unplanned failure occurs. While we are more inclined to emphasize the volatile and transient nature of the data in the cache, it is still very practical to persist the data on disk in some cache scenarios. This mechanism can quickly reload the data stored on disk into the cache after the device restarts, greatly reducing the cache warm-up cycle and re-evaluating the current cache content based on the master data store content.

  last but not least, Redis is capable of providing replication capabilities. The replication feature is designed to help cache architectures implement high-availability configuration scenarios that continue to provide uninterrupted caching services to applications in the event of a failure. It is clear that a mature caching scenario should be able to have little or no impact on the user experience or application performance in the event of an application failure, and this strong assurance of caching content and service availability is, in most cases, a major advantage of caching solutions.

Choose memcached or 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.