当前位置:网站首页>[MySQL 45 lecture -12] lecture 12 the reason why MySQL has a wind attack from time to time

[MySQL 45 lecture -12] lecture 12 the reason why MySQL has a wind attack from time to time

2022-06-11 02:34:00 You and other students

 Please add a picture description

12 | Why my MySQL It's going to shake ?

Preface

  • One SQL Sometimes very slow , And the scene is difficult to reproduce , reason ?

  • Make a metaphor

    • Powder board :redo log
    • Shopkeeper's memory : Memory
    • Account book : Data files
  • Dirty page : The contents of the memory data page and the disk data page are inconsistent

  • Brush dirty pages : Write memory pages to disk

  • Shake it : Maybe it's really dirty , Usually, a very fast update operation is performed to write memory and logs

What will trigger the database flush The process ?

    1. The powder board is full of , I can't remember
      (redo log It's full. , The system stops all update operations )
    • Try to avoid this situation , It's all blocked , The number of updates dropped to 0
    1. Business is so good , The shopkeeper can't remember
      ( Out of memory , To write dirty pages to disk )
    • Normal behavior , There should be a mechanism to control the proportion of dirty pages to avoid the following two situations

        1. Too many dirty pages to be eliminated , Results in longer response times for queries
        1. The log is full of , All updates are blocked
    1. Update the ledger when business is not busy
      (MySQL When the system is considered idle , Brush dirty pages )
    • The system is idle , No pressure
    1. Year end clearing book
      (MySQL Clean the dirty pages during normal shutdown )
    • The system is idle , No pressure

InnoDB Control strategy of brushing dirty pages

    1. tell InnoDB Of the host IO Ability
    • innodb_io_capacity

    • Factors affecting the speed of cleaning dirty pages

      • Dirty page ratio
      • redo log Write disk speed
    1. Continuous sitting mechanism for brushing dirty pages
    • innodb_flush_neighbors
    • When the neighbor of a dirty page is also a dirty page , Will brush together
    • Set the parameter to 0, Turn off the tandem mechanism

Take a chestnut

  • One memory configuration is 128GB,innodb_io_capacity=20000 Under the circumstances , It is normal to suggest that you will redo log Set to 4 individual 1GB file . If... Is set during configuration redo log Set to one 100MB file , What will happen ?( High configuration machine ,redo log Set what happens when it is too small .)

    • Every time a transaction is committed redo log, If the setting is too small, it will soon be filled , The system is forced to stop all updates , What happened : Disk pressure is low , But the database suffers intermittent performance degradation .
原网站

版权声明
本文为[You and other students]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020608018086.html