MySQL Semi-Synchronous vs Asynchronous Replication

This article explains the key differences between MySQL semi-synchronous replication and traditional asynchronous replication. It covers how each method handles data transmission, the impact of each on write latency, and how to choose the right replication strategy to balance data safety with database performance.

Understanding Traditional Asynchronous Replication

In traditional asynchronous replication, the source (master) server writes transactions to its binary log and commits them locally without waiting for any confirmation from the replicas. The replica servers pull the events from the source’s binary log and apply them to their own databases independently.

Understanding Semi-Synchronous Replication

Semi-synchronous replication bridges the gap between fully synchronous and asynchronous replication. With this method, the source commits the transaction locally but waits to return a success status to the client until at least one replica has received the transaction and written it to its relay log.

Key Differences Side-by-Side

1. Data Safety and Durability

2. Performance and Latency

3. Fallback Behavior (Timeout)

MySQL semi-synchronous replication includes a fallback mechanism. If a replica does not acknowledge a transaction within a configurable timeout period (controlled by the rpl_semi_sync_master_timeout variable), the source automatically switches to asynchronous replication. Once at least one replica catches up and begins acknowledging transactions again, the source automatically switches back to semi-synchronous mode.

Which Replication Method Should You Choose?