This is the fifth in a series of posts reviewing methods for MySQL master discovery: the means by which an application connects to the master of a replication tree. Moreover, the means by which, upon master failover, it identifies and connects to the newly promoted master.
These posts are not concerned with the manner by which the replication failure detection and recovery take place. I will share orchestrator
specific configuration/advice, and point out where cross DC orchestrator/raft
setup plays part in discovery itself, but for the most part any recovery tool such as MHA
, replication-manager
, severalnines
or other, is applicable.
We discuss asynchronous (or semi-synchronous) replication, a classic single-master-multiple-replicas setup. A later post will briefly discuss synchronous replication (Galera/XtraDB Cluster/InnoDB Cluster).
Master discovery via Service discovery and Proxy
Part 4 presented with an anti-pattern setup, where a proxy would infer the identify of the master by drawing conclusions from backend server checks. This led to split brains and undesired scenarios. The problem was the loss of context.
We re-introduce a service discovery component (illustrated in part 3), such that:
- The app does not own the discovery, and
- The proxy behaves in an expected and consistent way.
In a failover/service discovery/proxy setup, there is clear ownership of duties:
- The failover tool own the failover itself and the master identity change notification.
- The service discovery component is the source of truth as for the identity of the master of a cluster.
- The proxy routes traffic but does not make routing decisions.
- The app only ever connects to a single target, but should allow for a brief outage while failover takes place.
Depending on the technologies used, we can further achieve:
- Hard cut for connections to old, demoted master
M
. - Black/hold off for incoming queries for the duration of failover.
We explain the setup using the following assumptions and scenarios:
- All clients connect to master via
cluster1-writer.example.net
, which resolves to a proxy box. - We fail over from master
M
to promoted replicaR
.
Continue reading » “MySQL master discovery methods, part 5: Service discovery & Proxy”