skip to content

For a MySQL 8.4 OLTP database that must survive losing its primary, how do you choose between async GTID replicas, semisynchronous replication and an InnoDB Cluster?

level: principalimportance: should knowfreq 35%

answer

  1. how much loss, how fast back
  2. who promotes, and who reroutes
  3. network distance between members
  4. what the schema and batch jobs allow
  5. what the team can operate at 3 a.m.

basics

~20 s

Choose by tolerated data loss, recovery time, network latency and operating skill. Async GTID replicas are simplest but can lose commits; semisync AFTER_SYNC narrows loss at commit latency; InnoDB Cluster adds consensus and automatic failover with stricter requirements.

solid answer

~50 s

I start from the recovery objectives and the network, not the feature list. Async GTID replicas, optionally managed as an InnoDB ReplicaSet with MySQL Router, are cheap and tolerate distant replicas, but a crash can lose the commits not yet shipped and failover is manual or external. Semisync with `AFTER_SYNC` makes a failover to the acknowledging replica lossless, as long as it has not timed out back to async, at a round trip per commit; promotion is still someone else's job. InnoDB Cluster runs Group Replication in single-primary mode: a majority agrees on every commit, a secondary is elected automatically and Router follows it, but members need a low-latency network, three or more nodes, InnoDB tables with primary keys, and transactions under `group_replication_transaction_size_limit`. My usual pick is InnoDB Cluster inside one region, plus an async replica elsewhere for disaster recovery, unless the schema or batch jobs cannot meet its rules.

go deeper

for a junior

Recall the three MySQL options in outline: plain asynchronous replicas, semisynchronous replication, and InnoDB Cluster built on Group Replication.

for a middle

Explain what each option makes a commit wait for, and what each needs from the schema and the network.

for a senior

Show the operational failure modes of each: the semisync timeout fallback, manual promotion picking the right replica, and Group Replication's size limit and majority loss.

for a principal

Turn recovery objectives, network layout and team capacity into a recorded choice, with its latency and operating costs and the triggers that would reopen it.

## The decision a lead owns All three designs keep a copy of the data on other MySQL servers; they differ in **when a commit counts as safe**, **who promotes a new primary**, and **what they demand of the schema, the network and the team**. There is no universally right answer, so the useful skill is turning business constraints into a choice and writing down what it costs. The general theory of synchronous versus asynchronous acknowledgement and of failover procedures belongs to the engine-neutral material; this is about MySQL's own options. Start by fixing four inputs: 1. **Recovery point objective.** How many committed transactions may be lost when the primary dies: some seconds' worth, or none? 2. **Recovery time objective.** Is a human allowed to decide on promotion, or must the system fail over within seconds on its own? 3. **Network.** Are the candidate servers in one data centre with sub-millisecond latency, or spread across regions? 4. **Workload and schema.** Do all tables have primary keys and use InnoDB? Do batch jobs write transactions of hundreds of megabytes? ## The three options | | Async GTID replicas | Semisync (`AFTER_SYNC`) | InnoDB Cluster | |---|---|---|---| | Commit waits for | nothing | one replica's relay-log receipt | the group's agreed order, from a majority | | Data loss on crash | commits not yet shipped | none to the acknowledging replica, unless it fell back to async | none for certified transactions | | Failover | manual or external tooling | manual or external tooling | automatic primary election | | Client routing | yours to build, or MySQL Router with an InnoDB ReplicaSet | yours to build | MySQL Router, bootstrapped from the cluster | | Network | tolerates distance | each commit pays a round trip | members close together | | Hard requirements | GTIDs recommended | plugins on both sides | InnoDB, primary keys, GTIDs, ROW, at least three members | **Async GTID replication** is the baseline. It is simple, tolerates slow links and lets replicas run different hardware or serve reporting. An **InnoDB ReplicaSet** wraps it with MySQL Shell's AdminAPI and MySQL Router, but the manual is explicit that a ReplicaSet does not provide automatic failover; switchover and failover are manual commands. **Semisynchronous replication** keeps the async topology but makes each commit wait for one replica to acknowledge receipt. With `rpl_semi_sync_source_wait_point=AFTER_SYNC` a failover to the acknowledging replica loses nothing clients saw. The traps are operational: after `rpl_semi_sync_source_timeout` (10 seconds by default) the source quietly reverts to async, and promotion still depends on tooling that picks the right replica. **InnoDB Cluster** is Group Replication in single-primary mode plus MySQL Shell and MySQL Router. Commits go through the group's consensus, a failed primary is replaced by election, and Router sends clients to the new one. The price: - a group of at least three members, nine at most, on a low-latency network, because every write involves the group; - InnoDB-only tables, each with a primary key or a non-null unique key; - transactions under `group_replication_transaction_size_limit` (150000000 bytes by default), so large batch jobs must be split; - losing the majority stops writes rather than risking divergence; - more moving parts to upgrade, monitor and understand. ## How I would decide - **Small service, minutes of downtime acceptable, seconds of loss tolerable:** async GTID replicas, ideally as a ReplicaSet so the team uses one tool for switchover. - **Loss must be near zero, servers close together, failover tooling already exists:** semisync with `AFTER_SYNC`, alerting on `Rpl_semi_sync_source_status`, and a promotion runbook that chooses the replica with the largest received GTID set. - **Automatic failover required and the schema can meet the rules:** InnoDB Cluster within one region, with an asynchronous replica in another region for disaster recovery, because a group stretched across regions pays wide-area latency on every commit. - **Schema cannot comply:** fix the schema first. Tables without primary keys also hurt multithreaded replicas, so the work pays off in any topology. ## Costs to put in the decision record 1. **Write latency** added per commit by semisync or by group consensus, measured on the real network. 2. **Operational load:** who is paged, which tool promotes, and how an old primary is rebuilt; under semisync `AFTER_SYNC`, a crashed source must be rebuilt rather than restarted. 3. **Application changes:** retry on rolled-back commits, batch sizes under the transaction limit, and connection routing through Router. 4. **Revisit triggers:** a second region, a new batch workload, or a recovery objective that tightens. Whatever is chosen, enable GTIDs everywhere and set `super_read_only` on non-primaries; both make every later move between these designs cheaper.

  • Why would you not stretch one MySQL InnoDB Cluster across two distant regions?
    Every read/write commit needs the group to agree on its order, so a member in a distant region adds a wide-area round trip to commits, and the manual expects members to sit close together. With two regions you also cannot place a majority safely: losing the bigger side stops writes. A common design keeps the group in one region and adds an asynchronous replica elsewhere for disaster recovery.
  • A team's nightly job deletes 400 MB of rows in one transaction. How does that affect the MySQL topology choice?
    Under InnoDB Cluster that transaction exceeds the default `group_replication_transaction_size_limit` of 150000000 bytes and is rolled back on the member that ran it, so the job must be split into batches before adopting the cluster. Under async or semisync replication it would replicate, but as one huge row-based transaction it would still stall replicas, so batching is worth doing anyway.

  • InnoDB Cluster is always best because automatic failover has no downside.
  • Semisync guarantees zero data loss in every failure, so monitoring it is optional.
  • An InnoDB ReplicaSet fails over automatically, just like InnoDB Cluster.
  • A two-node Group Replication setup gives high availability for one failure.
  • Topology choice is independent of the schema, since replication copies any table.

Assumes MySQL 8.4 LTS, where InnoDB Cluster, InnoDB ReplicaSet and semisync's AFTER_SYNC default are current and the replication statements use SOURCE and REPLICA names.