I need Step by Step, simple and easy way to configure swappiness.
The Linux kernel provides a tweakable setting that controls how often the swap file is used, called swappiness
A swappiness setting of zero means that the disk will be avoided unless absolutely necessary (you run out of memory), while a swappiness setting of 100 means that programs will be swapped to disk almost instantly.
Ubuntu system comes with a default of 60, meaning that the swap file will be used fairly often if the memory usage is around half of my RAM. You can check your own system's swappiness value by running:
As I have 4 GB of RAM, so I'd like to turn that down to 10 or 15. The swap file will then only be used when my RAM usage is around 80 or 90 percent. To change the system swappiness value, open
Reboot for the change to take effect
You can also change the value while your system is still running
you can also clear your swap by running
To calculate your swap Formula
so what it mean is that when 10 % 395 MB of ram left then it start using swapiness
What is swappiness
The swappiness parameter controls the tendency of the kernel to move processes out of physical memory and onto the swap disk. Because disks are much slower than RAM, this can lead to slower response times for system and applications if processes are too aggressively moved out of memory.
. swappiness can have a value of between 0 and 100
. swappiness=0 tells the kernel to avoid swapping processes out of physical memory for as long as possible
. swappiness=100 tells the kernel to aggressively swap processes out of physical memory and move them to swap cache
The default setting in Ubuntu is swappiness=60. Reducing the default value of swappiness will probably improve overall performance for a typical Ubuntu desktop installation. A value of swappiness=10 is recommended, but feel free to experiment.
Started Using swap at 91%
As I have configured my system & vm to make use of ram at 90 % . At 90 % there was no swapping
after that I opened some application like Firefox & Shutter , its start swapping because of ram usage is above 90 %
|show 2 more comments|
Actually, without repeating what @psusi and @Jon already wrote in the comments, reducing swappiness increases perceived performance, read: it improves interactivity. But overall you are loosing performance on a memory constrained system because you are trading filesystem cache against swap usage. The system is faster at reading from swap than looking up data again on the filesystem (by digging thru directories, inodes, and extents). At a first glance this may not sound logical because your perception tells you otherwise, but: swapping-in is a blocking process for an application you are going to use, so it hurts interactivity. However, when putting the swap partition at the start of your harddisk (which is generally a good idea) the head may need to do wide seeks to gather swap data and filesystem data when your current IO pattern requests that. So swap should be put between a smaller root partition and your home partition, or (even better) onto a separate disk (e.g. where your Windows installation is when dual booting from a second disk), or on headless media (SSD). So depending on your IO pattern it may help to reduce swappiness, but generally it does not. For SSD I might even suggest to experiment with increasing swappiness.