Redis requires much memory reserved memory for security issues, redis memory usage

Source: Internet
Author: User

Redis requires much memory reserved memory for security issues, redis memory usage

I have tried to limit the memory usage of apsaradb for redis by setting it. The result shows that it is not feasible. (Redis does not distinguish between cold and hot data and keeps cold data on the hard disk ). If you want to run redis normally, you need to know how much memory redis can occupy and how much memory it retains.

Conclusion:

Limit: Double the memory. For example, if your redis data occupies 8 GB of memory, you need to reserve 8 GB of free memory. That is, the memory requirement is 16 GB. Memory usage less than 50% is the safest.

General situation:Normally, all data is not changed during the serialization period, but only some data is changed., Then, reserve space for possible changes. If you really want to talk about a piece of data, it is safe to use less than 75% of the memory usage.

For example, one of the N data servers of our game server:

For example, the 16 GB memory has already used 64%. But in fact, during fork serialization, it only occupies more than 200 MB of memory. Because only 200 M is changed. That is to say, even if the memory usage reaches 80%, it is safe. BecauseCopy-On-WriteMB is required.

It is the safest to leave a memory multiple times.
The process that overrides the AOF file and RDB file (even if it is not persistent, RDB should be written when it is copied to Slave) will generate a new process for fork,The Copy-On-Write policy of the operating system is adopted (if the memory of the parent process is not modified, the child process shares the Page with the parent process. If the Page of the parent process is modified, a copy of the content before the modification is copied to the new process ),Pay attention to the reports produced by the Console, such as "RDB: 1215 MB of memory used by copy-on-write ".
When the system is extremely busy, if all pages of the parent process have been modified during RDB writing by the child process, the memory needs to be doubled.
According to the reminder when Redis is started, when vm. overcommit_memory = 1 is set to make fork () A 10 Gb process, 10 Gb free memory is not required because of the COW policy.
When the maximum memory reaches, it is processed according to the configured Policy. The default policy is volatile-lru, and LRU is used to clear the key with expire time (not based on the actual expire time ). If no data is set to expire time or the policy is noeviction, an error is reported directly. However, the system still supports read operations such as get. There are also several policies, such as volatile-ttl Based on the closest expire time. allkeys-lru performs LRU on all keys.
The original version of VM 2.0 (put the Value on the disk, and the Key is still in the memory), which is not supported after version 2.4.(Ps. This is a pitfall. I used to remember this)

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.