How to Make Replication Faster in MySQL

How to Make Replication Faster in MySQL

innodb_flush_log_at_trx_commit to 2 will help on increasing speed of replication in case of latency between Master and Slave. It is not a recommended solution and you should not consider as permanent solution.

The default setting of 1 is required for full ACID compliance. Logs are written and flushed to disk at each transaction commit.

With a setting of 0, logs are written and flushed to disk once per second. Transactions or which logs have not been flushed can be lost in a crash.

With a setting of 2, logs are written after each transaction commit and flushed to disk once per second. Transactions for which logs have not been flushed can be lost in a crash.

Suggession and Recommendation

innodb_flush_log_at_trx_commit = 0 if: it is my development computer or home mini database where is no sensitive data.

innodb_flush_log_at_trx_commit = 2 if: it is blog/stats/e-commerce (with ~100x shop in day), etc.

innodb_flush_log_at_trx_commit = 1 if: you have a lot of customers or you need to work with money transaction like bank. so this time you should split your dataflow between several servers to have speed & safety.

You can use 2, because it has ~75x faster write speed and it fails ONLY if hardware fails.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.