Millions of O & M experience 2: Selection of Redis and Memcached

Source: Internet
Author: User

Many people recommend using Redis instead of Memcached. I think these two are different. Their relationship should be coexistence rather than substitution.

Memcached is a memory-only cache system that supports a single data type, a single cache data has restrictions, and supports distributed storage. I think this is an ideal cache system.

Redis is a simple NOSQL database that supports several simple data types, master-slave replication, persistence, and memory type databases.

It can be seen that Memcached is an authentic cache system, and Redis is a memory-type database that can be used as a cache system.

Because Redis data can be set with an expiration time, multiple data types are supported, the data size is not limited, and persistence is supported, it seems that Memcached is more stable than Memcached, which seems to be the trend of the times.

This is not the case.

The data to be cached can be divided into two types: one is a loose cache, which does not care about being lost. If it is lost, it will be read back from the database or other places, such as Session, data queried from the database, application code cache, and so on. The other is non-lost cache, that is, data that is not stored elsewhere and only cached by Redis.

Let's talk about the advantages and disadvantages of Memcached and Redis:

Memcached is a memory-only cache that occupies a small amount of memory, runs stably, and reads and writes data quickly. Redis data can be persisted to the hard disk, occupying a large amount of memory and high hard disk I/O usage. When writing frequently and hard disk performance is not high (currently, only SSD performance is high, mechanical hard drive performance is not high), greatly occupying CPU resources, the read/write performance will be greatly reduced, or even crash, unstable.

Why does Memcached cache Session data? Some people say that the Memcached crash will cause Session loss. I don't think this is very likely. Sessions are read on every page and written by every new user, in addition, most Session data is data that can be lost (generally, the number of sessions for a website stranger is much larger than the number of sessions logged on to the user), and the data volume is small, which is very suitable for storing in Memcached.

Memcached is actually very stable. At present, our website has millions of PVS every day, and no Memcached crash has occurred. As long as the server does not crash, rather than being shut down manually, Memcached is almost impossible to crash. If the server crashes frequently, I think we should consider changing a better server instead of replacing Memcached with Redis.

Of course, Redis also has its applicability. In the next blog, I will introduce in detail what non-lost data can be stored on my website using 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.