Scrivio Interview library
DesignAdvanced6 min read · updated 12 November 2026

Design a highly available MySQL setup for a payments service that must not lose committed transactions on primary failure, and compare async replication, semi-synchronous replication and Group Replication / InnoDB Cluster.

Asynchronous replication can lose transactions that the primary committed but had not yet sent to any replica, so it cannot meet the requirement alone. Semi-synchronous replication with AFTER_SYNC waits until at least one replica has received and logged each transaction before the commit returns, and Group Replication, the core of InnoDB Cluster, certifies every transaction with a majority of members through a Paxos-based protocol. For payments I would choose a three-node InnoDB Cluster in single-primary mode, with full durability settings, automated failover that fences the old primary, regular failover tests, and backups with archived binlogs for point-in-time recovery.

Background to this question

For a payments service, losing a committed transaction is not a small bug: a customer was told their payment went through, and the record of it is gone. High availability for such a service is therefore two promises at once, staying up when a server dies and not forgetting anything when it does, and the replication method decides whether the second promise is even possible. In this answer, we will recap where loss happens, compare asynchronous replication, semi-synchronous replication and Group Replication, propose a design, and then look at fencing, testing, and the backups that replication cannot replace.

1Where a Committed Transaction Can Be Lost

On one server, a commit is durable when its redo and binlog records are on disk, which requires innodb_flush_log_at_trx_commit=1 and sync_binlog=1. That protects against a crash where the same server comes back. High availability adds a second case: the primary never comes back, and we promote a replica. Whatever the replica had not received at that moment is lost, even though the primary had confirmed it to the client. The replication method decides how large that window is.

2Comparing the Three Replication Options

With asynchronous replication, the primary commits and replies to the client without waiting for anyone. Replicas usually trail by milliseconds, but under load or network trouble the gap can be seconds, and any transaction inside that gap is lost on failover.

With semi-synchronous replication, the primary waits after writing the transaction to its binlog until at least one replica confirms it has written the events to its relay log. With rpl_semi_sync_source_wait_point=AFTER_SYNC, the default, the transaction is not visible to other clients on the primary until that confirmation arrives, so no client can see data that a failover would lose. The cost is one network round trip per commit.

Group Replication goes further. Every transaction is sent to all members, which agree on its order using a Paxos-based group communication protocol, and each member certifies it against concurrent transactions. A transaction commits only when a majority has accepted it, so with three members the loss of any one member loses nothing. InnoDB Cluster packages Group Replication with MySQL Shell for administration and MySQL Router, which sends application connections to the current primary.

Replication options for a payments database
AsyncSemi-sync AFTER_SYNCGroup Replication
Loss on primary failurerecent transactions possiblenone, unless it fell back to asyncnone while a majority is up
Commit latency addednoneone round trip to a replicaone round of group messages
Failoverexternal toolingexternal toolingbuilt in, automatic
Split brain protectionmust be builtmust be builtmajority rule
Typical layout1 primary + N replicas1 primary + 2 replicas3 or 5 members, single primary

3The Design I Would Propose

For payments I would run a three-member InnoDB Cluster in single-primary mode within one region, spread over three availability zones, with MySQL Router running next to each application instance. Single-primary mode is the usual choice because all writes go to one member, which avoids certification conflicts between concurrent writers and keeps behaviour close to what applications expect. Every member runs innodb_flush_log_at_trx_commit=1 and sync_binlog=1, so even a simultaneous crash of all members does not lose a commit that was acknowledged.

Step throughPayments database layout
  1. Payments serviceSpring Boot, HikariCP pool
  2. MySQL Routerlocal, sends writes to the primary
  3. Group Replication3 members in 3 zones, majority commit
  4. Durable storage per membertrx_commit=1, sync_binlog=1
  5. Backups and binlog archivepoint-in-time recovery, other account
  6. Async replica clustersecond region, disaster recovery

6 layers, from the top down. Step through them one at a time.

The cost is latency: each commit waits for a majority, which across zones in one region adds roughly a millisecond. For a payments service that is a good trade. For disaster recovery in a second region, we add an asynchronous replica cluster there (InnoDB ClusterSet), knowing that a regional failover may lose the last moments, and we document that as the only accepted loss window.

4Failover Must Fence the Old Primary

Automatic failover is only safe if the old primary cannot keep accepting writes after a new one is chosen. Otherwise a network split leaves two primaries, both taking payments, and their data can never be merged cleanly: split brain. Group Replication handles this with the majority rule: a member that loses contact with the majority cannot commit, and when it is expelled it switches itself to super_read_only. With semi-sync and external failover tools, fencing has to be built: the tool must make the old primary read-only, remove it from the load balancer or virtual IP, or power it off before promoting a replica.

We test failover regularly, for example monthly in production during quiet hours and weekly in staging, by killing the primary, cutting its network and failing a whole zone, and we measure time to recover and confirm no acknowledged payment is missing.

5Replication Is Not a Backup

Replication copies mistakes as faithfully as it copies payments. An accidental DELETE or a buggy migration reaches every member within milliseconds. So we keep physical backups, for example nightly with MySQL Enterprise Backup or Percona XtraBackup, plus continuous archiving of binlogs to separate storage, which together allow point-in-time recovery to the second before the mistake. Restores are tested on a schedule, because an untested backup is only a hope.

6Follow-up questions

What happens to semi-sync if the replica is slow or down?

The primary waits for an acknowledgement up to rpl_semi_sync_source_timeout, 10 seconds by default. If none arrives, it falls back to asynchronous replication and keeps committing, so for that period transactions are not protected, and it switches back to semi-sync when a replica catches up. For payments we alert on the fallback and run at least two semi-sync replicas so one slow replica does not trigger it; with Group Replication this situation does not arise while a majority is healthy.

Why not multi-primary Group Replication for more write capacity?

Because every member still applies every write, so it does not multiply write capacity much, and concurrent writes to the same rows on different members fail certification and must be retried. Single-primary mode gives the same durability with simpler behaviour.

Can a read on a secondary see stale data?

Yes, by default secondaries apply transactions slightly after the primary. group_replication_consistency can make reads wait for preceding transactions (for example BEFORE or AFTER levels), at a latency cost; payment flows that must read their own writes simply read from the primary.

7Conclusion

In this answer, we saw that asynchronous replication can lose committed transactions on primary failure, semi-synchronous replication with AFTER_SYNC closes most of that gap at the cost of a round trip per commit but can fall back to async, and Group Replication commits only with a majority and fences minority members. For payments, a three-member single-primary InnoDB Cluster across zones with full durability settings, automated and fenced failover tested regularly, plus physical backups and archived binlogs for point-in-time recovery, meets the requirement.

What to say in the interviewAbout 90 seconds aloud

Open with

First, where loss happens: on one server, a commit is durable with innodb_flush_log_at_trx_commit and sync_binlog both at 1. On failover, whatever the promoted replica had not received is lost.

Then, if they want more

With asynchronous replication that can be the last seconds of payments, so async alone does not meet the requirement. Semi-synchronous replication with the AFTER_SYNC wait point makes the primary wait until at least one replica has written the transaction to its relay log, and the transaction is not visible before that, so a failover to that replica loses nothing.

It costs a round trip per commit, and if replicas are slow past the timeout it falls back to async, so I would alert on that. Group Replication uses a Paxos-based protocol: a transaction commits only once a majority has accepted and certified it, and a member that loses the majority cannot commit.

My design would be a three-member InnoDB Cluster in single-primary mode across three zones, MySQL Router next to the application, and full durability settings on every member. Failover is automatic, but it must fence the old primary to avoid split brain, which the majority rule gives us, and I would test failover regularly.

Finally, replication also copies mistakes, so I would keep physical backups and archive binlogs for point-in-time recovery, and test restores.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
MySQL reference manual
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Design a highly available MySQL setup for a payments service that must not lose...": https://scrivio-interview-library.netlify.app/databases/mysql/9757c83778/