The buffermem file is also closely related to the operation of the virtual memory VM subsystem of the Linux kernel. The value in this
file /proc/sys/vm/buffermem controls how much memory should be used for buffer memory in percentage. It is important to note that the percentage
is calculated as a percentage of total system memory.
The default setup for the buffermem parameters under Red Hat Linux is:
"2 10 60"
To change the values of buffermem, type the following command on your terminal:
[root@deep] /# echo "70 10 60" >/proc/sys/vm/buffermem
|
You may add the above commands to the
/etc/rc.d/rc.local script file and you'll not have to type it again the next time you reboot your system.
Edit the
/etc/sysctl.conf file and add the following line:
# Improve virtual memory performance
vm.buffermem = 70 10 60
|
You must restart your network for the change to take effect. The command to manually restart the network is the following:
[root@deep] /# /etc/rc.d/init.d/network restart
|
Setting network parameters [ OK ]
Bringing up interface lo [ OK ]
Bringing up interface eth0 [ OK ]
Bringing up interface eth1 [ OK ]
According to the
/usr/src/linux/Documentation/sysctl/vm.txt file, the first parameter 80 % means to use a minimum of 80 percent of memory for the buffer cache; the minimum percentage
of memory that should be spent on buffer memory.The last two parameters 10 and 60 are unused by the system so we dont need to change the defaults.
Depending of the amount of RAM you have in the server the value of 80% may vary. When your server is highly loaded and when all application are used, you can know in detail how much memory are required and
used by the system. 80 % for the buffermem parameters seem to be too much for systems under 256 MB of RAM. Doing a free -m command on the prompt your system will
display amount of free and used memory in the system. Once you have executed this command free -m, check for -/+ buffers/cache:values
and get the one related to the minimal (-) to set your value for buffermem.
Example 6-1. For 128 MB of RAM
128 * 80% = 102.4 MB
128 - 102.4 = 25.6 MB
|
total used free shared buffers cached
Mem: 124 121 3 30 43 48
-/+ buffers/cache: 29 95
Swap: 128 2 126
|
The result shows us that the
-/+ buffers/cache: need 29 MB at minimum to run the system properly and with 128 MB of RAM set at 80% we have only 25.6 MB available. Hmmm! problem, i guess.
so we go back to the calculator again and do this:
128 * 70% = 89.6
128 - 89.6 = 38.4 MB
|
well solved good!.
:
Look at /usr/src/linux/Documentation/sysctl/vm.txt for more information on how to improve kernel parameters related to virtual memory.