<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="innodb-linux-native-aio">
      </a>
      17.8.6 Using Asynchronous I/O on Linux
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045162705696">
  </a>
  <a class="indexterm" name="idm46045162704240">
  </a>
  <a class="indexterm" name="idm46045162702752">
  </a>
  <a class="indexterm" name="idm46045162701680">
  </a>
  <p>
   <code class="literal">
    InnoDB
   </code>
   uses the asynchronous I/O subsystem
      (native AIO) on Linux to perform read-ahead and write requests for
      data file pages. This behavior is controlled by the
   <a class="link" href="innodb-parameters.html#sysvar_innodb_use_native_aio">
    <code class="literal">
     innodb_use_native_aio
    </code>
   </a>
   configuration option, which applies to Linux systems only and is
      enabled by default. On other Unix-like systems,
   <code class="literal">
    InnoDB
   </code>
   uses synchronous I/O only. Historically,
   <code class="literal">
    InnoDB
   </code>
   only used asynchronous I/O on Windows
      systems. Using the asynchronous I/O subsystem on Linux requires
      the
   <code class="literal">
    libaio
   </code>
   library.
  </p>
  <p>
   With synchronous I/O, query threads queue I/O requests, and
   <code class="literal">
    InnoDB
   </code>
   background threads retrieve the queued
      requests one at a time, issuing a synchronous I/O call for each.
      When an I/O request is completed and the I/O call returns, the
   <code class="literal">
    InnoDB
   </code>
   background thread that is handling the
      request calls an I/O completion routine and returns to process the
      next request. The number of requests that can be processed in
      parallel is
   <em class="replaceable">
    <code>
     n
    </code>
   </em>
   , where
   <em class="replaceable">
    <code>
     n
    </code>
   </em>
   is the number of
   <code class="literal">
    InnoDB
   </code>
   background threads. The number of
   <code class="literal">
    InnoDB
   </code>
   background threads is controlled by
   <a class="link" href="innodb-parameters.html#sysvar_innodb_read_io_threads">
    <code class="literal">
     innodb_read_io_threads
    </code>
   </a>
   and
   <a class="link" href="innodb-parameters.html#sysvar_innodb_write_io_threads">
    <code class="literal">
     innodb_write_io_threads
    </code>
   </a>
   . See
   <a class="xref" href="innodb-performance-multiple_io_threads.html" title="17.8.5 Configuring the Number of Background InnoDB I/O Threads">
    Section 17.8.5, “Configuring the Number of Background InnoDB I/O Threads”
   </a>
   .
  </p>
  <p>
   With native AIO, query threads dispatch I/O requests directly to
      the operating system, thereby removing the limit imposed by the
      number of background threads.
   <code class="literal">
    InnoDB
   </code>
   background
      threads wait for I/O events to signal completed requests. When a
      request is completed, a background thread calls an I/O completion
      routine and resumes waiting for I/O events.
  </p>
  <p>
   The advantage of native AIO is scalability for heavily I/O-bound
      systems that typically show many pending reads and writes in
   <code class="literal">
    SHOW ENGINE INNODB STATUS
   </code>
   output. The increase
      in parallel processing when using native AIO means that the type
      of I/O scheduler or properties of the disk array controller have a
      greater influence on I/O performance.
  </p>
  <p>
   A potential disadvantage of native AIO for heavily I/O-bound
      systems is lack of control over the number of I/O write requests
      dispatched to the operating system at once. Too many I/O write
      requests dispatched to the operating system for parallel
      processing could, in some cases, result in I/O read starvation,
      depending on the amount of I/O activity and system capabilities.
  </p>
  <p>
   If a problem with the asynchronous I/O subsystem in the OS
      prevents
   <code class="literal">
    InnoDB
   </code>
   from starting, you can start
      the server with
   <a class="link" href="innodb-parameters.html#sysvar_innodb_use_native_aio">
    <code class="literal">
     innodb_use_native_aio=0
    </code>
   </a>
   . This
      option may also be disabled automatically during startup if
   <code class="literal">
    InnoDB
   </code>
   detects a potential problem such as a
      combination of
   <code class="literal">
    tmpdir
   </code>
   location,
   <code class="literal">
    tmpfs
   </code>
   file system, and Linux kernel that does
      not support asynchronous I/O on
   <code class="literal">
    tmpfs
   </code>
   .
  </p>
 </div>
 <br/>
</div>
