mysql_replication - What to do if a single writing database cannot meet the performance requirements when mysql reads and writes are separated?
学习ing2017-06-20 10:05:42
0
2
909
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?
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
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.
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 toredis
and get it. Personal suggestion, for reference onlyWhen read and write separation cannot meet the performance, horizontal splitting is usually used to solve the problem:
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.