Time synchronization method for distributed system

By dividing the synchronization domain in the distributed simulation system and updating the role of the synchronization node, data conflicts and resource consumption problems caused by clock frequency differences in the distributed system are solved, and a high reliability and scalable time synchronization method is realized.

WO2025055596A1PCT designated stage expired Publication Date: 2025-03-20ZTE CORP
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/109891
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-09-12
Filing Date
2024-08-05
Publication Date
2025-03-20

AI Technical Summary

Technical Problem

In distributed simulation systems, since each core runs independently on different servers, there may be slight differences in clock frequency, resulting in data conflicts, deadlock crashes and other problems, which in turn increases communication overhead and resource consumption, and reduces the system's fault tolerance, scalability and reliability.

Method used

By dividing synchronization domains at different levels and updating the role of synchronization nodes in the time synchronization topology when synchronization nodes change, the time management algorithm of packets reduces the system's communication overhead and resource consumption and improves the reliability of the system.

Benefits of technology

It effectively reduces the communication overhead and resource consumption of distributed systems, improves the fault tolerance, scalability and reliability of the system, and avoids the problem of time loss.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024109891_20032025_PF_FP_ABST
    Figure CN2024109891_20032025_PF_FP_ABST
Patent Text Reader

Abstract

A time synchronization method for a distributed system. The method comprises: acquiring a time synchronization topological structure of the distributed system, wherein the time synchronization topological structure comprises synchronization domains of different levels, each synchronization domain comprises at least one synchronization node, and the synchronization nodes are allocated with different time synchronization roles according to a logical relationship between the nodes; and when the synchronization nodes change, updating the time synchronization roles of the synchronization nodes in the time synchronization topological structure on the basis of the changed synchronization nodes. According to the method, the problems in the related art of large communication overhead, large resource consumption, and poor overall system fault tolerance, scalability and reliability are solved, and compared with the conventional centralized time synchronization algorithms, the communication overhead and resource consumption are greatly reduced, the overall system fault tolerance and scalability are improved, thereby ensuring high reliability of the whole simulation system.
Need to check novelty before this filing date? Find Prior Art

Description

Time synchronization method for distributed systems

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This disclosure is based on Chinese patent application CN202311184237.5, filed on September 12, 2023, entitled “Time synchronization method for distributed systems”, and claims the priority of the patent application, and all the contents disclosed therein are incorporated into this disclosure by reference. Technical Field

[0003] The present disclosure relates to the field of communications, and in particular to a time synchronization method for a distributed system. Background Art

[0004] With the rapid development of modern computer technology, the scale and structure of objects requiring simulation are becoming increasingly complex, resulting in an increasing amount of data and computational tasks that simulation systems must handle. In this context, clusters consisting of multiple servers provide a solid foundation for the research and application of large-scale, complex distributed simulation systems. However, in distributed simulation platforms, since each core runs independently on different servers, clock frequencies may vary slightly, which can lead to serious problems such as data conflicts and deadlocks. This, in turn, results in high communication overhead and resource consumption when data is exchanged between servers, and poor overall system fault tolerance, scalability, and reliability.

[0005] Summary of the Invention

[0006] The embodiments of the present disclosure provide a time synchronization method for a distributed system, so as to at least solve the problems in related technologies such as high communication overhead, high resource consumption, and poor fault tolerance, scalability, and reliability of the entire system.

[0007] According to an embodiment of the present disclosure, a time synchronization method for a distributed system is provided, comprising:

[0008] Acquire a time synchronization topology structure of the distributed system, wherein the time synchronization topology structure includes synchronization domains at different levels, the synchronization domain includes at least one synchronization node, and the synchronization node is assigned different time synchronization roles according to a logical relationship between the nodes;

[0009] In the case where the synchronization node changes, the time synchronization role of the synchronization node in the time synchronization topology is updated based on the changed synchronization node.

[0010] According to another embodiment of the present disclosure, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the steps of any one of the above method embodiments when running.

[0011] According to another embodiment of the present disclosure, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any one of the above method embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] FIG1 is a hardware structure block diagram of a mobile terminal of a time synchronization method for a distributed system according to an embodiment of the present disclosure;

[0013] FIG2 is a diagram of a multi-dimensional cross-domain collaborative time management topology system architecture according to an embodiment of the present disclosure;

[0014] FIG3 is a flowchart of time synchronization of a distributed system according to an embodiment of the present disclosure;

[0015] FIG4 is a flow chart of a ring-based election algorithm for electing candidate synchronization nodes according to an embodiment of the present disclosure;

[0016] FIG5 is a flowchart of updating a time synchronization topology according to an embodiment of the present disclosure;

[0017] FIG6 is a schematic diagram of a process of time synchronization of a distributed system according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0018] Hereinafter, embodiments of the present disclosure will be described in detail with reference to the accompanying drawings and in conjunction with embodiments.

[0019] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0020] In a distributed system, each server can handle a portion of the simulation tasks, while task allocation and coordination are typically performed by a central node. By rationally partitioning tasks and resources, distributed systems can fully utilize the computing power and storage resources of each server, improving simulation efficiency. However, in a distributed simulation platform, since each core runs independently on different servers, clock frequencies may vary slightly, potentially leading to serious problems such as data conflicts and deadlocks. Therefore, to ensure system correctness and reliability, reliable time synchronization methods are required to ensure consistent time across all servers. Currently, common time synchronization methods for distributed simulation systems include the Network Time Protocol and the Berkeley algorithm.

[0021] The Network Time Protocol (NTP) is a protocol used to synchronize computer clocks with time servers to achieve high-precision time correction. However, this method is not suitable for distributed systems where external clock sources are unavailable. Because such systems cannot know the real time, they may experience time desynchronization over long periods of time.

[0022] The Berkeley algorithm is suitable for distributed systems where an external clock source is unavailable. Because such systems cannot know the true time, they can only maintain a global average time as a standard. A time server periodically communicates with other servers, collects their time information, and calculates an average time. The server then sends this average time back to the other servers so that they can adjust their own clocks based on it.

[0023] Currently, the main time synchronization algorithms are based on the two aforementioned strategies. However, these existing technologies have their limitations and unresolved technical issues:

[0024] 1. NTP's external time source is unavailable: Once the communication link between the cluster server and the atomic clock device fails, the server can only rely on its own clock to keep time. Due to slight differences in the internal clocks of each server, time synchronization will occur between the servers after running for a long time.

[0025] 2. Berkeley algorithm performance bottleneck problem: As the number of servers increases, more communication overhead will be brought, which will increase the resource consumption of the central coordination node and affect the overall simulation effect.

[0026] 3. Single point failure problem of Berkeley algorithm: The central coordination node fails, resulting in all member nodes being unable to access and receive notifications, ultimately rendering the entire system unusable.

[0027] In order to solve the above problems, the present disclosure proposes a time synchronization method for distributed systems. The technical concept is to use a grouped time management algorithm to divide the nodes in the system into different time synchronization domains, thereby reducing the system's communication overhead and resource consumption; and when the nodes in the system change, the time synchronization roles of the nodes in each time synchronization domain are updated in a timely manner, thereby ensuring the reliability of the entire system.

[0028] The time synchronization method for distributed systems disclosed in this disclosure can be applied to scenarios with time synchronization requirements in large-scale distributed simulation systems consisting of multiple servers, including but not limited to:

[0029] 1. Time synchronization of each simulation chip in the simulation system of large-capacity and high-speed communication equipment;

[0030] 2. Time synchronization of each simulated drone in a large-scale drone self-organizing network simulation system;

[0031] 3. In large-scale satellite network simulation systems, time synchronization of each simulated satellite.

[0032] The method embodiments provided in the embodiments of the present disclosure can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 is a hardware structure block diagram of a mobile terminal of a time synchronization method for a distributed system according to an embodiment of the present disclosure. As shown in Figure 1, the mobile terminal may include one or more (only one is shown in Figure 1) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the above-mentioned mobile terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It can be understood by those skilled in the art that the structure shown in Figure 1 is only for illustration and does not limit the structure of the above-mentioned mobile terminal. For example, the mobile terminal may also include more or fewer components than those shown in Figure 1, or have a configuration different from that shown in Figure 1.

[0033] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the time synchronization method of the distributed system in the embodiment of the present disclosure. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implementing the above-mentioned method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely located relative to the processor 102, and these remote memories may be connected to the mobile terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0034] The transmission device 106 is used to receive or send data via a network. A specific example of the aforementioned network may include a wireless network provided by the mobile terminal's communications provider. In one embodiment, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0035] FIG2 is a diagram of a multi-dimensional cross-domain collaborative time management topology system architecture according to an embodiment of the present disclosure. The embodiment of the present disclosure can run on the network architecture shown in FIG2. As shown in FIG2, the system architecture includes: a global synchronization server, a local synchronization server, a member server, a local synchronization domain, and a member synchronization domain. The functions or relationships of the above-mentioned various servers and various synchronization domains are as follows:

[0036] Global synchronization server: responsible for receiving time signals sent by local synchronization servers, maintaining global time signals, sending notifications to local synchronization servers to continue executing tasks, and executing tasks.

[0037] Local synchronization server: responsible for receiving the time signal sent by the member synchronization server, sending the collected timestamps to the global synchronization server, maintaining the local time signal, sending notifications to the member synchronization server to continue executing the task, and executing the task.

[0038] Member server: responsible for sending the current advanced timestamp to the local synchronization server and executing tasks.

[0039] Global synchronization domain: It consists of global synchronization servers. When a global synchronization server goes offline, a candidate global server can be selected from the local synchronization domain to replace it.

[0040] Local synchronization domain: It is composed of local synchronization servers. Candidate global synchronization servers can be selected based on the ring election algorithm. When a local synchronization server goes offline, a candidate local server can be selected from the corresponding member synchronization domain to replace it.

[0041] Member synchronization domain: It is composed of member synchronization servers and can select candidate local synchronization servers based on the ring election algorithm.

[0042] It should be noted that the three-level cross-domain time synchronization topology structure of global synchronization domain-local synchronization domain-member synchronization domain shown in Figure 2 above is only an example of the present disclosure. The levels of different synchronization domains can be expanded to multiple layers according to actual needs, and the local synchronization domain and member synchronization domain can also be expanded to multiple layers according to actual needs. The embodiments of the present disclosure are not limited here.

[0043] The time synchronization method for distributed systems disclosed herein can be applied to distributed systems, and in particular, to large-scale distributed simulation systems based on two or more servers. For example, it can be applied to multi-server distributed simulation systems that need to handle large amounts of data exchange and computing tasks, such as simulations of high-speed communication equipment, large-capacity data exchange equipment, large-scale unmanned aerial vehicle ad hoc networks, and large-scale satellite networks.

[0044] Among them, the characteristics of this type of simulation system are:

[0045] 1. High degree of parallelism: Simulation tasks usually require a large amount of computing and storage resources. A distributed system consisting of multiple servers can decompose tasks into multiple subtasks for parallel processing, thereby improving simulation efficiency.

[0046] 2. High reliability: Servers in the distributed system can back up each other. When a server fails, it can automatically switch to the backup server to continue running, ensuring the high reliability of the simulation system.

[0047] 3. High scalability: The distributed system can dynamically increase or decrease the number of servers according to the needs of the simulation task to achieve high scalability of the system.

[0048] 4. Sensitive to network delay: Servers in distributed systems require a high-speed, low-latency network environment to ensure the real-time and accuracy of simulation tasks.

[0049] In this embodiment, a time synchronization method for a distributed system running on the above-mentioned mobile terminal or network architecture is provided. FIG3 is a flow chart of time synchronization of a distributed system according to an embodiment of the present disclosure. As shown in FIG3 , the flow includes the following steps:

[0050] Step S301: Acquire a time synchronization topology of the distributed system. The time synchronization topology includes synchronization domains at different levels. The synchronization domain includes at least one synchronization node. The synchronization nodes are assigned different time synchronization roles according to the logical relationship between the nodes.

[0051] The embodiments of the present disclosure are described using a distributed simulation system as an example. The distributed simulation system may include multiple servers, and each server may serve as a synchronization node in a system time synchronization topology.

[0052] For example, referring to Figure 2, the user can determine in advance the number of time synchronization domains that need to be divided based on the number of servers, and logically divide the cluster composed of multiple servers into synchronization domains of different levels. Each server in the synchronization domain can serve as a synchronization node, and the synchronization nodes in each synchronization domain are communicated with each other. Each synchronization node in each current-level synchronization domain is communicated with all synchronization nodes in the corresponding next-level synchronization domain.

[0053] Nodes in a synchronization domain can be assigned different time synchronization roles according to the logical relationship between the nodes, where the time synchronization roles can include global synchronization nodes, local synchronization nodes, member synchronization nodes, and the like.

[0054] As an example, the process of assigning different time synchronization roles can be as follows:

[0055] Based on the initial performance indicators of the servers, such as the number of CPU cores, memory size, network bandwidth, etc., a server with the best performance can be selected as the global synchronization node, M servers with the second best performance can be selected as local synchronization nodes, and the remaining nodes can be used as member nodes.

[0056] For example, after the hierarchical structure is determined and the roles are assigned, the communication links between the global synchronization node, the local synchronization node, and the member nodes can form an M-tree topology. Assuming that the distributed simulation system consists of N servers, That is, the minimum value that can form a three-level tree topology, and M is a positive integer.

[0057] It should be noted that the global synchronization node and the local synchronization node are only logical abstractions of the server's time synchronization role. In fact, like the member nodes, they also participate in the task execution of the simulation system.

[0058] After the synchronization nodes in the system are assigned time synchronization roles, the system can start time synchronization.

[0059] Exemplarily, the time synchronization of the simulation system begins, and each member server can send a timestamp to the local synchronization node every t time slices, and then enter a blocking state; after each local synchronization server receives the timestamps of all member servers in the management scope, it can send a timestamp to the global synchronization server, and then enter a blocking state; after the global synchronization server receives the timestamps of all local synchronization servers, it advances the global clock and notifies all local synchronization servers to continue executing the simulation task.

[0060] After receiving a response from the global synchronization server, the local synchronization server continues the simulation task, advances the local clock, and sends a notification to the member servers it manages to continue the simulation task. When the local synchronization node receives the timestamps of all member synchronization nodes in the corresponding next-level synchronization domain and the timestamps of all member synchronization nodes are equal, it indicates that the timestamps of all member synchronization nodes in the next-level synchronization domain corresponding to the local synchronization node have been advanced to the same time, completing time synchronization.

[0061] After receiving the reply, the member server continues to execute the simulation task, and each member server's internal clock advances. When the global synchronization node receives the timestamps of all local synchronization nodes in the corresponding next-level synchronization domain, and the timestamp values ​​of all local synchronization nodes are equal, it indicates that the timestamps of all local synchronization nodes in the next-level synchronization domain corresponding to the global synchronization node have been advanced to the same time, and time synchronization is complete.

[0062] At this point, the distributed system completes the time synchronization of the nodes.

[0063] This embodiment transmits synchronization signals and time information by sending timestamps step by step, and can determine the clock to which the node corresponding to each time synchronization role has advanced.

[0064] Step S302 : When the synchronization node changes, the time synchronization role of the synchronization node in the time synchronization topology is updated based on the changed synchronization node.

[0065] For example, when the synchronization nodes in the system change, the time synchronization roles of the synchronization nodes in the time synchronization topology can be adjusted based on the changed synchronization nodes. For example, when a synchronization node goes offline or a new node joins, the global synchronization node and the local synchronization node can be reselected, etc.

[0066] In an exemplary embodiment, when the synchronization node changes, the time synchronization role of the synchronization node in the time synchronization topology structure is updated based on the changed synchronization node, including: when the synchronization node goes offline, determining the candidate synchronization node corresponding to the offline synchronization node in the current hierarchical synchronization domain; and updating the time synchronization role of the synchronization node in the time synchronization topology structure based on the candidate synchronization node.

[0067] In the embodiment of the present disclosure, if a server in the distributed system is offline at this time, the time synchronization roles can be reallocated to the servers in the system, and cross-domain scheduling can be performed based on the reallocated time synchronization roles to update the current time synchronization topology.

[0068] For example, when a synchronization node goes offline, the standby synchronization node corresponding to the offline synchronization node can be determined based on the time synchronization role of the offline synchronization node and the level of the synchronization domain where the offline synchronization node is located. The standby synchronization node can replace the offline synchronization node and update the time synchronization role of the synchronization node in the time synchronization topology structure.

[0069] In an exemplary embodiment, the candidate synchronization node is a synchronization node in a next-level synchronization domain that is communicatively connected to the offline synchronization node; updating the time synchronization role of the synchronization node in the time synchronization topology structure based on the candidate synchronization node includes: deleting the offline synchronization node in the current-level synchronization domain, and scheduling the candidate synchronization node from the next-level synchronization domain to the current-level synchronization domain.

[0070] Exemplarily, the candidate synchronization node can be a synchronization node in the next-level synchronization domain corresponding to the offline synchronization node. When a synchronization node goes offline, the offline synchronization node can send an offline notification or an offline signal to the synchronization node in the corresponding next-level synchronization domain, and delete the offline synchronization node in the current-level synchronization domain, thereby spontaneously completing the switching of the time synchronization role. For example, when a local synchronization server goes offline, the local synchronization server sends an offline signal to the candidate synchronization server in the corresponding next-level member synchronization domain. After receiving the offline signal, the candidate synchronization server in the corresponding member synchronization domain can be dispatched from the member synchronization domain to the local synchronization domain to become the new local synchronization server, thereby spontaneously completing the switching of the time synchronization role.

[0071] In an exemplary embodiment, before the synchronization node changes, it also includes: a ring-based election algorithm to select the synchronization node with the largest performance weight from each synchronization domain of the next level, and determine the synchronization node with the largest performance weight as the candidate synchronization node corresponding to the synchronization node in the synchronization domain of the current level.

[0072] Exemplarily, before the synchronization node changes, a corresponding candidate synchronization node may be selected in advance for each synchronization node in each synchronization domain of the current level based on a ring election algorithm.

[0073] As an example, candidate synchronization nodes can be pre-determined based on a ring election algorithm. When a synchronization node goes offline, time synchronization roles can be quickly switched, improving efficiency. Alternatively, when a synchronization node goes offline, a candidate synchronization node can be selected from the next-level synchronization domain corresponding to the offline synchronization node based on the ring election algorithm to replace the offline synchronization node.

[0074] For example, referring to Figure 2, if a server is offline at this time, and the offline server is a global synchronization server, the offline global synchronization server node can be deleted, and a candidate global synchronization node can be selected from the servers in the local synchronization domain according to the ring-based election algorithm as the new global synchronization server, and the new global synchronization server can be scheduled to the global synchronization domain.

[0075] If the offline server is a local server, the offline local synchronization server can be deleted, and a candidate local synchronization server can be selected from the member servers adjacent to the offline local synchronization server according to the ring-based election algorithm as the new local synchronization server, and the new local synchronization server can be scheduled to the corresponding local synchronization domain.

[0076] If the offline server is a member server, no adjustment is required.

[0077] As an example, the synchronization node with the largest performance weight may be selected from each synchronization domain of the next level, and used as the candidate synchronization node corresponding to the synchronization node in the synchronization domain of the current level.

[0078] In an exemplary embodiment, the selection process may specifically include the following steps:

[0079] Step S3001: Select a synchronization node from each synchronization domain of the next level as a convening node, and send a data packet carrying the convening node ID and the performance weight of the convening node to the successor node, so that the successor node receives the data packet and compares the performance weight of the convening node in the data packet with the performance weight of its own node;

[0080] As an example, in each synchronization domain at the next level, a synchronization node can be arbitrarily selected as the convening node, and nodes in the synchronization domain other than the convening node can be selected as successor nodes. For example, the node with the smallest node ID can be selected as the convening node.

[0081] For example, the convening node may send a data packet carrying the convening node ID and the performance weight of the convening node to its successor node. If the successor node does not respond, the convening node may send the data packet to the next successor node in the same synchronization domain.

[0082] Illustratively, after the convening node receives a response from the successor node that the data packet has been received, the successor node may obtain its own performance weight and compare the performance weight of the convening node in the data packet with the performance weight of its own node.

[0083] Step S3002: If the performance weight of the successor node is greater than the performance weight of the convening node, identify the successor node as a candidate synchronization node of the current-level synchronization domain, update the convening node ID in the data packet to the successor node ID, and update the performance weight of the convening node to the performance weight of the successor node;

[0084] Exemplarily, if the performance weight of the successor node is greater than the performance weight of the convening node, the successor node can be identified as a candidate synchronization node for the current level synchronization domain, and the ID and performance weight of the convening node in the data packet are updated to the ID and performance weight of the successor node.

[0085] In an exemplary embodiment, when the performance weight of the successor node is equal to the performance weight of the convening node, the successor node ID and the convening node ID are compared; when the successor node ID is greater than the convening node ID, the successor node is identified as the candidate synchronization node, and the convening node ID in the data packet is updated to the successor node ID, and the performance weight of the convening node is updated to the performance weight of the successor node.

[0086] Exemplarily, if the performance weight of the successor node is equal to the performance weight of the convening node, the successor node ID can be compared with the convening node ID, and if the successor node ID is greater than the convening node ID, the successor node is identified as a candidate synchronization node, and the ID and performance weight of the convening node in the data packet are updated to the ID and performance weight of the successor node.

[0087] Step S3003, sending the updated data packet to the next successor node, and when the data packet returns to the convening node, determining the node corresponding to the node ID in the returned data packet as the candidate synchronization node corresponding to the synchronization node in the current level synchronization domain.

[0088] Exemplarily, the updated data packet can be sent to the next successor node, which can continue to receive the updated data packet and compare the performance weight of its own node with the performance weight of the node in the current data packet. When the performance weight of its own server is greater than the performance weight of the node in the current data packet, the node ID in the current data packet is updated to its own server ID, and the performance weight of the node in the current data packet is updated to the performance weight of its own node, and the updated data packet is continued to be passed until the data packet returns to the target server.

[0089] Exemplarily, when the data packet is returned to the convening node, the node corresponding to the node ID in the returned data packet may be determined as the candidate synchronization node corresponding to the synchronization node in the current hierarchical synchronization domain.

[0090] For example, when the packet returns to the convening node, the convening node can re-include the candidate node ID in the packet and then broadcast the packet containing the candidate node ID to other successor nodes in the same synchronization domain, notifying all nodes in the same synchronization domain of the election result. When the packet containing the candidate synchronization node ID returns to the convening node again, it indicates that all nodes in the synchronization domain have learned the candidate synchronization node ID.

[0091] In an exemplary embodiment, when the synchronization node changes, updating the time synchronization role of the synchronization node in the time synchronization topology structure based on the changed synchronization node further includes:

[0092] When a new synchronization node joins, the performance weight of the synchronization node in the time synchronization topology structure and the performance weight of the new synchronization node are obtained; based on the performance weight of the synchronization node in the time synchronization topology structure and the performance weight of the new synchronization node, the time synchronization role of the synchronization node in the time synchronization topology structure is updated.

[0093] In the embodiment of the present disclosure, if a new node joins the distributed system at this time, the time synchronization role can be reallocated to the synchronization node in the time synchronization topology structure, and cross-domain scheduling can be performed according to the new time synchronization role to update the time synchronization topology structure of multi-server cross-domain collaboration.

[0094] For example, when a new node joins, the performance weight of the synchronization node in the current time synchronization topology and the performance weight of the new synchronization node can be obtained, and the time synchronization role of the synchronization node in the current time synchronization topology can be updated based on the performance weight of the synchronization node in the current time synchronization topology and the performance weight of the new synchronization node.

[0095] In an exemplary embodiment, obtaining the performance weight of the synchronization node in the time synchronization topology and the performance weight of the new synchronization node includes:

[0096] Obtain the performance index parameters of the synchronization node in the time synchronization topology structure and the performance index parameters of the new synchronization node; calculate the performance weight of the synchronization node in the time synchronization topology structure and the performance weight of the new synchronization node according to the performance index parameters of the synchronization node in the time synchronization topology structure and the performance index parameters of the new synchronization node; wherein the performance index parameters of the synchronization node include at least one of the following parameters: the number of idle CPU cores, the idle memory size, the network bandwidth, the weight coefficient of the idle CPU core number, the weight coefficient of the idle memory size, and the weight coefficient of the network bandwidth.

[0097] Exemplarily, the performance weight of the synchronization node can be calculated based on the performance indicators of the synchronization node, where the performance indicators of the synchronization node may include but are not limited to the number of idle CPU cores, the idle memory size, the network bandwidth, the weight coefficient of the idle CPU cores, the weight coefficient of the idle memory size, and the weight coefficient of the network bandwidth.

[0098] As an example, the performance weight calculation formula can be as follows: W = w1×NUM_CPU_free+w2×NUM_Memory_free+w3×Bandwidth

[0099] Among them, NUM_CPU_free is the number of idle CPU cores, NUM_Memory_free is the free memory size, Bandwidth is the network bandwidth, and w1, w2, and w3 are the weight coefficients of the idle CPU core number, free memory size, and network bandwidth, respectively.

[0100] In an exemplary embodiment, updating the time synchronization role of the synchronization node in the time synchronization topology structure according to the performance weight of the synchronization node in the time synchronization topology structure and the performance weight of the new synchronization node includes:

[0101] Comparing the performance weight of the new synchronization node with the performance weights of the synchronization nodes in the time synchronization topology layer by layer in descending order of the synchronization domain levels in the time synchronization topology;

[0102] In the case where the performance weight of the new synchronization node is greater than the performance weight of the synchronization node of the current-level synchronization domain, the new synchronization node replaces the synchronization node of the current-level synchronization domain, and the synchronization information of the synchronization node of the current-level synchronization domain is backed up to the new synchronization node;

[0103] The synchronization node of the current-level synchronization domain is scheduled to the adjacent next-level synchronization domain.

[0104] Exemplarily, after calculating the performance weights of all synchronization nodes in the time synchronization topology structure and the performance weight of the new node, the performance weight of the new synchronization node can be compared with the performance weights of the synchronization nodes in the time synchronization topology structure layer by layer in the order of the synchronization domain levels in the time synchronization topology structure from high to low. When the performance weight of the new synchronization node is greater than the performance weight of the synchronization node of the current-level synchronization domain, the replacement of the new synchronization node with the synchronization node of the current-level synchronization domain is completed, and the synchronization node of the current-level synchronization domain is scheduled to the adjacent next-level synchronization domain.

[0105] In an exemplary embodiment, after scheduling the synchronization node of the current-level synchronization domain to the adjacent next-level synchronization domain, the method further includes:

[0106] Select the synchronization node with the smallest performance weight in the next-level synchronization domain;

[0107] The synchronization node scheduled from the current level to the next level will replace the synchronization node with the smallest performance weight in the adjacent next-level synchronization domain step by step, and the synchronization information of the synchronization node with the smallest performance weight in the next-level synchronization domain will be backed up to the synchronization node scheduled from the previous level to the next level until the replacement of the synchronization node in each level synchronization domain in the time synchronization topology structure is completed.

[0108] Exemplarily, the synchronization node scheduled to the adjacent next-level synchronization domain can be used as the new synchronization node of the next-level synchronization domain. The synchronization node with the smallest performance weight can be selected based on the ring election algorithm, and the new synchronization node of the next-level synchronization domain can replace the synchronization node with the smallest performance weight of the next-level synchronization domain. The synchronization node with the smallest performance weight of the next-level synchronization domain can then be scheduled to its adjacent next-level synchronization domain until the replacement of the synchronization nodes of each level of synchronization domain in the time synchronization topology structure is completed.

[0109] For example, the performance weight value of the new synchronization node is first compared with the performance weight value of the global synchronization node in the global synchronization domain. If the performance weight value of the new synchronization node is greater than the performance weight value of the current global synchronization node, the historical time synchronization information of the current global synchronization node can be backed up to the new synchronization node, and the current global synchronization node can be scheduled to the local synchronization domain adjacent to the current global synchronization node as a new local synchronization node, and the new synchronization node can be scheduled to the global synchronization domain as a new global synchronization node.

[0110] When a new local synchronization node joins the local synchronization domain, the local synchronization node with the smallest performance weight value can be selected based on the ring election algorithm, the historical time synchronization information of the local synchronization node with the smallest performance weight value can be backed up to the new local synchronization node, the new local synchronization node can replace the local synchronization node with the smallest performance weight value, and the local synchronization node with the smallest performance weight value can be scheduled to the member synchronization domain adjacent to the local synchronization node with the smallest performance weight value as a new member synchronization node.

[0111] In an exemplary embodiment, when the performance weight of the new synchronization node is less than or equal to the performance weight of the synchronization node of the current-level synchronization domain, the new synchronization node is scheduled to the next-level synchronization domain adjacent to the current-level synchronization domain.

[0112] Exemplarily, when the performance weight of the new synchronization node is less than or equal to the performance weight of the synchronization node of the current-level synchronization domain, the new synchronization node may be scheduled to the next-level synchronization domain adjacent to the current-level synchronization domain.

[0113] For example, if the performance weight value of the newly added synchronization node is smaller than the performance weight value of the current global synchronization node, the newly added synchronization node can be scheduled to a local synchronization domain adjacent to the global synchronization domain, and in the adjacent local synchronization domain, the local synchronization node with the smallest performance weight value can be selected based on the ring election algorithm.

[0114] If the performance weight value of the local synchronization node selected by the ring election algorithm is less than or equal to the performance weight value of the newly added synchronization node, the historical time synchronization information of the local synchronization node with the smallest performance weight value can be backed up to the newly added synchronization node, the newly added synchronization node can replace the local synchronization node with the smallest performance weight value, and the local synchronization node with the smallest performance weight value can be scheduled to the adjacent member synchronization domain.

[0115] If the performance weight value of the local synchronization node selected by the ring-based election algorithm is greater than the performance weight value of the newly added synchronization node, the newly added synchronization node can continue to be scheduled to the next adjacent synchronization domain on the time synchronization topology, and the synchronization node with the lowest performance weight value can be selected based on the ring-based election algorithm in the adjacent synchronization domain and compared with the performance weight value of the newly added synchronization node. If the performance weight value of the newly added synchronization node is larger, the historical time synchronization information of the synchronization node with the smallest performance weight in the synchronization domain can be backed up to the newly added synchronization node, the new synchronization node can replace the synchronization node with the smallest performance weight in the synchronization domain, and the synchronization node with the smallest performance weight in the synchronization domain can be scheduled to its adjacent next-level synchronization domain.

[0116] The above process may be repeated until a synchronization node with a smaller performance weight value than the newly added synchronization node is found. Otherwise, the newly added synchronization node may be directly used as a member synchronization node.

[0117] As an example, the scheduling algorithm adopted by the embodiment of the present disclosure may be a Breadth First Search (BFS) algorithm.

[0118] As an example, if no synchronization node goes offline or new synchronization node joins within the preset time, the synchronization roles of the synchronization nodes can be reallocated and the time synchronization topology can be updated based on the performance indicators of each synchronization node in the current time synchronization topology after the preset time is reached.

[0119] As an example, the ring-based election algorithm in the embodiment of the present disclosure can dynamically update the time synchronization role in the distributed simulation system. When the global synchronization node or the local synchronization node goes offline, a new candidate node can be quickly selected and cross-domain scheduling can be completed. When a new node joins or the node failure is recovered, the update of the node time synchronization role can be triggered. Compared with the traditional centralized time synchronization algorithm, the overall fault tolerance and scalability of the system are improved, thereby ensuring the high reliability of the entire simulation system.

[0120] In addition, the present disclosure can be used in scenarios that do not rely on external time sources, and thus can avoid time desynchronization problems similar to those caused by external time source failure in NTP.

[0121] In order to facilitate further understanding by those skilled in the art, the present disclosure is further illustrated below through some examples.

[0122] Example 1:

[0123] FIG4 is a flow chart of a ring-based election algorithm for electing candidate synchronization nodes according to an embodiment of the present disclosure. The servers in each synchronization domain are connected in communication to form a server ring. Referring to FIG4 ,

[0124] 1. The user selects the server with the smallest server ID in the server ring as the convening server. The convening server constructs a data packet carrying its own server ID and its own server performance weight;

[0125] 2. The convening server sends a data packet carrying its own server ID and its own server performance weight to the subsequent server in the server ring;

[0126] 3. The convening server determines whether the subsequent server responds. If the subsequent server does not respond, the data packet is sent to the next subsequent server on the ring until a normal operating server is found;

[0127] 4. The convening server determines whether the data packet is returned to the convening server when the subsequent server responds;

[0128] 5. In the case that the data packet does not return to the calling server, after the data packet reaches the subsequent server, the subsequent server can compare its own performance weight value with the performance weight value in the data packet;

[0129] 6. If the performance weight value in the data packet is greater than its own performance weight value, keep the content in the data packet and continue to send the data packet to the next subsequent server;

[0130] 7. If the performance weight value in the data packet is less than its own performance weight value, the performance weight value and server ID in the data packet are updated to the performance weight value and server ID of the current successor server respectively, and the updated data packet is sent to the next successor server;

[0131] 8. When the performance weight value in the data packet is equal to its own performance weight value, the subsequent server determines whether the server ID in the data packet is less than its own server ID. If the server ID in the data packet is less than its own server ID, the performance weight value and server ID in the data packet are updated to the performance weight value and server ID of the current subsequent server respectively, and the updated data packet is sent to the next subsequent server. If the server ID in the data packet is greater than or equal to its own server ID, the data packet is directly sent to the next subsequent server.

[0132] 9. When the data packet is returned to the convening server, the convening server may extract the server ID in the data packet and select the server corresponding to the server ID as a candidate synchronization server;

[0133] 10. The convening server regenerates a data packet containing the candidate server performance weight and candidate server ID, and broadcasts the regenerated data packet to all servers on the server ring to inform all servers on the server ring of the election result.

[0134] At this point, the election of candidate servers on the server ring is completed.

[0135] Example 2:

[0136] FIG5 is a flowchart of an update time synchronization topology according to an embodiment of the present disclosure. Taking a distributed simulation system as an example, the distributed simulation system includes multiple servers. Referring to FIG5 :

[0137] 1. Simulation starts;

[0138] 2. Based on the server performance indicators, select the server with the best performance as the global synchronization server, m servers with the second best performance as local synchronization servers, and the remaining servers as member synchronization servers;

[0139] 3. When the global synchronization server or local synchronization server goes offline, the synchronization roles of the servers are reallocated based on the elected candidate servers, and the system time synchronization topology is updated;

[0140] 4. When a new server joins, the synchronization role of the new server is determined based on the performance weight of the new server and the performance weight of the servers in the current time synchronization topology. The corresponding candidate server is re-determined based on the ring election algorithm, the synchronization roles of the servers in the current time synchronization topology are reallocated, and the system's time synchronization topology is updated.

[0141] 5. When the global clock passes T time slices, the server synchronization role is re-determined based on the performance weight of the servers in the current time synchronization topology using the ring-based election algorithm. The synchronization roles of the servers in the current time synchronization topology are then reallocated, and the system's time synchronization topology is updated.

[0142] 6. The simulation ends.

[0143] Example 3:

[0144] FIG6 is a schematic diagram of a process of time synchronization of a distributed system according to an embodiment of the present disclosure. Taking a distributed simulation system as an example, the distributed simulation system includes multiple servers. Referring to FIG6 :

[0145] S600, simulation starts;

[0146] S601, the member synchronization server executes the computing task;

[0147] S602: Determine whether the member synchronization server has passed t time slices;

[0148] S603: If not, continue to execute the computing task; if so, each member synchronization server sends a timestamp to the corresponding local synchronization server;

[0149] S604, the member synchronization server enters a blocked state;

[0150] S605: The local synchronization server executes the computing task and sends the timestamp to the global synchronization server after receiving the timestamps sent by all member synchronization servers. If the timestamps sent by all member synchronization servers are not received, the computing task continues to be executed.

[0151] S606: After sending the timestamp to the global synchronization server, the local synchronization server enters a blocking state.

[0152] S607: The global synchronization server executes the computing task and advances the global clock after receiving the timestamps sent by all local synchronization servers.

[0153] S608, determining whether the global clock is equal to the simulation end time;

[0154] S609: If it is not equal to the simulation end time, notify the local synchronization server to continue to execute the computing task. After receiving the notification, the local synchronization server continues to execute the computing task and notifies the corresponding member synchronization server to continue to execute the computing task.

[0155] S610: If it is equal to the simulation end time, the simulation ends.

[0156] The distributed system of the disclosed embodiment provides a time synchronization topology structure, including synchronization domains at different levels, each synchronization domain including at least one synchronization node, and the synchronization nodes are assigned different time synchronization roles according to the logical relationship between the nodes. On the one hand, compared with the traditional centralized time synchronization topology structure, the synchronization nodes of the highest-level synchronization domain only need to exchange data with the synchronization nodes in the next-level synchronization domain, which greatly reduces the communication overhead and resource consumption. In addition, the high-performance communication framework can be used between the synchronization nodes to improve the overall network performance, such as the Data Plane Development Kit (DPDK), thereby ensuring the high performance of the entire system; on the other hand, in the case of changes in the synchronization nodes, the time synchronization roles of the synchronization nodes in the time synchronization topology structure are updated based on the changed synchronization nodes. Compared with the traditional centralized time synchronization algorithm, the overall fault tolerance and scalability of the system are improved, thereby ensuring the high reliability of the entire simulation system.

[0157] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), including a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present disclosure.

[0158] An embodiment of the present disclosure further provides a computer-readable storage medium, in which a computer program is stored. The computer program is configured to execute the steps of any one of the above method embodiments when run.

[0159] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.

[0160] An embodiment of the present disclosure further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any one of the above method embodiments.

[0161] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0162] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail here.

[0163] Obviously, those skilled in the art should understand that the modules or steps of the present disclosure described above can be implemented using a general-purpose computing device, they can be concentrated on a single computing device, or distributed across a network composed of multiple computing devices, they can be implemented using program code executable by the computing device, and thus, they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be performed in a different order than herein, or they can be fabricated into separate integrated circuit modules, or multiple modules or steps can be fabricated into a single integrated circuit module for implementation. Thus, the present disclosure is not limited to any particular combination of hardware and software.

[0164] The foregoing description is merely a preferred embodiment of the present disclosure and is not intended to limit the present disclosure. Those skilled in the art will readily appreciate that various modifications and variations of the present disclosure are possible. Any modifications, equivalent substitutions, or improvements made within the principles of the present disclosure shall be included within the scope of protection of the present disclosure.

Claims

1. A time synchronization method for a distributed system, the method comprising: Acquire a time synchronization topology structure of the distributed system, wherein the time synchronization topology structure includes synchronization domains at different levels, the synchronization domain includes at least one synchronization node, and the synchronization node is assigned different time synchronization roles according to a logical relationship between the nodes; In the case where the synchronization node changes, the time synchronization role of the synchronization node in the time synchronization topology is updated based on the changed synchronization node.

2. The method according to claim 1, wherein: When the synchronization node changes, updating the time synchronization role of the synchronization node in the time synchronization topology structure based on the changed synchronization node includes: In the case where the synchronization node is offline, determining a candidate synchronization node corresponding to the offline synchronization node in the synchronization domain of the current level; The time synchronization role of the synchronization node in the time synchronization topology is updated according to the candidate synchronization node.

3. The method according to claim 2, wherein: The candidate synchronization node is a synchronization node in a next-level synchronization domain that is communicatively connected to the offline synchronization node; The updating of the time synchronization role of the synchronization node in the time synchronization topology structure according to the candidate synchronization node includes: The offline synchronization nodes in the current-level synchronization domain are deleted, and the candidate synchronization nodes are scheduled from the next-level synchronization domain to the current-level synchronization domain.

4. The method according to claim 2, wherein: Before the synchronization node changes, the method further includes: Based on the ring election algorithm, a synchronization node with the largest performance weight is selected from each synchronization domain of the next level, and the synchronization node with the largest performance weight is determined as a candidate synchronization node corresponding to the synchronization node in the synchronization domain of the current level.

5. The method according to claim 4, wherein: The ring-based election algorithm selects a synchronization node with the largest performance weight from each synchronization domain of the next level, and determines the synchronization node with the largest performance weight as a candidate synchronization node corresponding to the synchronization node in the synchronization domain of the current level, including: Select a synchronization node from each synchronization domain of the next level as a convening node, and send a data packet carrying the convening node ID and the performance weight of the convening node to the successor node, so that the successor node receives the data packet and compares the performance weight of the convening node in the data packet with the performance weight of its own node; In the case where the performance weight of the successor node is greater than the performance weight of the convening node, the successor node is identified as a candidate synchronization node of the current level synchronization domain, and the convening node ID in the data packet is updated to the successor node ID, and the performance weight of the convening node is updated to the performance weight of the successor node; The updated data packet is sent to the next successor node, and when the data packet is returned to the convening node, the node corresponding to the node ID in the returned data packet is determined as the candidate synchronization node corresponding to the synchronization node in the current level synchronization domain.

6. The method according to claim 5, wherein: Also includes: When the performance weight of the successor node is equal to the performance weight of the convening node, the successor node ID Compare with the convening node ID; When the successor node ID is greater than the convening node ID, the successor node is identified as the candidate synchronization node, the convening node ID in the data packet is updated to the successor node ID, and the performance weight of the convening node is updated to the performance weight of the successor node.

7. The method according to claim 2, wherein: In the case where the synchronization node changes, updating the time synchronization role of the synchronization node in the time synchronization topology structure based on the changed synchronization node also includes: When a new synchronization node is added, obtaining the performance weight of the synchronization node in the time synchronization topology structure and the performance weight of the new synchronization node; The time synchronization role of the synchronization node in the time synchronization topology structure is updated according to the performance weight of the synchronization node in the time synchronization topology structure and the performance weight of the new synchronization node.

8. The method according to claim 7, wherein: The obtaining the performance weight of the synchronization node in the time synchronization topology structure and the performance weight of the new synchronization node includes: Acquire performance indicator parameters of synchronization nodes in the time synchronization topology structure and performance indicator parameters of the new synchronization node; According to the performance indicator parameters of the synchronization nodes in the time synchronization topology structure and the performance indicator parameters of the new synchronization nodes, the performance weights of the synchronization nodes in the time synchronization topology structure and the performance weights of the new synchronization nodes are calculated respectively; wherein the performance indicator parameters of the synchronization nodes include at least one of the following parameters: the number of idle CPU cores, the idle memory size, the network bandwidth, the weight coefficient of the idle CPU cores, the weight coefficient of the idle memory size, and the weight coefficient of the network bandwidth.

9. The method according to claim 7, wherein: The updating of the time synchronization role of the synchronization node in the time synchronization topology structure according to the performance weight of the synchronization node in the time synchronization topology structure and the performance weight of the new synchronization node comprises: Comparing the performance weight of the new synchronization node with the performance weights of the synchronization nodes in the time synchronization topology layer by layer in the order of the synchronization domain levels in the time synchronization topology from high to low; In the case where the performance weight of the new synchronization node is greater than the performance weight of the synchronization node of the current-level synchronization domain, the synchronization node of the current-level synchronization domain is replaced by the new synchronization node, and the synchronization information of the synchronization node of the current-level synchronization domain is backed up to the new synchronization node; The synchronization node of the current-level synchronization domain is scheduled to an adjacent next-level synchronization domain.

10. The method according to claim 9, wherein: After scheduling the synchronization node of the current-level synchronization domain to the adjacent next-level synchronization domain, the method further includes: Select the synchronization node with the smallest performance weight in the next-level synchronization domain; The synchronization node scheduled from the current level to the next level replaces the synchronization node with the smallest performance weight in the adjacent next level synchronization domain step by step, and the synchronization information of the synchronization node with the smallest performance weight in the next level synchronization domain is backed up to the synchronization node scheduled from the previous level to the next level until each level in the time synchronization topology is completed. Replacement of synchronization nodes in a level sync domain.

11. The method according to claim 10, wherein: Also includes: When the performance weight of the new synchronization node is less than or equal to the performance weight of the synchronization node of the current-level synchronization domain, the new synchronization node is scheduled to a next-level synchronization domain adjacent to the current-level synchronization domain.

12. A computer-readable storage medium having a computer program stored therein, wherein: When the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 11 are implemented.

13. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in any one of claims 1 to 11 when executing the computer program.

Citation Information

Patent Citations

  • Multi-node coordinated time consistency management method

    CN101132270A

  • Version control method, nodes and system of distributed system

    CN101753609A

  • Wireless sensor network synchronization method based on dynamic path and variable period

    CN108712769A

  • Dynamic topology reconfiguration in federated learning systems

    US20230281502A1