Excuse me, how does the distributed architecture database come from?

recently, I have been learning distributed architecture. I have basically figured it out. What about the database?
the mysql, I"ve been using take mysql as an example

for example, I now have two databases of server B. According to the load balancer, server may write to An or B
the question is mainly how the database is Synchronize. I know that mysql has a master-slave database Synchronize function, but what about that timeliness? For example, a client inserts a piece of data into database A, and then the client is disconnected and reconnected, and then he redoes the operation, just this time he inserts it into database B. at this time, Amai B and the two databases haven"t had time for Synchronize, isn"t there two pieces of duplicate data?

I would like to ask the experienced warrior to tell me how the usual situation in this area is going on. Or is the architecture I"m talking about wrong, usually using other methods rather than multiple databases to share the load?

Mar.12,2021

what you say is not master-slave in MySQL, but two-master (because to write An and B), master-slave means to write master forever, and then asynchronously Synchronize to slave.

dual masters are generally not used in practical projects (reliability and maintainability are not as good as master-slave), but master-slave is widely used, and master-slave is enough, because master-slave mode has well shared the read operation, and most applications are write less and read more. From my personal experience, it is not recommended to use MySQL multi-master.


formal distributed databases will not randomly select partitions to store data, but will store data in the corresponding database according to the hash algorithm. For example, there are four databases with 0-3, and the data will be stored in the corresponding database partition according to uid% 4 when storing the data. If something goes wrong, it will not change when retried.

Menu