Databases 21 min read

Why Does Semi‑Synchronous MySQL Replication Match Asynchronous Speed in Real Tests?

This article compares MySQL semi‑synchronous and asynchronous replication, presenting performance test results that show only a small difference in TPS and QPS, explains why the gap is minimal, and provides step‑by‑step instructions and sysbench scripts for setting up and benchmarking both replication modes.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Why Does Semi‑Synchronous MySQL Replication Match Asynchronous Speed in Real Tests?

MySQL replication mode comparison: many claim semi‑synchronous is much slower than asynchronous, but current tests show the performance gap is tiny.

Performance Test Report

Results:

Semi‑synchronous replication: TPS 760.35, QPS 15207.04
Asynchronous replication: TPS 837.05, QPS 16740.90

Observations:

The difference is slight; semi‑synchronous is only a bit slower.

Why is the gap so small? Because only one slave is used and the master waits for a single acknowledgment (rpl_semi_sync_master_wait_for_slave_count = 1). In a one‑master‑two‑slave setup the gap would be larger.

During the test the slave had little load, so binlog ACKs were fast; heavier slave load would increase latency.

Which is better to use, semi‑synchronous or asynchronous replication?

Example deployment: in a one‑master‑three‑slave architecture you can set one slave to semi‑synchronous and the other two to asynchronous, balancing data safety and consistency.

Semi‑Synchronous Replication Stress Test

1. Build GTID semi‑synchronous replication

# Check GTID status on master
show variables like '%gtid%';
# Install semi‑sync plugin on master
install plugin rpl_semi_sync_master soname 'semisync_master.so';
set global rpl_semi_sync_master_enabled = 1;
# Install plugin on slave
install plugin rpl_semi_sync_slave soname 'semisync_slave.so';
set global rpl_semi_sync_slave_enabled = 1;
# Create replication user
grant replication slave on *.* to repl@'%' identified by '123456';
# Configure master
CHANGE MASTER TO MASTER_HOST='10.186.61.30', MASTER_USER='repl', MASTER_PASSWORD='123456', MASTER_PORT=3306, MASTER_CONNECT_RETRY=10, MASTER_AUTO_POSITION=1;
START SLAVE;

2. Pressure test semi‑synchronous mode

# Create test database
create database testdb;
grant all on *.* to root@'%' identified by '123456';
# Load data with sysbench (200k rows, 8 tables, 4 threads, 60 s)
sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --mysql-host=10.186.61.30 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=testdb --oltp-table-size=200000 --oltp-tables-count=8 --threads=4 --time=60 --report-interval=3 run;

Sample sysbench output (selected lines):

[3s] thds: 4 tps: 599.32 qps: 15207.04 (r/w/o: 8401.09/2397.26/1199.96) lat (ms,95%): 11.04 err/s: 0.00 reconn/s: 0.00
[6s] thds: 4 tps: 740.06 qps: 14808.55 (r/w/o: 10364.19/2964.24/1480.12) lat (ms,95%): 8.58 err/s: 0.00 reconn/s: 0.00
[9s] thds: 4 tps: 761.70 qps: 15239.62 (r/w/o: 10668.43/3047.32/1523.39) lat (ms,95%): 8.74 err/s: 0.00 reconn/s: 0.00
[12s] thds: 4 tps: 766.66 qps: 15327.62 (r/w/o: 10730.97/3063.32/1533.33) lat (ms,95%): 8.43 err/s: 0.00 reconn/s: 0.00
[15s] thds: 4 tps: 770.31 qps: 15407.89 (r/w/o: 10784.03/3083.25/1540.62) lat (ms,95%): 8.28 err/s: 0.00 reconn/s: 0.00
[18s] thds: 4 tps: 775.37 qps: 15504.64 (r/w/o: 10854.78/3099.13/1550.73) lat (ms,95%): 8.28 err/s: 0.00 reconn/s: 0.00
[21s] thds: 4 tps: 796.65 qps: 15931.60 (r/w/o: 11151.39/3187.25/1592.96) lat (ms,95%): 7.98 err/s: 0.00 reconn/s: 0.00
[24s] thds: 4 tps: 766.31 qps: 15325.15 (r/w/o: 10726.31/3065.90/1532.95) lat (ms,95%): 8.43 err/s: 0.00 reconn/s: 0.00
[27s] thds: 4 tps: 750.69 qps: 15016.21 (r/w/o: 10512.05/3002.78/1501.39) lat (ms,95%): 8.28 err/s: 0.00 reconn/s: 0.00
[30s] thds: 4 tps: 767.35 qps: 15349.98 (r/w/o: 10745.89/3069.40/1534.70) lat (ms,95%): 8.28 err/s: 0.00 reconn/s: 0.00
[33s] thds: 4 tps: 744.96 qps: 14894.10 (r/w/o: 10425.70/2978.49/1489.91) lat (ms,95%): 9.39 err/s: 0.00 reconn/s: 0.00
[36s] thds: 4 tps: 752.64 qps: 15050.90 (r/w/o: 10535.03/3010.58/1505.29) lat (ms,95%): 8.13 err/s: 0.00 reconn/s: 0.00
[39s] thds: 4 tps: 786.04 qps: 15721.48 (r/w/o: 11006.57/3142.83/1572.08) lat (ms,95%): 8.28 err/s: 0.00 reconn/s: 0.00
[42s] thds: 4 tps: 782.34 qps: 15649.87 (r/w/o: 10955.81/3129.37/1564.69) lat (ms,95%): 8.43 err/s: 0.00 reconn/s: 0.00
[45s] thds: 4 tps: 790.66 qps: 15810.29 (r/w/o: 11063.97/3164.99/1581.33) lat (ms,95%): 8.13 err/s: 0.00 reconn/s: 0.00
[48s] thds: 4 tps: 741.67 qps: 14829.09 (r/w/o: 10381.40/2964.35/1483.34) lat (ms,95%): 9.06 err/s: 0.00 reconn/s: 0.00
[51s] thds: 4 tps: 773.67 qps: 15474.64 (r/w/o: 10831.31/3095.99/1547.33) lat (ms,95%): 8.74 err/s: 0.00 reconn/s: 0.00
[54s] thds: 4 tps: 778.59 qps: 15580.14 (r/w/o: 10908.26/3114.69/1557.18) lat (ms,95%): 8.13 err/s: 0.00 reconn/s: 0.00
[57s] thds: 4 tps: 801.73 qps: 16031.28 (r/w/o: 11219.90/3207.92/1603.46) lat (ms,95%): 8.13 err/s: 0.00 reconn/s: 0.00
[60s] thds: 4 tps: 761.29 qps: 15228.56 (r/w/o: 10660.79/3045.18/1522.59) lat (ms,95%): 8.28 err/s: 0.00 reconn/s: 0.00

Asynchronous Replication Stress Test

1. Switch to GTID asynchronous replication

# Disable semi‑sync on master
set global rpl_semi_sync_master_enabled = 0;
# Disable on slave
set global rpl_semi_sync_slave_enabled = 0;
STOP SLAVE IO_THREAD;
START SLAVE IO_THREAD;

2. Pressure test asynchronous mode

sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --mysql-host=10.186.61.30 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=testdb --oltp-table-size=200000 --oltp-tables-count=8 --threads=4 --time=60 --report-interval=3 run;

Sample async sysbench output (selected lines):

[3s] thds: 4 tps: 805.14 qps: 16122.80 (r/w/o: 11286.63/3224.56/1611.61) lat (ms,95%): 7.70 err/s: 0.00 reconn/s: 0.00
[6s] thds: 4 tps: 891.19 qps: 17819.06 (r/w/o: 12475.28/3561.41/1782.37) lat (ms,95%): 7.43 err/s: 0.00 reconn/s: 0.00
[9s] thds: 4 tps: 838.69 qps: 16775.78 (r/w/o: 11742.98/3355.42/1677.38) lat (ms,95%): 7.98 err/s: 0.00 reconn/s: 0.00
[12s] thds: 4 tps: 855.24 qps: 17100.48 (r/w/o: 11969.37/3420.63/1710.48) lat (ms,95%): 7.84 err/s: 0.00 reconn/s: 0.00
[15s] thds: 4 tps: 856.08 qps: 17122.62 (r/w/o: 11987.13/3423.32/1712.16) lat (ms,95%): 8.13 err/s: 0.00 reconn/s: 0.00
[18s] thds: 4 tps: 834.35 qps: 16683.96 (r/w/o: 11678.20/3337.39/1668.36) lat (ms,95%): 8.13 err/s: 0.00 reconn/s: 0.00
[21s] thds: 4 tps: 836.93 qps: 16733.92 (r/w/o: 11712.34/3347.72/1673.86) lat (ms,95%): 7.98 err/s: 0.00 reconn/s: 0.00
[24s] thds: 4 tps: 849.73 qps: 17006.66 (r/w/o: 11906.93/3399.93/1699.80) lat (ms,95%): 8.13 err/s: 0.00 reconn/s: 0.00
[27s] thds: 4 tps: 847.67 qps: 16953.77 (r/w/o: 11865.41/3393.02/1695.34) lat (ms,95%): 7.43 err/s: 0.00 reconn/s: 0.00
[30s] thds: 4 tps: 841.00 qps: 16808.31 (r/w/o: 11765.98/3360.66/1681.66) lat (ms,95%): 8.58 err/s: 0.00 reconn/s: 0.00
[33s] thds: 4 tps: 811.29 qps: 16238.80 (r/w/o: 11366.73/3249.16/1622.91) lat (ms,95%): 8.58 err/s: 0.00 reconn/s: 0.00
[36s] thds: 4 tps: 809.04 qps: 16175.85 (r/w/o: 11324.93/3232.84/1618.08) lat (ms,95%): 7.84 err/s: 0.00 reconn/s: 0.00
[39s] thds: 4 tps: 843.62 qps: 16870.73 (r/w/o: 11809.68/3373.81/1687.24) lat (ms,95%): 7.98 err/s: 0.00 reconn/s: 0.00
[42s] thds: 4 tps: 841.00 qps: 16826.31 (r/w/o: 11778.65/3365.66/1682.00) lat (ms,95%): 7.56 err/s: 0.00 reconn/s: 0.00
[45s] thds: 4 tps: 820.69 qps: 16411.52 (r/w/o: 11487.36/3282.77/1641.39) lat (ms,95%): 8.28 err/s: 0.00 reconn/s: 0.00
[48s] thds: 4 tps: 830.99 qps: 16623.45 (r/w/o: 11635.18/3326.29/1661.98) lat (ms,95%): 7.98 err/s: 0.00 reconn/s: 0.00
[51s] thds: 4 tps: 838.67 qps: 16763.33 (r/w/o: 11734.33/3352.00/1677.00) lat (ms,95%): 7.70 err/s: 0.00 reconn/s: 0.00
[54s] thds: 4 tps: 822.67 qps: 16456.73 (r/w/o: 11521.37/3289.68/1645.67) lat (ms,95%): 8.28 err/s: 0.00 reconn/s: 0.00
[57s] thds: 4 tps: 834.70 qps: 16696.98 (r/w/o: 11686.78/3340.80/1669.40) lat (ms,95%): 7.98 err/s: 0.00 reconn/s: 0.00
[60s] thds: 4 tps: 834.58 qps: 16684.62 (r/w/o: 11679.47/3335.99/1669.16) lat (ms,95%): 7.98 err/s: 0.00 reconn/s: 0.00

Both modes achieve similar throughput; the semi‑synchronous mode incurs only a modest overhead, making it a viable option when stronger data consistency is required.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

AsynchronousmysqlReplicationGTIDSemi-synchronous
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.