Chapter 7 Mysqlnd replication and load balancing plugin

Table of Contents

7.1 Key Features
7.2 Limitations
7.3 On the name
7.4 Quickstart and Examples
7.4.1 Setup
7.4.2 Running statements
7.4.3 Connection state
7.4.4 SQL Hints
7.4.5 Local transactions
7.4.6 XA/Distributed Transactions
7.4.7 Service level and consistency
7.4.8 Global transaction IDs
7.4.9 Cache integration
7.4.10 Failover
7.4.11 Partitioning and Sharding
7.4.12 MySQL Fabric
7.5 Concepts
7.5.1 Architecture
7.5.2 Connection pooling and switching
7.5.3 Local transaction handling
7.5.4 Error handling
7.5.5 Transient errors
7.5.6 Failover
7.5.7 Load balancing
7.5.8 Read-write splitting
7.5.9 Filter
7.5.10 Service level and consistency
7.5.11 Global transaction IDs
7.5.12 Cache integration
7.5.13 Supported clusters
7.5.14 XA/Distributed transactions
7.6 Installing/Configuring
7.6.1 Requirements
7.6.2 Installation
7.6.3 Runtime Configuration
7.6.4 Plugin configuration file (>=1.1.x)
7.7 Predefined Constants
7.8 Mysqlnd_ms Functions
7.8.1 mysqlnd_ms_dump_servers
7.8.2 mysqlnd_ms_fabric_select_global
7.8.3 mysqlnd_ms_fabric_select_shard
7.8.4 mysqlnd_ms_get_last_gtid
7.8.5 mysqlnd_ms_get_last_used_connection
7.8.6 mysqlnd_ms_get_stats
7.8.7 mysqlnd_ms_match_wild
7.8.8 mysqlnd_ms_query_is_select
7.8.9 mysqlnd_ms_set_qos
7.8.10 mysqlnd_ms_set_user_pick_server
7.8.11 mysqlnd_ms_xa_begin
7.8.12 mysqlnd_ms_xa_commit
7.8.13 mysqlnd_ms_xa_gc
7.8.14 mysqlnd_ms_xa_rollback
7.9 Change History
7.9.1 PECL/mysqlnd_ms 1.6 series
7.9.2 PECL/mysqlnd_ms 1.5 series
7.9.3 PECL/mysqlnd_ms 1.4 series
7.9.4 PECL/mysqlnd_ms 1.3 series
7.9.5 PECL/mysqlnd_ms 1.2 series
7.9.6 PECL/mysqlnd_ms 1.1 series
7.9.7 PECL/mysqlnd_ms 1.0 series

Copyright 1997-2014 the PHP Documentation Group.

The mysqlnd replication and load balancing plugin (mysqlnd_ms) adds easy to use MySQL replication support to all PHP MySQL extensions that use mysqlnd.

As of version PHP 5.3.3 the MySQL native driver for PHP (mysqlnd) features an internal plugin C API. C plugins, such as the replication and load balancing plugin, can extend the functionality of mysqlnd.

The MySQL native driver for PHP is a C library that ships together with PHP as of PHP 5.3.0. It serves as a drop-in replacement for the MySQL Client Library (libmysqlclient). Using mysqlnd has several advantages: no extra downloads are required because it's bundled with PHP, it's under the PHP license, there is lower memory consumption in certain cases, and it contains new functionality such as asynchronous queries.

Mysqlnd plugins like mysqlnd_ms operate, for the most part, transparently from a user perspective. The replication and load balancing plugin supports all PHP applications, and all MySQL PHP extensions. It does not change existing APIs. Therefore, it can easily be used with existing PHP applications.