[Source code analysis] How does Nacos use the AP protocol to complete data synchronization between servers?

The synchronization of AP nodes is realized by means of asynchronous task + message queue.
insert image description here
insert image description here

After the task is taken out, it will be put into a List collection.
Then you will find that the execution of the task is conditional.
First of all, the number of nodes in the current cluster is equal to 1000, then the synchronization will start directly at this time. Of course, this condition will not be true in small projects, so there is another condition that the current time and the last synchronization time exceed 2s. A task synchronization will be performed.
insert image description here
insert image description here

When performing data synchronization here, we can consider that the registered node this time may be registered to Nacos server 1, then several other Nacos servers want to synchronize instance data to their own memory, we can use many Simple HTTP way to synchronize data.

insert image description here
insert image description here
insert image description here

It can be found that in the end, it is actually a method of sending HTTP requests and then sending service instance synchronization.
insert image description here

Then call back the method of data synchronization.
insert image description here

Guess you like

Origin blog.csdn.net/Zhangsama1/article/details/132143057