Questions about Redis Overcommit_memory under Linux

Source: Internet
Author: User

First, Background

The company's Redis sometimes background save db is unsuccessful, and the following alarm is found through log, which is likely to be caused by it:

[13223] ~ Mar 13:18:02.207 # WARNING Overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add ' vm.overcommit_memory = 1 ' to/etc/sysctl.conf and then reboot or run the command ' Sysctl vm.overcom Mit_memory=1 ' for the take effect.

So through the search, also someone with me encountered the same problem, basically can be determined that it is caused by it.

Second, kernel parameter overcommit_memory

It is a memory allocation policy, Optional values: 0, 1, 2.

0, indicates that the kernel will check for sufficient available memory to be used by the process, and if sufficient memory is available, the memory request is allowed; otherwise, the memory request fails and the error is returned to the application process.
1, which means that the kernel allows all physical memory to be allocated regardless of the current memory state.
2, which indicates that the kernel allows allocating more memory than the sum of all physical memory and swap space

Iii. what is Overcommit and Oom

Linux responds "Yes" to most requests for memory so that it can run more and bigger programs. Memory is not used immediately after memory is applied. This technique is called overcommit. OOM Killer (oom=out-of-memory) occurs when Linux discovers that there is not enough memory. It chooses to kill some processes (the user-state process, not the kernel thread) in order to free up memory. when oom-killer occurs, which processes does Linux choose to kill? Select the function of the process oom_badness function (in MM/OOM_KILL.C), which calculates the number of points (0~1000) per process. The higher the number of points, the more likely the process is to be killed. The number of points per process is related to Oom_score_adj, and Oom_score_adj can be set (-1000 min, 1000 max).

Iv. Solutions:

very simple, follow the instructions (set Vm.overcommit_memory to 1), There are three ways to modify kernel parameters, but to have root privileges:

1, edit/etc/sysctl.conf, change Vm.overcommit_memory=1, and then sysctl-p make the configuration file take effect

2, Sysctl Vm.overcommit_memory=1

3, echo 1 >/proc/sys/vm/overcommit_memory

Questions about Redis Overcommit_memory under Linux (GO)

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.