CentOS - How To Configure Swappiness | hrace009 Personal Community

CentOS How To Configure Swappiness

hrace009

Administrator
Staff member
#1
swappiness-feaured.png
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:
Bash:
cat /proc/sys/vm/swappiness
Result:
Bash:
60
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:
Bash:
sysctl vm.swappiness=10
Result:
Bash:
vm.swappiness=10
If we check the system swappiness again, we can confirm that the setting was applied:
Bash:
cat /proc/sys/vm/swappiness
Result:
Bash:
10
To make your VPS automatically apply this setting every time it boots up, you can add the setting to the /etc/sysctl.conf file:
Bash:
sudo nano /etc/sysctl.conf
Search for the vm.swappiness setting. Uncomment and change it as necessary or add it if not available.
Bash:
vm.swappiness=10
By Etel Sverdlov
 
Last edited:
Top