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

by on August 18, 2006 · 4 comments· LAST UPDATED August 17, 2006

in , ,

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

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 4 comments… read them below or add one }

1 Sandro Tosi August 21, 2006 at 7:03 am

It doesn’t kill randomly! It select the “best” process to kill, as stated in the description page you linked in the page

Reply

2 nixCraft August 21, 2006 at 11:19 am

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.

Reply

3 Vasudeva October 16, 2009 at 8:33 pm

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?

Reply

4 Moses September 16, 2012 at 10:08 am

I’m not find variable on centos 6.X

cat /proc/sys/vm/lower_zone_protection

cat: /proc/sys/vm/lower_zone_protection: No such file or directory

Thanks

Reply

Leave a Comment

Previous post:

Next post: