According to the principle, there should be no delay between the master and the backup, because the master database is capable of processing, but the backup database is not capable, especially when it is on the same machine
The reason is that only one thread is opened for the writing of the standby database. In this way, in versions after 5.7, we can turn on multi-threaded processing
slave-parallel-type=LOGICAL_CLOCK
slave-parallel-workers=8
master_info_repository=TABLE
relay_log_info_repository=TABLE
relay_log_recovery=ON
binlog_group_commit_sync_delay=1000000
binlog_group_commit_sync_no_delay_count=20
reference:
MySQL Performance Schema
https://cloud.tencent.com/developer/article/1143420
This can adjust the master, in practice
https://www.jianshu.com/p/ed19bb0e748a
UPDATE performance_schema.setup_consumers SET ENABLED = 'YES' WHERE NAME LIKE 'events_transactions%';
UPDATE performance_schema.setup_instruments SET ENABLED = 'YES', TIMED = 'YES'WHERE NAME = 'transaction';
SELECT thread_id,count_star FROM performance_schema.events_transactions_summary_by_thread_by_event_name WHERE thread_id IN (SELECT thread_id FROM performance_schema.replication_applier_status_by_worker);