LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   What does swappiness do ? (https://www.linuxquestions.org/questions/linux-newbie-8/what-does-swappiness-do-4175481105/)

LostObjext 10-16-2013 08:57 PM

What does swappiness do ?
 
What does swappiness do? I search it on wiki, but they explained it that I don't really fully understand. Any easy and simple way to explain it to me?

frankbell 10-16-2013 09:02 PM

Wikipedia can help. https://en.wikipedia.org/wiki/Swappiness

suicidaleggroll 10-16-2013 09:03 PM

The linux swap is used like a Windows paging file. It stores memory (from RAM) that hasn't been used in some time, to free up RAM for active processes that need it. It is also used as a dump location when the system runs out of RAM so that the computer doesn't lock up entirely (though if your swap is located on a typical HDD, the system might as well be locked up since response times will drop into the minutes or longer).

swappiness is a value that tells the kernel how aggressively it should dump old memory from RAM into the swap (in other words, it defines what "old" means). Setting the swappiness to 0 prevents the kernel from ever dumping old memory onto the swap (the swap will still be used if you run out of RAM and the machine needs a dump location though).


Personally, I feel that swappiness is an outdated parameter, a remnant from when RAM was expensive and it was necessary for the OS to dump RAM data to the HDD occasionally to keep some available RAM for the occasional process that needed it. These days, RAM is so incredibly cheap that there's really no reason not to over-deliver on RAM and prevent the need for swap entirely. On all of the systems I build (as of the last 5 years or so, back when RAM prices plummeted), I install more than enough RAM to cover the requirements of the job, set up some swap space as "backup", and set swappiness to 0.


All times are GMT -5. The time now is 06:59 AM.