Redis How much memory reservation is required-how much memory is consumed is safe __redis

Source: Internet
Author: User
Tags redis serialization volatile

In the previous article, I have tried to set the way to limit the size of redis memory, the results found to be not feasible. (Redis does not distinguish between hot and cold data, keep cool data on the hard disk). So if you want to run Redis, you need to know how much memory Redis can occupy and how much memory to keep.

Conclusion:

Limit condition : Set aside memory for one times. For example, if your Redis data consumes 8G of RAM, you will need to reserve 8G of free memory. That is, the memory requirement is 16G. A memory occupancy rate below 50% is the safest.

Normal situation : Normally, in the serialization cycle, all data will not be changed, only some of the data changes , then set aside the possible changes in the portion of space, on the line. If you really want to say a data, the memory occupancy rate of less than 75% is safe.

For example, we are the game server, one of the N data Server screenshot:


As shown above, 16G of RAM has been used for 64%. But in fact, when fork serialization, it only takes up more than 200 m of memory. Because only a change of more than 200 m. In other words, using memory usage is safe even if it reaches 80%. Because Copy-On-Write need 200M.


The following is an extended reading, the original link: https://searchdatabase.techtarget.com.cn/7-21572/

It is safest to keep one more memory.
The process of rewriting aof files and Rdb files (even if you do not persist, and write to slave when you copy them) will fork a new process, using the copy-on-write policy of the operating system (if the parent process's memory 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 it is copied to the new process, note the report that the console has typed, such as "rdb:1215 MB of memory used by Copy-on-write."
When the system is extremely busy, if all the page of the parent process has been modified during the RDB write process, it will require twice times of memory.
In accordance with the Redis startup reminder, set vm.overcommit_memory = 1 to make fork () a 10G process, because the cow strategy does not necessarily require 10G free memory.
When the maximum memory arrives, it is processed according to the configured policy, the default policy is VOLATILE-LRU, the key that has expire time is LRU cleared (not according to actual expire time). If no data is set to expire time or policy as noeviction, the error is immediate, but the system still supports read operations such as get. There are several other policy, such as Volatile-ttl by the closest expire time, ALLKEYS-LRU to all the key to do LRU.
The original 2.0 version of the VM (put value on the disk, key is still in memory), 2.4 version after not supported. (Ps. This is a pit.) I remember this one before.




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.