mysql-5.7 Using Asynchronous I/O on Linux

來源:互聯網
上載者:User

標籤:檔案的   記錄檔   寫入   show   nod   aio   --   情境   mysq   

一、mysql - innodb 使用非同步IO的情境

  總的來說innodb 只會對資料檔案採用非同步IO,為了儲存日誌是真正被寫入到磁碟,innodb不會對記錄檔啟用非同步IO

  更新細一步的說,innodb只會對資料檔案的read-ahead ,write 這兩個操作啟用非同步IO

 

二、非同步IO在mysql中解決了什麼問題:

  在沒有IO這個功能之前,innodb對資料的讀寫請求先放入任務隊列,後台read-thread ,write-thread從任務隊列中

  拿出任務並執行讀寫操作;後台讀寫線程的個數可以通過show engine innodb status 語句來查看

show engine innodb status;--------FILE I/O--------I/O thread 0 state: waiting for i/o request (insert buffer thread)I/O thread 1 state: waiting for i/o request (log thread)I/O thread 2 state: waiting for i/o request (read thread)I/O thread 3 state: waiting for i/o request (read thread)I/O thread 4 state: waiting for i/o request (read thread)I/O thread 5 state: waiting for i/o request (read thread)I/O thread 6 state: waiting for i/o request (write thread)I/O thread 7 state: waiting for i/o request (write thread)I/O thread 8 state: waiting for i/o request (write thread)I/O thread 9 state: waiting for i/o request (write thread)Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] , ibuf aio reads:, log i/o‘s:, sync i/o‘s:Pending flushes (fsync) log: 0; buffer pool: 0376 OS file reads, 54 OS file writes, 7 OS fsyncs41.77 reads/s, 21886 avg bytes/read, 6.00 writes/s, 0.78 fsyncs/s

  由上面的內容可以看出預設情況下innodb會有4個read-thread 和4個write-thread ,問題就出現在這裡,如果業務繁重,那麼

  讀寫任務就會非常的多,而innodb只有八個讀寫線程,這樣的話隊列中的其它讀寫請求就沒能得到及時的響應。

  

  引入非同步IO之後就變天啦,讀寫請求不再像之前那樣先放入隊列,等著背景讀寫線程去執行任務;

 

 

----

mysql-5.7 Using Asynchronous I/O on Linux

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.