<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="replication-threads">
      </a>
      19.2.3 Replication Threads
     </h3>
    </div>
   </div>
  </div>
  <div class="toc">
   <dl class="toc">
    <dt>
     <span class="section">
      <a href="replication-threads-monitor-main.html">
       19.2.3.1 Monitoring Replication Main Threads
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="replication-threads-monitor-worker.html">
       19.2.3.2 Monitoring Replication Applier Worker Threads
      </a>
     </span>
    </dt>
   </dl>
  </div>
  <p>
   MySQL replication capabilities are implemented using the following
      types of threads:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <b>
       Binary log dump thread.
      </b>
      The source creates a thread to send the binary log contents
            to a replica when the replica connects. This thread can be
            identified in the output of
      <a class="link" href="show-processlist.html" title="15.7.7.31 SHOW PROCESSLIST Statement">
       <code class="literal">
        SHOW
            PROCESSLIST
       </code>
      </a>
      on the source as the
      <code class="literal">
       Binlog
            Dump
      </code>
      thread.
     </p>
    </li>
    <li class="listitem">
     <p>
      <b>
       Replication I/O receiver thread.
      </b>
      When a
      <a class="link" href="start-replica.html" title="15.4.2.4 START REPLICA Statement">
       <code class="literal">
        START REPLICA
       </code>
      </a>
      statement is issued on a replica server, the replica creates
            an I/O (receiver) thread, which connects to the source and
            asks it to send the updates recorded in its binary logs.
     </p>
     <p>
      The replication receiver thread reads the updates that the
          source's
      <code class="literal">
       Binlog Dump
      </code>
      thread sends (see
          previous item) and copies them to local files that comprise
          the replica's relay log.
     </p>
     <p>
      The state of this thread is shown as
      <code class="literal">
       Slave_IO_running
      </code>
      in the output of
      <a class="link" href="show-replica-status.html" title="15.7.7.35 SHOW REPLICA STATUS Statement">
       <code class="literal">
        SHOW REPLICA STATUS
       </code>
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <b>
       Replication SQL applier thread.
      </b>
      When
      <a class="link" href="replication-options-replica.html#sysvar_replica_parallel_workers">
       <code class="literal">
        replica_parallel_workers
       </code>
      </a>
      is
            equal to 0, the replica creates an SQL (applier) thread to
            read the relay log that is written by the replication
            receiver thread and execute the transactions contained in
            it. When
      <code class="literal">
       replica_parallel_workers
      </code>
      is
      <code class="literal">
       <em class="replaceable">
        <code>
         N
        </code>
       </em>
       &gt;= 1
      </code>
      ,
            there are
      <em class="replaceable">
       <code>
        N
       </code>
      </em>
      applier threads and
            one coordinator thread, which reads transactions
            sequentially from the relay log, and schedules them to be
            applied by worker threads. Each worker applies the
            transactions that the coordinator has assigned to it.
     </p>
    </li>
   </ul>
  </div>
  <p>
   You can enable further parallelization for tasks on a replica by
      setting the system variable
   <code class="literal">
    replica_parallel_workers
   </code>
   to a value greater
      than 0. When this is done, the replica creates the specified
      number of worker threads to apply transactions, plus a coordinator
      thread which reads transactions from the relay log and assigns
      them to workers. A replica with
   <code class="literal">
    replica_parallel_workers
   </code>
   (
   <code class="literal">
    slave_parallel_workers
   </code>
   ) set to a value greater
      than 0 is called a multithreaded replica. If you are using
      multiple replication channels, each channel has the number of
      threads specified using this variable.
  </p>
  <p>
   Multithreaded replicas are also supported by NDB Cluster. See
   <a class="xref" href="mysql-cluster-replication-mta.html" title="25.7.11 NDB Cluster Replication Using the Multithreaded Applier">
    Section 25.7.11, “NDB Cluster Replication Using the Multithreaded Applier”
   </a>
   , for more
      information.
  </p>
 </div>
 <br/>
</div>
