mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-28 14:58:55 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@317311 c90b9560-bf6c-de11-be94-00142212c4b1
233 lines
7.8 KiB
XML
Executable file
233 lines
7.8 KiB
XML
Executable file
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
|
|
<book xml:id="book.mysqlnd-ms" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<title>Mysqlnd replication and load balancing plugin</title>
|
|
<titleabbrev>mysqlnd_ms</titleabbrev>
|
|
|
|
<preface xml:id="intro.mysqlnd-ms">
|
|
&reftitle.intro;
|
|
<para>
|
|
The mysqlnd replication and load balancing plugin (<literal>mysqlnd_ms</literal>)
|
|
adds easy to use MySQL replication support to all PHP MySQL extensions that use
|
|
<link linkend="book.mysqlnd">mysqlnd</link>.
|
|
</para>
|
|
<para>
|
|
As of version PHP 5.3.3 the MySQL native driver for PHP
|
|
(<literal>mysqlnd</literal>)
|
|
features an internal plugin C API. C plugins, such as the replication and
|
|
load balancing plugin, can extend the functionality of
|
|
<link linkend="book.mysqlnd">mysqlnd</link>.
|
|
</para>
|
|
<para>
|
|
The MySQL native driver for PHP is a C library which ships together with
|
|
PHP as of PHP 5.3.0. It serves as a drop-in replacement for the
|
|
MySQL Client Library (AKA libmysql/libmysqlclient). Using mysqlnd has
|
|
several advantages: no extra downloads because it comes with PHP,
|
|
PHP license, lower memory consumption in certain cases,
|
|
new functionality such as asynchronous queries. As of PHP 5.4.0, mysqlnd is
|
|
the compile time default library used by all PHP MySQL extensions
|
|
(<link linkend="ref.mysqli">mysqli</link>,
|
|
<link linkend="ref.mysql">mysql</link>,
|
|
<link linkend="ref.pdo-mysql">PDO_MYSQL</link>).
|
|
</para>
|
|
<para>
|
|
Mysqlnd plugins such as the replication and load balancing plugin operate
|
|
mostly transparent from an user perspective. The replication and load balancing
|
|
plugin supports all PHP applications
|
|
and all PHP MySQL extensions.
|
|
It does not change existing APIs. Therefore, it can easily be used with
|
|
existing PHP applications.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
The mysqlnd replication and load balancing plugin is in beta status.
|
|
It is not feature complete.
|
|
</para>
|
|
</note>
|
|
<section xml:id="mysqlnd-ms.key_features">
|
|
<title>Key Features</title>
|
|
<para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
Transparent and therefore easy to use.
|
|
</para>
|
|
<para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
Supports all of the PHP MySQL extensions.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
A consistent <acronym>API</acronym>.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Little to no application changes required, dependent on the required usage scenario.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Lazy connections: connections to master and slave servers are not
|
|
opened before a SQL statement is executed.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Optional: automatic use of master after the first write in a web request, to
|
|
lower the possible impact of replication lag.
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>
|
|
Featured read-write split strategies
|
|
</para>
|
|
<para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
Automatic detection of SELECT.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Supports SQL hints to overrule automatism.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
User-defined.
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>
|
|
Featured load balancing strategies
|
|
</para>
|
|
<para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
Round Robin: choose a different slave in round-robin fashion for every slave request.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Random: choose a random slave for every slave request.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Random once (sticky): choose a random slave once to run all slave requests for the duration of a web request.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
User-defined. The application can register callbacks with mysqlnd_ms.
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</section>
|
|
|
|
<section xml:id="mysqlnd-ms.limitations">
|
|
<title>Limitations</title>
|
|
<para>
|
|
The plugin does not support MySQL replication setups with more
|
|
than one master server. An experimental configuration setting
|
|
<link linkend="ini.mysqlnd-ms.multi_master"><literal>mysqlnd_ms.multi_master</literal></link>
|
|
has been introduced in version 1.1.0-beta to find ways for lifting this
|
|
limitation.
|
|
</para>
|
|
<para>
|
|
The built-in read/write-split mechanism is very basic. Every
|
|
query which starts with <literal>SELECT</literal>
|
|
is considered a read request to be sent to a MySQL slave server.
|
|
All other queries, including, for example, <literal>SHOW</literal>
|
|
statements, are considered as write requests to be sent to the MySQL master server.
|
|
The build-in behaviour can be overruled using
|
|
<link linkend="mysqlnd-ms.constants">SQL hints</link> or an user-defined
|
|
<link linkend="function.mysqlnd-ms-set-user-pick-server">callback function</link>.
|
|
</para>
|
|
<para>
|
|
The read/write splitter is not aware of multi-statements. Multi-statements
|
|
are considered as one statement. The decision of where to run the statement
|
|
will be based on the beginning of the statement string.
|
|
</para>
|
|
<para>
|
|
Prior to version 1.1.0-beta the plugin did not support native prepared statements.
|
|
Please note that <link linkend="ref.pdo-mysql">PDO_MySQL</link> is using a
|
|
client-side prepared statement emulation by default. Client-side emulated
|
|
prepared statements are fully supported by any version of
|
|
the replication and load balancing plugin because the emulation is not
|
|
using native prepared statements. If you are using PHP based database
|
|
abstraction, please consult the vendor manual to learn if a client-side
|
|
prepared statement emulation is used.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
Application must be aware of the consequences of connection switches performed
|
|
for load balancing purpose. Please check the documentation on
|
|
<link linkend="mysqlnd-ms.pooling">connection pooling and switching</link>,
|
|
<link linkend="mysqlnd-ms.transaction">transaction handling</link>,
|
|
<link linkend="mysqlnd-ms.failover">failover</link>
|
|
<link linkend="mysqlnd-ms.loadbalancing">load balancing</link> and
|
|
<link linkend="mysqlnd-ms.rwsplit">read-write splitting</link> carefully.
|
|
</para>
|
|
</note>
|
|
</section>
|
|
|
|
<section xml:id="mysqlnd-ms.name">
|
|
<title>On the name</title>
|
|
<para>
|
|
The shortcut <literal>mysqlnd_ms</literal>
|
|
stands for <literal>mysqlnd master slave plugin</literal>. The name
|
|
was chosen for a quick-and-dirty proof-of-concept. In the beginning
|
|
the developers did not expect to continue using the code base.
|
|
</para>
|
|
</section>
|
|
</preface>
|
|
|
|
&reference.mysqlnd-ms.quickstart;
|
|
&reference.mysqlnd-ms.concepts;
|
|
&reference.mysqlnd-ms.setup;
|
|
&reference.mysqlnd-ms.constants;
|
|
&reference.mysqlnd-ms.reference;
|
|
&reference.mysqlnd-ms.changes;
|
|
|
|
</book>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|