Linux OOM killer (Out of memory) and NFS server optimization

Posted on in Categories Linux, Troubleshooting, Tuning last updated August 18, 2006

OOM is short form for Out of memory. As name suggest it kills process randomly when the size of the data to be copied exceeds the size of physical memory i.e. when out of memory situation occurs OOM kills the lower priority process and frees the memory.

It is the job of the linux ‘oom killer’ to sacrifice one or more processes in order to free up memory for the system when all else fails.

Recently I fixed NFS related problem by setting vm.lower_zone_protection to 150 via sysctl facility. A reasonable value for lower_zone_protection is 150. But what is 150? It is 150 MB (approximately).

The lower_zone_protection tunable determines how aggressive the kernel is
in defending these lower zones. In simple words – I am preventing NFS eating up all memory and keeping my system stable. Remember 150MB will be reserved and not allocated to any one including applications, users, and cache.

Open your /etc/sysctl.conf and add following line (thanks to Alexander N. Spitzer for solution/hint):
# vi /etc/sysctl.conf
Append followin line:
vm.lower_zone_protection = 150
Save the change and reboot system. Mount NFS share and it will now able to create large file.

On the other hand, you can type the following command at shell prompt:
# echo 150 > /proc/sys/vm/lower_zone_protection

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

5 comment

  1. Sandro,

    OOM kills the lower priority process and frees the memory, if there are 10 process with lower priority process, OOM will select any random process from pool of 10 process. That is why I had used the word ‘random‘.

    However, the algorithm written by Linux kernel developer is quite smart to detect which process to kill. Unfortunately some time *smart algorithm* fails to work (for example my NFS Server) and it started to kill important process such as sendmail.

    That is why I had to control OOM via sysctl. Now system is stable. Correct me if I am wrong here.

    Appreciate your post.

  2. Specified lower_zone protection works for all applications? Like I have n number of applications running on host A, after adding one more application (n +1), host was stable for a week without any problem. But I got OOM killer issue after a week and started killing most of the processes one by one. To fix the issue I disabled n + 1 application and rebooted the host. Can I configure lower_zone protection to solve above problem?

Leave a Comment