Nacos configuration update workflow

        First of all, Nacos is a function of initiating a configuration update query to the Nacos Server in the form of long-round training. The so-called long rotation training (as shown in the figure) means that the client initiates a rotation training request to the server. When there is no change in the server configuration, the connection is always open. Return until the server has configuration or the connection times out.

        The Nacos client needs to obtain the changed configuration of the server, and the premise is to have a comparison, that is, to compare the local configuration information of the client with the configuration information of the server. Once a difference is found with the configuration of the server, it means that the configuration of the server has been updated, so the updated configuration is pulled to the local. In this process, there may be a problem that due to the large number of client configurations, the comparison takes a long time, which makes the configuration synchronization slow.

So Nacos made two optimizations for this scenario.
1. To reduce the amount of network communication data, the client fragments the configurations that need to be compared, and the size of each fragment
is 3000,
That is to say, take up to 3000 configurations to Nacos Server for comparison each time.
2. Compare and update in stages,
In the first stage, the client concatenates the 3000 configured keys and the md5 of the corresponding value values ​​into a word
String, and then sent to Nacos Server
To make a judgment, the server will compare the different md5 keys in these configurations one by one, and return the updated key to
client.
In the second stage, the client gets the changed keys, and calls the service order one by one in a loop to obtain the values ​​of these keys
value.
The core purpose of these two optimizations is to reduce the size of network communication data packets, and split a large data packet communication into
Multiple small packet communications.
Although it will increase the number of network communications, it will greatly improve the overall performance.
Finally, the method of long connection is used, which not only reduces the number of pull polls, but also takes advantage of the long connection.
Good implementation of the dynamic update synchronization function of the configuration.

Guess you like

Origin blog.csdn.net/weixin_55229531/article/details/131500861