MySQL Fabric provides data distribution and high-availability features for a set of MySQL database servers.
Developers using Connector/Python can take advantage of its features to work with a set of servers managed by MySQL Fabric. Connector/Python supports the following MySQL Fabric capabilities:
Automatic node selection based on application-provided shard information (tables and key)
Read/write splitting within a MySQL Fabric high-availability group
More specifically, Connector/Python Fabric support provides these features:
Requesting a connection to a MySQL server managed by Fabric is as transparent as possible to users already familiar with Connector/Python.
Connector/Python is able to get a MySQL server connection given a high-availability group and a mode specifying whether the connection is read-only or also permits updates (read-write).
Connector/Python supports sharding and is able to find the correct MySQL server for a given table or tables and key based on scope (local or global) and mode (read-only or read-write).
HASHmechanisms are supported transparently to the user.
Among secondary MySQL servers in the same group, read-only connections are load balanced. Load balancing is based on a weight set for each MySQL server, using a Weighted Round-Robin algorithm.
Faulty MySQL servers are reported to Fabric, and failover is supported when failure occurs for a server in a group.
To speed up operations, Connector/Python caches information obtained from Fabric, such as group and sharding information. Each time Connector/Python looks up data, it first checks its cache. When information in the cache is too old, it is invalidated. By default, the time-to-live (TTL) for cached information is 1 minute. However, Fabric itself can provide this TTL for its clients and this value is used instead if greater than zero.
Cache information is also invalidated when failures occur, such as when a connection to a MySQL server fails (invalidation applies to the group to which the server belongs).
Fabric support applies to versions of Python supported by Connector/Python itself (see Connector/Python Versions). In particular, you can use Connector/Python with Python 3.1 and later to establish Fabric connections, even though Fabric does not support Python 3.
Connector/Python support for Fabric comprises the following module and classes:
mysql.connector.fabric: All classes, functions, and constants related to MySQL Fabric.
fabric.MySQLFabricConnection: Similar to
MySQLConnection, it creates a connection to the MySQL server based on application-provided information.
fabric.Fabric: Manages the connection with a MySQL Fabric node; used by
Other helper classes for caching information.