What to do if Redis requires more memory than available memory

Source: Internet
Author: User
Tags allkeys

We know that Redis sets the maxmemory parameter of the configuration file to control its maximum available memory size (bytes).

What if the required memory exceeds MaxMemory ?

This time the maxmemory-policy in the configuration file appeared.

Its default value is noeviction.

Below I will list the elimination rules that are available when the Redis key is removed when there is not enough free memory.

Rule name Rule description
Volatile-lru Remove a key using the LRU algorithm (only for keys that have a time-to-live setting)
Allkeys-lru Remove a key using the LRU algorithm
Volatile-random Randomly delete a key (only for keys that have a time-to-live setting)
Allkeys-random Randomly delete a key
Volatile-ttl Delete one of the most recent keys to survival time
Noeviction Do not delete keys, only return errors

The LRU algorithm , least recently used, is the least recently used algorithm . This means that the least recently used key is deleted by default.

But be sure to pay attention to a little ! Instead of accurately deleting the least recently used keys in all keys, Redis randomly extracts 3 keys , removing the least recently used keys from the three keys.

Then 3 this number can also be set, the corresponding location is the maxmeory-samplesin the configuration file.

How does Redis require more memory than is available?

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.