Parameters for disk performance in Linux under Proc

Source: Internet
Author: User

We have had a special performance problem on a server where disk writes continue to be busy. Every 30 seconds, the server encounters a disk write activity spike that causes the request processing latency to be very large (more than 3 seconds). Later on the Internet to check the information, by adjusting the kernel parameters, the peak of the write activity is distributed to frequent multiple writes, each write less data. This can be used to flattened the peak write operation into multiple write operations. This is done in a less efficient way because the kernel does not have the opportunity to compose the write operation. But for busy servers, write operations will be more consistent and will greatly improve interactive performance.
Here is the adjustment of the relevant parameters:

One, 2.6 cores

  1,/proc/sys/vm/dirty_ratio 
This parameter controls the size of the file system write buffer for the filesystem, in percent, representing the percentage of system memory, indicating how much of the memory is used to write data to disk. Increased use of more system memory for disk write buffering can also greatly improve the write performance of the system. However, when you need a continuous, constant write situation, you should lower its 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 the disk is refreshed. The unit is a percentage that represents the percentage of system memory, meaning that when the write buffer is used to the amount of system memory, Pdflush begins writing data to the disk. Increased use of more system memory for disk write buffering can also greatly improve the write performance of the system. However, when you need a continuous, constant write situation, you should lower its 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. The unit is 1/100 seconds. The default value is 500, which is 5 seconds. If your system is continuously writing to the action, then actually it is better to lower this value, so that the spike write operation can be flattened into multiple writes. The Setup method is as follows:
echo "three" >/proc/sys/vm/dirty_writeback_centisecs if your system is short-term spike-type write operations, and the data is not very large (dozens of m/times) and the memory is much richer, you should increase this value:
echo "+" >/proc/sys/vm/dirty_writeback_centisecs

4,/proc/sys/vm/dirty_expire_centisecs  
This parameter declares that the Pdflush process begins to consider writing to disk when the data in the Linux kernel write buffer is "old". The unit is 1/100 seconds. The default is 30000, which means that 30 seconds of data is old and will flush the disk. For specially overloaded writes, it is good to shrink the value appropriately, but it does not shrink too much, because too much narrowing can cause the IO to improve too quickly.
echo "/proc/sys/vm/dirty_expire_centisecs" >
Of course, if your system memory is large, and the write mode is intermittent, and the data written every time is small (such as dozens of M), then this value is better.

5,/proc/sys/vm/vfs_cache_pressure
This file indicates that the kernel recycles the memory used by the directory and Inode caches, and the default value of 100 means that the kernel will keep the directory and inode caches at a reasonable percentage based on Pagecache and Swapcache. Lowering this value below 100 causes the kernel to tend to retain the directory and Inode caches, and increasing this value by more than 100 will cause the kernel to tend to recycle the directory and Inode caches
Default setting: 100

6,/proc/sys/vm/min_free_kbytes
This file represents the minimum amount of free memory (Kbytes) that the Linux VM is forced to keep. Default setting: 724 (512M physical memory)

7,/proc/sys/vm/nr_pdflush_threads
  
This file represents the number of Pdflush processes currently running, and the kernel will automatically add more Pdflush processes with high I/O load.
Default setting: 2 (Read only)

  8,/proc/sys/vm/overcommit_memory
  
This file specifies the kernel's policy for memory allocation, which can be 0, 1, 2.
0, indicates that the kernel will check for sufficient available memory to be used by the process, and if sufficient memory is available, the memory request is allowed; otherwise, the memory request fails and the error is returned to the application process.
1, which means that the kernel allows all physical memory to be allocated regardless of the current memory state.
2, which indicates that the kernel allows allocating more memory than the sum of all physical memory and swap space (refer to Overcommit_ratio).
Default setting: 0

9,/proc/sys/vm/overcommit_ratio
The file indicates that if overcommit_memory=2, the percentage of memory that can be overloaded, the overall available memory of the system is calculated by the following formula.
System assignable Memory = Swap space + physical memory *overcommit_ratio/100 default setting: 50 (%)

10,/proc/sys/vm/page-cluster
This file represents the number of pages written once to the swap area, 0 for 1 pages, 1 for 2 pages, and 2 for 4 pages. Default setting: 3 (2 of 3 parties, 8 pages)

  11,/proc/sys/vm/swapiness
The file represents the degree to which the system is exchanging behavior, and the higher the value (0-100), the more likely the disk exchange will occur.


Five. Summary

1. With these four parameters, you can control how much dirty data is consumed in memory to write to the disk file system;

2. How long the dirty data can exist in memory, and write to disk over this time;

3. The amount of dirty data in memory of a single task is written to disk;

The frequency at which the 4.pdflush kernel thread executes.

Six. Note

1. Distinguish between Dirty_background_ratio and dirty_ratio.

2. Database systems ORACLE and MySQL have many performance tuning based on the OS level. Even if the database is tuned, the specific parameters will be limited to the OS. Because the RDBMS is installed on the OS.

Seven. View these four parameters with the following command

Find/proc/sys/vm-name dirty*-print | while read name; do echo $name; Cat ${name}; Done

For example:

[Email protected] desktop]# find/proc/sys/vm-name dirty*-print | while read name; do echo $name; Cat ${name}; Done

/proc/sys/vm/dirty_expire_centisecs

2999

/proc/sys/vm/dirty_writeback_centisecs

499

/proc/sys/vm/dirty_ratio

40

/proc/sys/vm/dirty_background_ratio

10

[Email protected] desktop]#

Eight. Adjustment method

1. (Law i) vi/etc/sysctl.conf

And then modify it for example

Vm.dirty_ratio = 30

Sysctl-p Effective (restart active)

2. (France II) echo >/proc/sys/vm/dirty_ratio

echo >/proc/sys/vm/dirty_ratio

This method restarts invalid


Parameters for disk performance in Linux under Proc

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.