The operating system kernel can adjust how often it relies on swap through a configuration parameter known as swappiness.
To find the current swappiness settings, type:
Result:
Swapiness can be a value from 0 to 100. Swappiness near 100 means that the operating system will swap often and usually, too soon. Although swap provides extra resources, RAM is much faster than swap space. Any time something is moved from RAM to swap, it slows down.
A swappiness value of 0 means that the operating will only rely on swap when it absolutely needs to. We can adjust the swappiness with the sysctl command:
Result:
If we check the system swappiness again, we can confirm that the setting was applied:
Result:
To make your VPS automatically apply this setting every time it boots up, you can add the setting to the /etc/sysctl.conf file:
Search for the vm.swappiness setting. Uncomment and change it as necessary or add it if not available.
By Etel Sverdlov
To find the current swappiness settings, type:
Bash:
cat /proc/sys/vm/swappiness
Bash:
60
A swappiness value of 0 means that the operating will only rely on swap when it absolutely needs to. We can adjust the swappiness with the sysctl command:
Bash:
sysctl vm.swappiness=10
Bash:
vm.swappiness=10
Bash:
cat /proc/sys/vm/swappiness
Bash:
10
Bash:
sudo nano /etc/sysctl.conf
Bash:
vm.swappiness=10
Last edited: