Time synchronization method of distributed system

By assigning different time synchronization roles in the distributed simulation system and updating the topology structure, data conflicts and resource consumption problems caused by clock frequency differences in distributed systems are solved, and the fault tolerance and reliability of the system are improved.

CN119629063APending Publication Date: 2025-03-14ZTE CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311184237.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-12
Publication Date
2025-03-14

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

The time synchronization method of a distributed system is adopted to obtain the time synchronization topology and allocate different time synchronization roles according to the logical relationship between nodes, so as to reduce communication overhead and resource consumption, and update the roles in the time synchronization topology when the synchronization node changes.

Benefits of technology

It effectively reduces the communication overhead and resource consumption of distributed systems, improves the fault tolerance and scalability of the system, and thus ensures the high reliability of the entire simulation system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119629063A_ABST
    Figure CN119629063A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a time synchronization method for a distributed system, and the method comprises the steps: obtaining a time synchronization topological structure of the distributed system, the time synchronization topological structure comprises synchronization domains of different levels, and the synchronization domains comprise at least one synchronization node, different time synchronization roles are distributed to the synchronization nodes according to the logic relation between the nodes; and under the condition that the synchronization nodes change, the time synchronization roles of the synchronization nodes in the time synchronization topological structure are updated based on the changed synchronization nodes. Through the method and the device, the problems of high communication overhead, high resource consumption and poor fault tolerance, expansibility and reliability of the whole system in related technologies are solved, and compared with a traditional centralized time synchronization algorithm, the communication overhead and the resource consumption are greatly reduced, the fault tolerance and the expansibility of the whole system are improved, and the time synchronization efficiency is improved. Therefore, the high reliability of the whole simulation system is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of communications, and in particular to a time synchronization method for a distributed system. Background Art

[0002] With the rapid development of modern computer technology, the scale and structure of objects to be simulated are becoming more and more complex, so the data and computing tasks that simulation systems need to process are also increasing. In this context, clusters composed 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, there may be slight differences in clock frequency, which may cause some serious problems, such as data conflicts, deadlock crashes, etc., which in turn leads to high communication overhead and resource consumption when data is exchanged between servers, as well as poor fault tolerance, scalability and reliability of the overall system. Summary of the invention

[0003] The embodiment of the present invention provides a time synchronization method for a distributed system, so as to at least solve the problems of large communication overhead, large resource consumption, and poor fault tolerance, scalability and reliability of the whole system in the related technology.

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

[0005] 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;

[0006] 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.

[0007] According to yet another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any one of the above method embodiments when run.

[0008] According to yet another embodiment of the present invention, there is provided 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 execute the steps in any one of the above method embodiments.

[0009] The distributed system of an embodiment of the present invention provides a time synchronization topology structure, including synchronization domains of 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; on the other hand, when the synchronization nodes change, 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. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] 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 invention;

[0011] Figure 2 This is a system architecture diagram of a multi-dimensional cross-domain collaborative time management topology structure according to an embodiment of the present invention;

[0012] Figure 3 is a flowchart of time synchronization of a distributed system according to an embodiment of the present invention;

[0013] Figure 4 is a flow chart of selecting candidate synchronization nodes according to a ring-based election algorithm according to an embodiment of the present invention;

[0014] Figure 5 is a flow chart of updating time synchronization topology according to an embodiment of the present invention;

[0015] Figure 6 It is a schematic diagram of the process of time synchronization of a distributed system according to an embodiment of the present invention. DETAILED DESCRIPTION

[0016] Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings and in combination with the embodiments.

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

[0018] In a distributed system, each server can handle a part of the simulation task, and the distribution and coordination of tasks are usually completed by a central node. By reasonably dividing tasks and resources, the distributed system can make full use of the computing power and storage resources of each server and improve the simulation efficiency. However, in a distributed simulation platform, since each core runs independently on different servers, there may be slight differences in clock frequency, which may cause some serious problems, such as data conflicts, deadlock crashes, etc. Therefore, in order to ensure the correctness and reliability of the system, a reliable time synchronization method is needed to ensure the time consistency of all servers. At present, the common time synchronization methods for distributed simulation systems are the Network Time Protocol and the Berkeley algorithm.

[0019] 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 and will experience time desynchronization problems during long-term operation.

[0020] The Berkeley algorithm is applicable to distributed systems where external clock sources are unavailable. Since such systems cannot know the real time, they can only maintain a global average time as the standard time. A time server will periodically communicate with other servers, collect their time information, and calculate an average time. The server will then send the average time back to other servers so that they can adjust their clocks according to this average time.

[0021] The main time synchronization algorithms currently used are based on the ideas of the above two strategies. However, these existing technologies have their limitations and unresolved technical problems:

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

[0023] 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.

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

[0025] In order to solve the above problems, the present application proposes a time synchronization method for a distributed system. 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 communication overhead and resource consumption of the system; 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 to ensure the reliability of the entire system.

[0026] The time synchronization method of the distributed system of the present application can be applied to scenarios with time synchronization requirements in a large-scale distributed simulation system consisting of multiple servers, including but not limited to:

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

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

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

[0030] The method embodiments provided in the embodiments of the present application 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 FIG. 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 invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 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 mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is for illustration only and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0031] 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 invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above 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 examples, the memory 104 may further include a memory remotely arranged 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.

[0032] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0033] Figure 2 This is a system architecture diagram of a multi-dimensional cross-domain collaborative time management topology structure according to an embodiment of the present invention. The embodiment of the present application can be run on Figure 2 In the network architecture shown in Figure 2 As shown, 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:

[0034] Global synchronization server: responsible for receiving the time signal sent by the local synchronization server, maintaining the global time signal, sending notifications to the local synchronization server to continue the task, and executing the task.

[0035] 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 the task, and executing the task.

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

[0037] Global synchronization domain: It is composed 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.

[0038] 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.

[0039] Member synchronization domain: It is composed of member synchronization servers, and candidate local synchronization servers can be selected based on the ring election algorithm.

[0040] It should be noted that the above Figure 2 The three-level cross-domain time synchronization topology structure of global synchronization domain-local synchronization domain-member synchronization domain shown is only an example of the present invention. 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 invention are not limited here.

[0041] The time synchronization method of the distributed system of the present application can be applied to distributed systems, and in particular to large-scale distributed simulation systems based on two or more servers. As an example, it can be applied to multi-server distributed simulation systems that need to process a large number of data exchange and computing tasks, such as simulation of high-speed communication equipment, large-capacity data exchange equipment, large-scale UAV self-organizing network simulation, and large-scale satellite network simulation.

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

[0043] 1. High degree of parallelization: Simulation tasks usually require a lot 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.

[0044] 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.

[0045] 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.

[0046] 4. Sensitivity 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.

[0047] In this embodiment, a time synchronization method for a distributed system running on the above mobile terminal or network architecture is provided. Figure 3is a flow chart of time synchronization of a distributed system according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps:

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

[0049] The embodiment of the present invention is described by taking 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.

[0050] For example, refer to Figure 2 The user can determine the number of time synchronization domains to be divided in advance according to 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 be used as a synchronization node. The synchronization nodes in each synchronization domain are communicated with each other, and each synchronization node in each current-level synchronization domain communicates with all synchronization nodes in the corresponding next-level synchronization domain.

[0051] The nodes of the synchronization domain may be assigned different time synchronization roles according to the logical relationship between the nodes, wherein the time synchronization roles may include global synchronization nodes, local synchronization nodes, member synchronization nodes, and the like.

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

[0053] According to the initial performance indicators of the server, 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.

[0054] For example, after the hierarchical structure is determined and the role assignment is completed, 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.

[0055] 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. Like the member nodes, they actually participate in the task execution of the simulation system.

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

[0057] 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.

[0058] After receiving the reply from the global synchronization server, the local synchronization server continues to execute the simulation task, the local clock also moves forward, and sends a notification to the member servers it manages to continue executing the simulation task. When the local synchronization node receives the timestamps of all member synchronization nodes of the corresponding next-level synchronization domain, and the timestamp values ​​of all member synchronization nodes are equal, it indicates that the time of all member synchronization nodes of the next-level synchronization domain corresponding to the local synchronization node has moved forward to the same time, and time synchronization has been completed.

[0059] After receiving the reply, the member server continues to execute the simulation task, and the internal clock of each member server moves forward. 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 time of all local synchronization nodes in the next-level synchronization domain corresponding to the global synchronization node has been advanced to the same time, and time synchronization has been completed.

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

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

[0062] 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.

[0063] Exemplarily, 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.

[0064] 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 is offline, determining the candidate synchronization node corresponding to the offline synchronization node in the current level synchronization domain; and updating the time synchronization role of the synchronization node in the time synchronization topology structure based on the candidate synchronization node.

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

[0066] Exemplarily, 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 the time synchronization role of the synchronization node in the time synchronization topology structure can be updated.

[0067] 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.

[0068] 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 corresponding synchronization node in the next-level synchronization domain, and delete the offline synchronization node in the current-level synchronization domain, and spontaneously complete 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 scheduled from the member synchronization domain to the local synchronization domain and become a new local synchronization server, that is, the switching of the time synchronization role is spontaneously completed.

[0069] 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.

[0070] 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.

[0071] As an example, the candidate synchronization node can be predetermined according to the ring election algorithm, and when a synchronization node goes offline, the time synchronization role can be quickly switched to improve efficiency. 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.

[0072] For example, refer to Figure 2 If a server goes offline at this time, and the server that goes offline 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.

[0073] 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.

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

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

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

[0077] Step S3001, selecting a synchronization node from each synchronization domain of the next level as a convening node, and sending a data packet carrying the convening node ID and the performance weight of the convening node to a 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;

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

[0079] Exemplarily, 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.

[0080] Exemplarily, 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.

[0081] Step S3002, when 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 hierarchical 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;

[0082] 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.

[0083] 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.

[0084] 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.

[0085] Step S3003, sending the updated data packet to the next successor node, and when the data packet is returned 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.

[0086] 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, and when its own server performance weight is greater than the performance weight of the node in the current data packet, update the node ID in the current data packet to its own server ID, and update the performance weight of the node in the current data packet to the performance weight of its own node, and continue to pass the updated data packet until the data packet returns to the target server.

[0087] 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 a candidate synchronization node corresponding to the synchronization node in the current level synchronization domain.

[0088] As an example, when the data packet returns to the convening node, the convening node can put the candidate node ID back into the data packet, and then broadcast the data packet containing the candidate node ID to other successor nodes in the same synchronization domain, and notify all nodes in the same synchronization domain of the election result. When the data packet containing the candidate synchronization node ID returns to the convening node again, it means that all nodes in the synchronization domain have known the candidate synchronization node ID.

[0089] 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:

[0090] When a new synchronization node joins, obtain the performance weight of the synchronization node in the time synchronization topology structure and the performance weight of the new synchronization node; update the time synchronization role of the synchronization node in the time synchronization topology structure based on the performance weight of the synchronization node in the time synchronization topology structure and the performance weight of the new synchronization node.

[0091] In an embodiment of the present invention, if a new node joins the distributed system at this time, the time synchronization role can be reallocated for 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.

[0092] Exemplarily, 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.

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

[0094] Obtain performance indicator parameters of the synchronization nodes in the time synchronization topology structure and performance indicator parameters of the new synchronization nodes; calculate the performance weights of the synchronization nodes in the time synchronization topology structure and the performance weights of the new synchronization nodes 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; wherein the performance indicator parameters of the synchronization nodes include at least one of the following parameters: the number of idle CPU cores, the size of idle memory, the network bandwidth, the weight coefficient of the number of idle CPU cores, the weight coefficient of the idle memory size, and the weight coefficient of the network bandwidth.

[0095] 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.

[0096] As an example, the calculation formula of the performance weight can be as follows:

[0097] W=w1×NUM_CPU_free+w2×NUM_Memory_free+w3×Bandwidth

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

[0099] 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:

[0100] 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;

[0101] 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;

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

[0103] 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, and when the performance weight of the new synchronization node is greater than the performance weight of the synchronization node of the synchronization domain of the current level, the replacement of the new synchronization node with the synchronization node of the synchronization domain of the current level is completed, and the synchronization node of the synchronization domain of the current level is scheduled to the adjacent next-level synchronization domain.

[0104] 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:

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

[0106] 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 nodes in each level of synchronization domain in the time synchronization topology structure is completed.

[0107] 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.

[0108] 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.

[0109] 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.

[0110] 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.

[0111] 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.

[0112] 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.

[0113] 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.

[0114] 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 for comparison 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.

[0115] 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.

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

[0117] As an example, if there is no synchronization node disconnection or new synchronization node joining 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.

[0118] As an example, the ring-based election algorithm in the embodiment of the present invention can dynamically update the time synchronization role in the distributed simulation system. When the global synchronization node or the local synchronization node is offline, a new candidate node can be quickly selected and cross-domain scheduling can be completed. When a new node is added 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.

[0119] In addition, the present invention can be used in scenarios that do not rely on external time sources, and therefore can avoid the time desynchronization problem similar to that caused by external time source failure in NTP.

[0120] In order to facilitate further understanding by those skilled in the art, the present invention is further described below through some examples.

[0121] Example 1:

[0122] Figure 4 is a flowchart of selecting candidate synchronization nodes according to a ring-based election algorithm according to an embodiment of the present invention. The servers in each synchronization domain are connected in communication and can form a server ring. Figure 4 :

[0123] 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;

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

[0125] 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;

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

[0127] 5. In the case where the data packet is not returned to the convening 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;

[0128] 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 successor server;

[0129] 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, and the updated data packet is sent to the next successor server.

[0130] 8. When the performance weight value in the data packet is equal to its own performance weight value, the successor 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 successor server, respectively, and the updated data packet is sent to the next successor 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 successor server.

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

[0132] 10. The server is called to regenerate a data packet containing the candidate server performance weight and the candidate server ID, and broadcast the regenerated data packet to all servers on the server ring to inform all servers on the server ring of the election result.

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

[0134] Example 2:

[0135] Figure 5is a flow chart of updating time synchronization topology according to an embodiment of the present invention, taking a distributed simulation system as an example, the distributed simulation system includes multiple servers, referring to Figure 5 :

[0136] 1. Simulation starts;

[0137] 2. According to 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;

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

[0139] 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, and the corresponding candidate server is re-determined based on the ring election algorithm, the synchronization role of the server in the current time synchronization topology is reallocated, and the system's time synchronization topology is updated;

[0140] 5. When the global clock has passed T time slices, the synchronization role of the server is re-determined based on the ring election algorithm according to the performance weight of the server in the current time synchronization topology, and the synchronization role of the server in the current time synchronization topology is reallocated to update the system's time synchronization topology;

[0141] 6. The simulation ends.

[0142] Example 3:

[0143] Figure 6 is a schematic diagram of a distributed system time synchronization process according to an embodiment of the present invention, taking a distributed simulation system as an example, the distributed simulation system includes multiple servers, referring to Figure 6 :

[0144] S600, simulation starts;

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

[0146] S602, determining whether the member synchronization server has passed t time slices;

[0147] S603, if not, continue to execute the computing task; if yes, each member synchronization server sends a timestamp to the corresponding local synchronization server;

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

[0149] S605, the local synchronization server executes the computing task, and after receiving the timestamps sent by all member synchronization servers, sends the timestamp to the global synchronization server; if the timestamps sent by all member synchronization servers are not received, the computing task continues to be executed;

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

[0151] S607, the global synchronization server executes the computing task and advances the global clock after receiving the timestamps sent by all local synchronization servers;

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

[0153] S609: If it is not equal to the simulation end time, the local synchronization server is notified 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.

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

[0155] The distributed system of an embodiment of the present invention provides a time synchronization topology structure, including synchronization domains of different levels, each synchronization domain includes 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, for example, the Data Plane Development Kit (DPDK), thereby ensuring the high performance of the entire system; on the other hand, 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. 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.

[0156] 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 a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, 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, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0157] An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.

[0158] 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.

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

[0160] 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.

[0161] 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 herein.

[0162] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that 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 executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.

[0163] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A time synchronization method for a distributed system, characterized in that: The method comprises: 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, characterized in that 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, characterized in that The candidate synchronization node is a synchronization node in a next-level synchronization domain that is communicatively connected to the offline synchronization node; and updating 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, characterized in that: 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, characterized in that 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, characterized in that Also includes: When the performance weight of the successor node is equal to the performance weight of the convening node, comparing the successor node ID 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, characterized in that: 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, characterized in that 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, characterized in that: 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, characterized in that 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 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 nodes in each level of synchronization domain in the time synchronization topology structure is completed.

11. The method according to claim 10, characterized in that 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, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 11 when executed by a processor.

13. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 1 to 11 are implemented.