Line
Skip to main content
< All Topics
Print

What is Swappiness in Linux?

Here we know that RAM has a micro-segmentation view. And there is a concept of Virtual Memory with various types of Pages to help support flexible management of memory space. There is another term that must be mentioned: Swapping, or a technique that helps write RAM data to a certain area on the hard disk (Swap Space as shown) to help reduce RAM space, then bring the data back when the process that is using the RAM space is finished. Swap space is definitely a matter of fixed size. However, Swappiness It does not play a role in determining this area at all and does not determine the Threshold of the RAM usage rate that will occur with Swapping.

Swappiness is just one parameter in the Linux Kernel that influences the frequency of swapping of Anonymous Pages and file-backed files, which requires choosing between them. Swappiness ranges from 0 to 200 and defaults to Basic number 60

  • If you have a lot of physical memory to store in RAM or an old hard drive that is slow. It would be better to reduce I/O involvement, which can be achieved by reducing the Swappiness value
  • Conversely, if RAM is small and the workload can benefit from frequent swapping, then the Swappiness value can be increased.

 Commands about Swappiness in Linux

You can check the Swappiness value in any OS with the command

proc/sys/vm/swappiness%20or%20sysctl%20vm.swappiness

Edit the swappiness value with the command

sudo sysctl vm.swappiness=[value]

You can configure it to be permanent and won’t disappear when you reboot

nano /etc/sysctl.conf and vm.swappiness = [value]

There is no middle ground for tuning Swappiness, but it is something administrators must test and monitor performance on an ongoing basis. However, you may usually refer to the recommendations from some database vendors, but most of them usually have their own good internal mechanisms Of course, if you are a general user, just know that “Swappiness is not a mechanism to prevent memory from being full in any way. But without this mechanism, it would be very difficult for Linux to manage memory well.”

Credit : Swappiness ใน Linux คืออะไร – TechTalkThai

Messenger