What is Swappiness

Swappiness has a value between 1 and 100 this controls how your system prioratises ram and swap usage, if you are unsure of what swap is then you may want to google this a bit but in short ram is the physical memory modules (ram) and swap is memory on your hard drive/ssd, swap is used when your system runs out of available ram so as a way of keeping the system running it moves data to the swap partition, in doing this it can affect system performance as your hard drive or SSD will be much much slower that your ram.
The swappiness value determins at which point the system will start to use swap in most cases you will want the system to use as much of the ram as posible before using swap, by default on liniux systems the swappiness value will default at around 60, from experiance I would normally recommend changing this to something between 10 and 30.

A swappiness value of 1 means avoid swap as much as possible and only use ram, where as a swappiness value of 100 means avoid ram as much as possible and only use swap.
By changing the default value you can get more performance out of your system if you have a lot of ram in your system and you do not use much of it then you could set the swappiness value to 1 although I would recommend 10 and then see how the system performs and make changes from that point, as a guide I would normally set a desktop with 8GB of ram to 10 and then see how it runs, in most cases this should be fine for a server I would set 20 but in most cases servers have a lot more ram available and some services will use available ram so this figure will probabily change depending on the use case but it's a good starting point.

How To Check Swappiness And Change

To check the current swappiness value run the following in your terminal window.

cat /proc/sys/vm/swappiness

To make a change to the value temporarily you can set the value by running the following.

sysctl vm.swappiness=10

To make the changes perminant on your system you will need to edit /etc/sysctl.conf and add in the swappiness value


Add a comment

0.0(0 votes)

Next Post Previous Post