What is Swapiness and How to Change it?
What is Swapiness and How to Change it?
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
30
[root@dockerserver ~]#
30
[root@dockerserver ~]#
After the Change:
[root@dockerserver ~]# echo 5 > /proc/sys/vm/swappiness
[root@dockerserver ~]# cat /proc/sys/vm/swappiness
5
[root@dockerserver ~]#
[root@dockerserver ~]# cat /proc/sys/vm/swappiness
5
[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