Get the App
SLTechnology News&Howtos  ›  Servers  › 

Optimization of swappiness parameters between memory and swap Partition in linux system

Shulou Source: shulou.com Published: 2022-06-02 05:59:23 09月18日 Update

Http://blog.itpub.net/29371470/viewspace-1250975

The size of the value of swappiness has a lot to do with how swap partitions are used. Swappiness=0 means to maximize the use of physical memory, followed by swap space, and swappiness=100 means to actively use swap partitions and move the data in memory to swap space in time. The basic default setting for linux is 60, as shown below:

[root@timeserver ~] # cat / proc/sys/vm/swappiness

sixty

[root@timeserver]

In other words, the use of swap partitions begins to appear when you use 100-60% of your memory. As we all know, the speed of memory will be much faster than that of disk, which will increase the io of the system. At the same time, a large number of pages will be swapped in and out, seriously affecting the performance of the system. So at the operating system level, we should use memory as much as possible and adjust this parameter.

The method of temporary adjustment is as follows, we adjust it to 10:

[root@timeserver ~] # sysctl vm.swappiness=10

Vm.swappiness = 10

[root@timeserver ~] # cat / proc/sys/vm/swappiness

ten

[root@timeserver ~] #

This is only a temporary adjustment. After rebooting, you will return to the default setting.

To make a permanent adjustment, you need to modify it in / etc/sysctl.conf, plus:

[root@timeserver ~] # cat / etc/sysctl.conf

# Controls the maximum number of shared memory segments, in pages

Kernel.shmall = 4294967296

Vm.swappiness=10

[root@timeserver] # sysctl-p

This completes the modification of the settings!

Tags: Memory adjustment system time method space parameters very large maximum operating system that is just at the same time size as much as possible level performance data appearance Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Docker Shulou Technology Apple macOS