What to do if a single writing database cannot meet the performance requirements when mysql reads and writes are separated? Should I use multiple databases to write? So how to synchronize data and ensure data consistency?
代言2017-06-20 10:07:42
You can try caching. When setting up data storage in the background, set it directly into redis
, and then synchronize the database. When fetching data at the front desk, go directly to redis
and get it. Personal suggestion, for reference only
欧阳克2017-06-20 10:07:42
When read and write separation cannot meet the performance, horizontal splitting is usually used to solve the problem:
主1 - 从1.1、从1.2、从1.3
主2 - 从2.1、从2.2、从2.3
...
In addition, the separation of reading and writing cannot guarantee data consistency. For example, if the user logs in just after registering, if the login reads from the slave database, then when the user logs in just after registering, but the registration data has not yet been synchronized to the slave database, Login will fail.
On the contrary, simple horizontal split will not have the problem of data inconsistency, because a piece of user data always falls in one partition.