<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Load balancing</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mysqlnd-ms.failover.html">Failover</a></div> <div class="next" style="text-align: right; float: right;"><a href="mysqlnd-ms.rwsplit.html">Read-write splitting</a></div> <div class="up"><a href="mysqlnd-ms.concepts.html">Concepts</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="mysqlnd-ms.loadbalancing" class="section"> <h2 class="title">Load balancing</h2> <p class="para"> Four load balancing strategies are supported to distribute statements over the configured MySQL slave servers: </p> <p class="para"> <dl> <dt> <span class="term">random</span> <dd> <p class="para"> Chooses a random server whenever a statement is executed. </p> </dd> </dt> <dt> <span class="term">random once (default)</span> <dd> <p class="para"> Chooses a random server after the first statement is executed, and uses the decision for the rest of the PHP request. </p> <p class="para"> It is the default, and the lowest impact on the connection state. </p> </dd> </dt> <dt> <span class="term">round robin</span> <dd> <p class="para"> Iterates over the list of configured servers. </p> </dd> </dt> <dt> <span class="term">user-defined via callback</span> <dd> <p class="para"> Is used to implement any other strategy. </p> </dd> </dt> </dl> </p> <p class="para"> The load balancing policy is configured in the plugins configuration file using the <a href="mysqlnd-ms.plugin-ini-json.html#ini.mysqlnd-ms-plugin-config-v2.filter-random" class="link">random</a>, <a href="mysqlnd-ms.plugin-ini-json.html#ini.mysqlnd-ms-plugin-config-v2.filter-roundrobin" class="link">roundrobin</a>, and <a href="mysqlnd-ms.plugin-ini-json.html#ini.mysqlnd-ms-plugin-config-v2.filter-user" class="link">user</a> <a href="mysqlnd-ms.filter.html" class="link">filters</a>. </p> <p class="para"> Servers can be prioritized assigning a weight. A server that has been given a weight of two will get twice as many requests as a server that has been given the default weight of one. Prioritization can be handy in heterogenous environments. For example, you may want to assign more requests to a powerful machine than to a less powerful. Or, you may have configured servers that are close or far from the client, thus expose different latencies. </p> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mysqlnd-ms.failover.html">Failover</a></div> <div class="next" style="text-align: right; float: right;"><a href="mysqlnd-ms.rwsplit.html">Read-write splitting</a></div> <div class="up"><a href="mysqlnd-ms.concepts.html">Concepts</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>