Set Swappiness Value Centos 7 to enhance system performance

What is Swap Memory ?

Swap memory is virtual memory which provide redundancy to the main memory of the system.

Generally we provide twice of RAM memory to the SWAP but not often.

Swappiness Value?

Swappiness is the value after which the system start utilizing the SWAP memory. By default it is set on 60 but we can change this value according to our need.

How to set swappiness value?

Perform following steps to set the swappines value.

[root@web ~]# cat /proc/sys/vm/swappiness

60

If we want to temporary change this value we can do it using a simple echo:

[root@web ~]# echo 10 > /proc/sys/vm/swappiness

Now again check swappiness value that present in “/proc/sys/vm/swappiness”
[root@web ~]# cat /proc/sys/vm/swappiness

This setting is not permanent, to make it permanent we have to set in file /etc/sysctl.conf. Just go at the bottom of the file and paste the following lines

# vi /etc/sysctl.conf

vm.swappiness = 10

net.ipv4.ip_forward = 1

Now just save and reboot once to reflect the changed value of swappiness.

# reboot

done ! !

Scroll to Top