The basic use of oom and the actual use case

Source: Internet
Author: User

Scenario Description: In practical applications, when an oom anomaly occurs, it's not what we expect. We force the process to terminate, in fact, to shut down the service, causing the service to fail, to some extent, the system crashes or restarts or freezes, there is no difference. For the actual customer, the inability to provide the service itself is an exception, whether for the need of downtime or the cooling of the machine. In fact, we should all find the root of the problem. Under a lot of factors, we have not designed the Oom protection program to protect the whole system, on the contrary, it is through this mechanism to find out where the problem lies.

If we try to monitor our service program and whether it will cause oom, we can simply close the current process by increasing the coefficient of oom and when the whole system is out of memory. Let's look at a section of Oom code:

/* * Adjust the score by Oomkilladj. */if (P->oomkilladj) {if (P->oomkilladj > 0) Points <<= p->oomkilladj;elsepoints >>=-(p-> OOMKILLADJ);} Simple description: Points is the evaluation integer that the current process needs to terminate, the higher the value, the more likely the process is terminated, and p is the descriptor struct task_struct of the current process.

Full description of how to be able to modify the Oomkilladj parameter, any process under the/proc to generate a process flag folder, record the current process of some parameters, for example, we see through the PS Process ID number is 100, you can see things under/proc/100/. One of the Oom_adj parameters can be set, detailed settings are as follows:

Excerpt from: http://www.oracle.com/technetwork/articles/servers-storage-dev/oom-killer-1911807.html

echo >/proc/100/oom_adj

Of course, we can see from the moving position that cannot infinite move, otherwise extremes meet. The value is typically between 16 and 15.

Of course, the oom mechanism can also be closed by passing the following parameters:

Sysctl Vm.overcommit_memory=2echo "vm.overcommit_memory=2" >>/etc/sysctl.conf

The basic use of oom and the actual use case

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.