Change Linux swappiness to increase physical memory utilization

Source: Internet
Author: User

The size of the swappiness value is very much associated with how the swap partition is used.

Swappiness=0 means to maximize the use of physical memory, then the swap space, swappiness=100 when the active use of the swap partition, and the memory of the data in a timely manner into the swap space.

When this parameter = 0, it means that whenever possible, try to avoid the swap process from moving out of physical memory; This parameter = 100, which tells the kernel to move data out of physical memory to the swap cache.

This value is just a "propensity" reference value for Linux to determine whether to swap memory (swap), not to say that Linux does not use memory swap space at all after setting to 0

the basic default setting for Linuxis as follows:

[Email protected] ~]# cat/proc/sys/vm/swappiness
60


In other words, when your memory is used to 100-60=40%, it starts to appear with the swap partition. As you know, the memory speed will be much faster than the disk, this will increase the system IO, at the same time create a large number of pages in the swap out, seriously affect the performance of the system, so we at the operating system level, we should use memory, to adjust the parameter.

The method of temporary adjustment is as follows: We suggest adjusting the range 1~10

[Email protected] ~]# sysctl vm.swappiness=10
Vm.swappiness = 10
[Email protected] ~]# cat/proc/sys/vm/swappiness
10
This is only a temporary adjustment method, and will return to the default settings after reboot.

If you want to make a permanent adjustment, you need to
Need to be modified in/etc/sysctl.conf, plus:
[Email protected] ~]# cat/etc/sysctl.conf
# Controls The maximum number of shared memory segments, in pages
Kernel.shmall = 4294967296
vm.swappiness=10

[Email protected] ~]# sysctl-p
This completes the modification settings!

Change Linux swappiness to increase physical memory utilization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.