• Recent Articles

    What is Swapiness and How to Change it?

    What is Swapiness and How to Change it?

    Swappiness is a property for the Linux kernel that changes the balance between swapping out run-time memory, as opposed to dropping pages from the system page cache. Swappiness can be set to values between 0 and 100, inclusive.A Low value means the kernel will try to avoid swappings as much as possible where a higher value instead will make kernel aggressively try to use swap space. "vm_swappiness" is the swappiness parameter, set to 60 by default.

    Why to Change it?

    The default value can not be fit to all scenarios. The swappiness value is a key parameter to evaluate the system performance. As the RAM become bigger and cheaper nowadays the system comes with larger memory configured. Hence the system may not need to use swap space. So the paging Operation and resources can be saved as well. The default parameter value set to “60” means that your kernel will swap when RAM reaches 40% capacity.if we change it to “100” means that your kernel will try to swap everything. Set it to 5 in larger system means that swap will be used when RAM is 95% full, so logically all the operation happen in the RAM (Respect to memory usage). 

    How to Change it?
    We can change this parameter run-time or make it persistent across the reboot. it is a text file which needs to be changed to get it implemented in run-time. 

    Before the Change:
    [root@dockerserver ~]# cat /proc/sys/vm/swappiness
    [root@dockerserver ~]#

    After the Change:
    [root@dockerserver ~]# echo 5 > /proc/sys/vm/swappiness
    [root@dockerserver ~]# cat /proc/sys/vm/swappiness
    [root@dockerserver ~]#

    To make the changes Permanent we need to edit the file /etc/sysctl.conf as root. Then  we need to add following entry "vm.swappiness=”value”"  and then save the file. 
    N.B: You can set the value to 0 or 100, which is permissible, but it is not recommended. 0 will completely disable the swapping, which means if the complete RAM is used in system the system unresponsive.

    No comments