Modify the swappiness of Linux swap space to reduce the hard disk cache.

Source: Internet
Author: User

Linux uses part of the hard disk as the swap partition for process scheduling-the process is running.Program-- Change unused processes to 'wait (standby') 'or even 'sleep (sleep)', and then 'Active )', sleep processes lie down in the SWAp partition to sleep, and leave the memory empty for the 'active' process.

If the memory is large enough, It should be told that Linux does not need to use too many swap partitions. You can modify swappiness
. When swappiness is set to 0, the physical memory is used to the maximum extent.
Swap space. When swappiness = 100, swap partitions are actively used, and the data in the memory is promptly moved to the swap space.

In ubuntu, the value of swappiness is set to 60 by default.

!!!! If the memory is small and the process is scheduled frequently, the hard disk will become larger !!!!

Currently, the memory size of 1 GB can be changed to 10, and the memory size of 2 GB can be changed to 5 or even 0. Specifically:
1. View swappiness in your system
$ CAT/proc/sys/Vm/swappiness
If nothing happens, you should see 60.
2. Change the value of swappiness to 10.
$ Sudo sysctl VM. swappiness = 10
However, this is only a temporary modification. After you restart the system, the default value of 60 will be restored. In order to ensure long-term stability, you must proceed further:
$ Sudo gedit/etc/sysctl. conf
Add the following line at the end of this document:
VM. swappiness = 10
Save and restart. OK. Your settings will take effect.

 

From: http://blog.sina.com.cn/s/blog_60aa9ccd0100h433.html

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.