当前位置:网站首页>MySQL performance tuning - dirty page refresh

MySQL performance tuning - dirty page refresh

2022-07-06 12:35:00 wx5caecf2ed0645


principle

When the contents of memory data page and disk data page are inconsistent , We call this memory page “ Dirty page ”. After memory data is written to disk , The contents of data pages on memory and disk are the same , be called “ Clean pages ”.

When the data page to be read is not in memory , You have to apply for a data page in the buffer pool . At this time, only the longest unused data page can be eliminated from memory : If it's a clean page to be eliminated , Just release it and reuse it ; But if it's a dirty page , You have to brush the dirty pages to disk first , It can only be reused after it becomes a clean page .

So the following two cases , It will obviously affect the performance :


  1. There are too many dirty pages to be eliminated in a query , The response time of the query will be significantly longer ;
  2. The log is full of , All updates are blocked , Writing performance has dropped to 0, For sensitive businesses , It is unacceptable .

therefore ,InnoDB There needs to be a mechanism to control the proportion of dirty pages , To try to avoid the above two situations .

Configuration tuning - innodb_io_capacity

innodb_io_capacity The default is 200, The unit is page , The setting size of this parameter depends on the size of the hard disk IOPS, That is, the input and output per second ( Or reading and writing times )

It will tell InnoDB Disk capabilities , So set this value to disk IOPS.

On disk IOPS Can pass fio This tool is used to test , The following statement is used to test the random read / write command of the disk :

       
fio -filename=$filename -direct=1 -iodepth 1 -thread -rw=randrw -ioengine=psync -bs=16k -size=500M -numjobs=10 -runtime=10 -group_reporting -name=mytest
  • 1.

Configuration tuning - innodb_flush_neighbors

InnoDB The storage engine also provides Flush Neighbor Page( Refresh adjacent pages ) Characteristics of . Its working principle is : When a dirty page is refreshed ,InnoDB The storage engine detects the location of the page (extent) All pages of , If it's dirty , So let's refresh together .

InnoDB1.2.x The version starts with parameters innodb_flush_neighbors, Used to control whether the feature is enabled .


This feature is recommended for traditional mechanical hard drives , For solid-state drives, it has a high IOPS Performance disk , It is recommended that this parameter be set to 0, That is, turn off the feature .




原网站

版权声明
本文为[wx5caecf2ed0645]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131527440911.html