How To Configure Swappiness Linux
How To Configure Swappiness
To find the current swappiness settings, type:
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:
If we check the system swappiness again, we can confirm that the setting was applied:
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.