Brief introduction
Swappiness,linux the kernel parameter to control the relative weight of the swap out run-time memory. The swappiness parameter value can be set in the range from 0 to 100. Low parameter values allow the kernel to use less swap, and higher parameter values will allow the kernel to make more of the swap space. The default value is 60 (refer to Network data: Start using swap space when the remaining physical memory is below 40% (40=100-60)). For most operating systems, setting to 100 may affect overall performance, while setting to a lower value (even 0) may reduce response latency.
swappiness parameter Value Description
vm.swappiness = 0
Use swap space only when there is insufficient memory-when the remaining free memory is below vm.min_free_kbytes limit.
vm.swappiness = 1
Kernel version 3.5 and above, Red hat kernel version 2.6.32-303 and above, for minimal switching without disabling switching.
Vm.swappiness = 10
When there is enough memory on the system, it is recommended to set this value to improve performance.
Vm.swappiness = 60
Default value
vm.swappiness = 100
The kernel will actively use swap space.
For kernel version 3.5 and above, Red hat kernel version 2.6.32-303 and above, in most cases, set to 1 may be better, 0 is suitable for the ideal case (it is likely better the use of 1 for cases where 0 used to Be optimal)
Modify swappiness the value
1) temporary settings (fail after reboot)
# Sysctl-a | grep vm.swappiness
Vm.swappiness = 30
# echo >/proc/sys/vm/swappiness
# Sysctl-a | grep vm.swappiness
# vm.swappiness = 10
The optional method is as follows
# sysctl-w vm.swappiness=10
Vm.swappiness = 10
# cat/proc/sys/vm/swappiness
10
2) Permanent settings
Edit in/etc/sysctl.conf, add the following parameters (if present)
Vm.swappiness = 10
Swappiness parameter setting and memory swapping