标签:文件的 日志文件 写入 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: 0 376 OS file reads, 54 OS file writes, 7 OS fsyncs 41.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
标签:文件的 日志文件 写入 show nod aio -- 场景 mysq
原文地址:http://www.cnblogs.com/JiangLe/p/7513846.html