1. The simplest is to read data that requires consistency from the master database. However, this method is obviously not feasible for applications with large data volumes.
2. the synchronous replication model is used. MYSQL provides a synchronous replication mode through NDB cluster storage engine, however, the stability of Mysql cluster, the efficiency of sync replication, and restrictions are still problems.
3. Use Server Load balancer and other technologies to relieve slave database pressure, thus reducing replication lag (but not completely avoiding it ).
4. database partition. I don't understand this.
5. Use a global-transaction-id or version to update this id during each write operation, and compare the id in the master-slave database during read to determine whether the master-slave database is synchronized, to determine which database to read.
In order to be fast, use MEMORY table to store this id. You can write code to encapsulate the update and compare id operations, or even hack MYSQL, or use MYSQL Proxy and other tools to complete these operations for you, in this way, you do not need to modify your business code.