Search This Blog

Monday, December 15, 2014

Linux swappiness parameter

The swappiness parameter controls the tendency of the kernel to move processes out of physical memory and onto the swap disk. Because disks are much slower than RAM, this can lead to slower response times for system and applications if processes are too aggressively moved out of memory.
  • swappiness can have a value of between 0 and 100
  • swappiness=0 tells the kernel to avoid swapping processes out of physical memory for as long as possible
  • swappiness=100 tells the kernel to aggressively swap processes out of physical memory and move them to swap cache
The default setting in RedHat is swappiness=60. Reducing the default value of swappiness will probably improve overall performance. A value of swappiness=10 is recommended, but feel free to experiment.
To check the current swappiness value:
cat /proc/sys/vm/swappiness
To change the swappiness value A temporary change (lost on reboot) with a swappiness value of 10 can be made with
sysctl vm.swappiness=10
To make a change permanent, edit the configuration file /etc/sysctl.conf with your favorite editor. Search for vm.swappiness and change its value as desired. If vm.swappiness does not exist, add it to the end of the file like so:
vm.swappiness=10
Save the file and run the this command to apply your change:
sysctl -p
you can also clear your swap by running swapoff -a and then vm.swapon -a as root instead of rebooting to achieve the same effect.

No comments:

Post a Comment