Go to: disk Performance Parameters in proc in Linux

Source: Internet
Author: User

Disk Performance Parameters in proc in Linux

 

Notes: sorting and reprinting

Address: http://blog.chinaunix.net/uid-20321915-id-1966431.html

We have encountered a special performance problem on the server where disk write operations are constantly busy. Every 30 seconds, the server will encounter a peak of disk write activity, resulting in a very high request processing latency (more than 3 seconds ). Later, I checked the information online. by adjusting the kernel parameters, I distributed the peak Write activity into frequent writes, with less data written each time. In this way, you can flatten the peak write operations into multiple write operations. The execution efficiency in this way is relatively low, because the kernel does not have the opportunity to combine write operations. However, for busy servers, write operations will be performed more consistently and interactive performance will be greatly improved.
Below are the adjustments to relevant parameters:

I. In the 2.6 kernel

  1./proc/sys/Vm/dirty_ratio 
This parameter controls the size of the file system write buffer in the file system. The unit is the percentage, indicating the percentage of the system memory, indicating the amount of the system memory used by the write buffer, write Data to the disk. Increase
It uses more system memory for disk write buffering and can greatly improve system write performance. However, when you need continuous and constant writing, you should reduce the value ,:
Echo '1'>/proc/sys/Vm/dirty_ratio

  2./proc/sys/Vm/dirty_background_ratio  
This parameter controls the pdflush process of the file system and when to refresh the disk. The Unit is the percentage, indicating the percentage of the system memory, which means when the write buffer is used to the system memory
Wait, pdflush starts to write data to the disk. By increasing the size, you can use more system memory for disk write buffering and greatly improve the system write performance. However, when you need continuous and constant writing,
Reduce the value ,:
Echo '1'>/proc/sys/Vm/dirty_background_ratio

  3./proc/sys/Vm/dirty_writeback_centisecs
This parameter controls the run interval of the kernel's dirty data refresh process pdflush. Unit: 1/100 seconds. The default value is 500, that is, 5 seconds. If your system writes data continuously, it is better to reduce the value. In this way, you can split the peak write operation into multiple write operations. The setting method is as follows:
Echo "100">/proc/sys/Vm/dirty_writeback_centisecs if your system is a short-term peak write operation and the write data is not large (dozens of MB/Time) in addition, the memory is rich, so the value should be increased:
Echo "1000">/proc/sys/Vm/dirty_writeback_centisecs

4./proc/sys/Vm/dirty_expire_centisecs  
This parameter declares that the data in the write buffer in the Linux kernel is too old, and the pdflush process begins to consider writing data to the disk. Unit: 1/100 seconds. The default value is
30000, that is, 30
If the data in seconds is old, the disk will be refreshed. For write operations with special overloading, it is also good to narrow down this value, but it cannot be reduced too much, because too much will lead to Io increase too quickly.
Echo "100">/proc/sys/Vm/dirty_expire_centisecs
Of course, if your system memory is large and the write mode is intermittent, and the data written each time is not large (for example, dozens of MB), the value is better.

5./proc/sys/Vm/vfs_cache_pressure
This file indicates that the kernel is recycled for directory and inode
Cache memory preference; default value: 100 indicates that the kernel uses directory and inode according to pagecache and swapcache
Cache stays at a reasonable percentage; lowering this value below 100 will lead to kernel preference for directory and inode
Cache; when this value is increased by more than 100, the kernel tends to recycle directory and inode cache.
Default: 100

6./proc/sys/Vm/min_free_kbytes
This file indicates the minimum number of idle memory (Kbytes) reserved by the Linux VM ). Default setting: 724 (MB physical memory)

7./proc/sys/Vm/nr_pdflush_threads
  
This file indicates the number of currently running pdflush processes. When the I/O load is high, the kernel will automatically add more pdflush processes.
Default setting: 2 (read-only)

  8./proc/sys/Vm/overcommit_memory
  
This file specifies the kernel memory allocation policy. The value can be 0, 1, or 2.
0 indicates that the kernel will check whether there is enough available memory for use by the process. If there is enough available memory, the memory application will be allowed; otherwise, the memory application will fail, and return the error to the application process.
1 indicates that the kernel allows all physical memory allocation regardless of the current memory status.
2, indicating that the kernel can allocate more memory than the total physical memory and swap space (refer to overcommit_ratio ).
Default Value: 0.

9./proc/sys/Vm/overcommit_ratio
This file indicates that if overcommit_memory = 2, the percentage of memory can be overloaded. The following formula is used to calculate the overall available memory of the system.
System allocable memory = swap space + physical memory * overcommit_ratio/100 default settings: 50 (%)

10./proc/sys/Vm/page-Cluster
This file indicates the number of pages written when writing to the swap area once. 0 indicates 1 page, 1 indicates 2 pages, and 2 indicates 4 pages. Default settings: 3 (3 to the power of 2, 8 pages)

  11./proc/sys/Vm/swapiness
This file indicates the extent to which the system performs swap. The higher the value (0-100), the more likely disk swap will occur.

II. In the 2.4 kernel  

By modifying the file/proc/sys/Vm/bdflush. The nine parameters in the file are described as follows:
Nfract: maximum percentage of dirty buffer in the buffer zone. If this value is exceeded, the bdflush process is refreshed to the hard disk. When the available memory is small, a large amount of disk I/O will be triggered. To balance disk I/O, you can keep a low value.
Ndirty: Maximum number of dirty buffer blocks that the bdflush process writes to the disk at a time. This value is relatively large, resulting in a sharp increase in I/O. If this value is small, the execution of the bdflush process is insufficient, which may lead to memory bottlenecks.
Dummy2: not used
Dummy3: not used
Interval: minimum frequency of kupdated operation and refresh. The default value is 5 seconds. The minimum value is 0 seconds. The maximum value is 600 seconds.
Age_buffer: Maximum waiting time of the operating system before the buffer data is written to the disk. The default value is 30 seconds, and the minimum value is 1 second. The maximum value is 6000 seconds.
Nfract_sync: Percentage of bdflush Process Synchronization activated by dirty cache. The default value is 60%.
Nfract_stop: Percentage of bdflush processes stopped by dirty cache. The default value is 20%.
Dummy5: not used
For example, on a database server with frequent write operations:
10 500 0 0 50 30 10 0 0

------------------------ Hua --- Li --- points --- cut --- line ------------------------

Many online users are asking how to limit the size of the cache, but no answer is found after a round. One of the methods is to modify/Proc/sys/Vm/min_free_kbytesThis file sets its value to a larger value, and the cache is restricted accordingly. However, if this value is increased, it will not affect the system. It is unknown for the moment. Thank you!

Related Article

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.