1. Pdflush Refresh dirty Data condition(Introduction to the principles and parameters of Linux io kernel parameter tuning) The previous section describes the key parameter parameters of the IO kernel tuning. It is concluded that the dirty data in cached is flushed to disk by Pdflush when one or more of the following conditions are met:
(1)Data exists longer than Dirty_expire_centisecs (default 30s) time
(2)Dirty data takes up memory/(Memfree + cached-mapped) > Dirty_background_ratio. This means that when the dirty data occupies a memory(Memfree + cached-mapped) memory will trigger Pdflush refresh of dirty data when the memory ratio exceeds dirty_background_ratio.It can be seen that the two parameters are connected. For example, the DIRTY_EXPIRE_CENTISECSS setting is smaller, then the Pdflush will refresh the dirty data will increase the frequency, which will make dirty data accounted for the total memory ratio will not reach dirty_background_ratio, which makes Dirty_ The Background_ratio parameter has no effect. Conversely, if the Dirty_background_ratio parameter is set very small and the dirty_expire_centisecs setting is large, it may be before the expiration time is reachedDirty data is flushed to disk by Pdflush.
2. Parameter Tuning
If there is a large amount of dirty data in the system's cached, there are two problems:
A.The more data is cached, the greater the risk of data loss.
B.IO spikes occur periodically, and the peak time is longer, during which all new write IO performance will be poor (in extreme cases it is directly stuck).The latter issue has a significant impact on applications with high write loads.
How can I adjust the kernel IO parameters to optimize IO write performance?
(1) First tuning dirty_background_ratio This parameter is appropriately reduced, this can make the cached main dirty data reduction, the original large IO refresh operation into a number of small IO refresh operations, so that the IO write peak flattened. For scenarios where the cached is large or the disk is slow, this value should be set to a smaller point. Adjustment method: Echo 5 >>/proc/sys/vm/dirty_background_ratio This percentage to 5% (note that the percentage here is for:Memfree + cached-mapped, not relative to Memtotal)
(2) The second step to adjust the Dirty_ratio parametersThis parameter is suitably adjusted to a small, principle (1) similar. If the percentage of cached's dirty data (this is the percentage of memtotal) exceeds this setting, the system stops all IO writes for the application layer, waiting for the IO to resume after the data has been brushed. So in case the system is triggered this operation, for the user has a very large impact.
(3) The third step adjusts the Dirty_expire_centisecs parameter (this parameter indicates how long the data in the page cache is marked as dirty)This parameter adjustment may be of little significance. This parameter does not guarantee that dirty data can be flushed quickly because there is an IO congestion problem. if in aFailure to finish the dirty data during the Dirty_expire_centisecs cycle can cause this parameter to fail. Ideally we want a dirty_expire_centisecs to finish brushing dirty data, but if cached has more dirty data or a slow disk, it can cause IO congestion. It is generally good to use the default value.
(4) Fourth step adjustment dirty_writeback_centisecs parameter (this parameter adjusts the frequency that Pdflush is awakened)In theory, this parameter can be adjusted to increase the Pdflush operating frequency, so that dirty data will be flushed to disk as soon as possible. But this is the same as encountering the third-step IO congestion problem. So the effect of this parameter is not satisfactory. It is generally good to use the default value.
3. Swapping tuningswap space is a piece of disk space, the operating system uses this space to save the operating system swapped out from memory is not commonly used page data, so that can allocate more memory to do page cache. This usually increases the throughput and IO performance of the system, but it also causes a lot of problems. Frequent swapping of pages will result in IO Read and write, operating system interrupts, which can affect the performance of the system. The larger the value, the more aggressively the swap space will be used by the operating system.
Adjust the Swappniess method as follows:cat/proc/sys/vm/swappniess View the configuration of this parameter (the default value isEcho 0 >>/proc/sys/vm/swappniess prohibits the operating system from using any swap spaceEcho >>/proc/sys/vm/swappniess operating system will try to use swap spaceswappniess setting an appropriate value can also have a noticeable effect on system performance. Swappniess is very small, the system can concurrently process or thread will be reduced, but each process or thread runs faster, CPU utilization is better. when the swappniess is large, the system is in good concurrency, but each process or thread is slower. More IO read-write and system outages consume a lot of CPU resources, which makes the system less efficient. Therefore, if you want to increase the concurrency of the server, the time required for the service is not very high scene can be appropriate to adjust the swappniess higher. For applications that have little concurrency but want to have a small amount of time, this parameter can be appropriately adjusted, such as a PC that can directly disable swap.
(turn) tuning of Linux IO kernel parameters and scene analysis