How To Configure Swappiness
To find the current swappiness settings, type:
cat /proc/sys/vm/swappiness
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.
- If we have more RAM on the server its better to leave the swappiness to a lower value like 10.
- Also if we are using the server as a Hadoop Datanode and has enough RAM on hand then we set it lower value.
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:
sysctl vm.swappiness=10
vm.swappiness=10
If we check the system swappiness again, we can confirm that the setting was applied:
cat /proc/sys/vm/swappiness
10
To make changes permanent, you can add the setting to the /etc/sysctl.conf file:
sudo nano /etc/sysctl.conf
Add the below line.
# Search for the vm.swappiness setting. Uncomment and change it as necessary.
vm.swappiness=10
Comments
Post a Comment