CN113014347A - Server time synchronization method and device, computer equipment and storage medium - Google Patents

Server time synchronization method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN113014347A
CN113014347A CN202110182906.XA CN202110182906A CN113014347A CN 113014347 A CN113014347 A CN 113014347A CN 202110182906 A CN202110182906 A CN 202110182906A CN 113014347 A CN113014347 A CN 113014347A
Authority
CN
China
Prior art keywords
time
server
target
deviation
deviations
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110182906.XA
Other languages
Chinese (zh)
Inventor
陈浩能
何志东
黄敏龙
邹胜
苗咏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Archforce Financial Technology Co Ltd
Original Assignee
Shenzhen Archforce Financial Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Archforce Financial Technology Co Ltd filed Critical Shenzhen Archforce Financial Technology Co Ltd
Priority to CN202110182906.XA priority Critical patent/CN113014347A/en
Publication of CN113014347A publication Critical patent/CN113014347A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation
    • H04J3/0658Clock or time synchronisation among packet nodes
    • H04J3/0661Clock or time synchronisation among packet nodes using timestamps
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/10Active monitoring, e.g. heartbeat, ping or trace-route
    • H04L43/106Active monitoring, e.g. heartbeat, ping or trace-route using time related information in packets, e.g. by adding timestamps

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Health & Medical Sciences (AREA)
  • Cardiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Synchronisation In Digital Transmission Systems (AREA)
  • Computer And Data Communications (AREA)

Abstract

The application relates to a server time synchronization method, a server time synchronization device, computer equipment and a storage medium. The method comprises the following steps: receiving a time synchronization instruction; responding to the time synchronization instruction, and acquiring a first time deviation set corresponding to the current time period, wherein the first time deviation set comprises a plurality of target time deviations; sequencing the target time deviations in the first time deviation set to obtain a first time sequence of each target time deviation; determining a target time deviation with link jitter in the first time deviation set based on the first time sequence of the target time deviation and a sequence threshold, and filtering the target time deviation with link jitter to obtain a filtered first time deviation set; and adjusting the time of the slave server based on the filtered first time deviation set. By adopting the method, the accuracy of the time synchronization of the server can be improved.

Description

Server time synchronization method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of communications technologies, and in particular, to a server time synchronization method, apparatus, computer device, and storage medium.
Background
With the development of communication technology, a server time synchronization technology appears, and time synchronization is a process for providing a uniform time scale for a distributed system through some operations on a local clock. The distributed system refers to a software system established on a network. In a software system having strict requirements on the time of submission of recorded data, the accuracy of the submission time must be ensured. For example, a stock exchange system, is important for time synchronization of servers across cities that carry the software system.
However, the current server synchronization method has the problem of low precision.
Disclosure of Invention
In view of the above, it is necessary to provide a server time synchronization method, apparatus, computer device and storage medium capable of improving the server synchronization accuracy.
A server time synchronization method, the method comprising: receiving a time synchronization instruction; responding to the time synchronization instruction, acquiring a first time deviation set corresponding to the current time period, wherein the first time deviation set comprises a plurality of target time deviations, the target time deviations are time deviations between the master server and the slave servers, and the target time deviations are obtained based on the difference of sending time and receiving time of the interactive messages between the master server and the slave servers; sequencing the target time deviations in the first time deviation set to obtain a first time sequence of each target time deviation; determining a target time deviation with link jitter in the first time deviation set based on the first time sequence of the target time deviation and a sequence threshold, and filtering the target time deviation with link jitter to obtain a filtered first time deviation set; and adjusting the time of the slave server based on the filtered first time deviation set.
In one embodiment, the obtaining of the target time offset includes: receiving a synchronous message sent by a main server, wherein the sending time of the synchronous message is a first time; recording a second time of receiving the synchronization message; sending a delay request message to the main server, and recording a third time corresponding to the delay request message, wherein the third time is the time for sending the delay request message; receiving a fourth time returned by the main server, wherein the fourth time is the time when the main server receives the delay request message; obtaining a first time difference between the first time and the second time and a second time difference between the third time and the fourth time; obtaining a target time offset between the slave server and the master server based on the first time difference and the second time difference.
In one embodiment, the obtaining the target time offset between the slave server and the master server based on the first time difference and the second time difference comprises: acquiring a first path delay from the master server to the slave server; the first path delay is the delay time from the main server to the slave server for sending the synchronous message; acquiring a second path delay from the slave server to the master server; the second path delay is the delay time from the slave server to the master server when the slave server sends the delay request message; and obtaining the target time deviation between the slave server and the master server according to the first path delay, the second path delay, the first time difference and the second time difference.
In one embodiment, the method further comprises: when the number of the target time deviations in the first time deviation set is smaller than a number threshold, selecting the target time deviation closest to the current time period from the first time deviation set as a first adjustment time deviation; adjusting the time of the slave server based on the first adjusted time offset; and when the number of the target time deviations in the first time deviation set is larger than a number threshold, sequencing the target time deviations in the first time deviation set to obtain a first time sequence of each target time deviation.
In one embodiment, the first time sequence is a time sequence in which the target time deviations are arranged from small to large; the determining a target time offset for which link jitter is present in the first set of time offsets based on the first temporal ordering of the target time offsets and an ordering threshold comprises: acquiring a target time deviation corresponding to a first time sequence larger than a sequence threshold in the first time deviation set as a jitter time deviation; taking the jitter time offset as a target time offset of link jitter in the first time offset set; the adjusting the time of the slave server based on the filtered set of first time deviations comprises: selecting the largest target time deviation from the filtered first time deviation set as a second adjustment time deviation; adjusting the time of the slave server based on the second adjusted time offset.
In one embodiment, the step of obtaining the target sorting threshold comprises: acquiring second adjustment time deviations corresponding to the plurality of forward time periods respectively, and taking the second adjustment time deviations as reference time deviations; sequencing the reference time deviation according to the time sequence to obtain a reference time deviation sequence; acquiring the variation trend of the reference time deviation sequence; and acquiring a preset sorting threshold, and adjusting the preset sorting threshold according to the direction opposite to the variation trend to obtain the target sorting threshold.
In one embodiment, after the adjusting the time of the slave server based on the filtered first set of time deviations, the method further includes: acquiring a transaction order; the transaction order carries a first timestamp; sending the trade order to a main server; the transaction order carries a time stamp acquisition request; receiving a second timestamp returned by the main server in response to the timestamp obtaining request; and when the difference value between the first time stamp and the second time stamp is larger than a time difference value threshold value, sending an abnormal prompt message corresponding to the slave server to a maintenance terminal.
A server time synchronization apparatus, the apparatus comprising: the time synchronization instruction receiving module is used for receiving a time synchronization instruction; a time synchronization instruction response module, configured to respond to the time synchronization instruction, to obtain a first time deviation set corresponding to a current time period, where the first time deviation set includes a plurality of target time deviations, where the target time deviations are time deviations between a master server and a slave server, and the target time deviations are obtained based on differences between sending times and receiving times of interactive messages between the master server and the slave server; a first time ordering obtaining module, configured to order the target time deviations in the first time deviation set to obtain a first time ordering of each target time deviation; a first time deviation set obtaining module, configured to determine, based on a first time ranking of the target time deviations and a ranking threshold, a target time deviation with link jitter in the first time deviation set, and filter the target time deviation with link jitter to obtain a filtered first time deviation set; and the time adjusting module of the server is used for adjusting the time of the slave server based on the filtered first time deviation set.
In one embodiment, the server time synchronizer further includes: the synchronous message receiving module is used for receiving a synchronous message sent by a main server, wherein the sending time of the synchronous message is a first time; the second time recording module is used for recording the second time for receiving the synchronous message; a third time recording module, configured to send a delay request message to the master server, and record a third time corresponding to the delay request message, where the third time is a time for sending the delay request message; a first time difference and second time difference obtaining module, configured to obtain a first time difference between the first time and the second time and a second time difference between the third time and the fourth time; a target time offset obtaining module, configured to obtain a target time offset between the slave server and the master server based on the first time difference and the second time difference.
In one embodiment, the target time offset obtaining module is configured to obtain a first path delay from the master server to the slave server; the first path delay is the delay time from the main server to the slave server for sending the synchronous message; acquiring a second path delay from the slave server to the master server; the second path delay is the delay time from the slave server to the master server when the slave server sends the delay request message; and obtaining the target time deviation between the slave server and the master server according to the first path delay, the second path delay, the first time difference and the second time difference.
In one embodiment, the server time synchronizer further includes: a first adjustment time deviation determining module, configured to select, when the number of target time deviations in the first time deviation set is smaller than a number threshold, a target time deviation closest to a current time period from the first time deviation set as a first adjustment time deviation; a time adjustment module of the slave server for adjusting the time of the slave server based on the first adjusted time offset; a first time sorting obtaining module, configured to, when the number of the target time deviations in the first time deviation set is greater than a number threshold, perform sorting on the target time deviations in the first time deviation set to obtain a first time sorting of each target time deviation.
In one embodiment, the first time deviation set obtaining module is configured to obtain a target time deviation, as a jitter time deviation, of the first time deviation set, where the first time ranking of the first time deviation set is greater than a ranking threshold; taking the jitter time offset as a target time offset of link jitter in the first time offset set; the adjusting the time of the slave server based on the filtered set of first time deviations comprises: selecting the largest target time deviation from the filtered first time deviation set as a second adjustment time deviation; adjusting the time of the slave server based on the second adjusted time offset.
In one embodiment, the server time synchronizer includes: a second adjustment time deviation obtaining module, configured to obtain second adjustment time deviations corresponding to the multiple forward time periods, respectively, as reference time deviations; a reference time deviation sequence obtaining module, configured to sort the reference time deviations according to a time sequence to obtain a reference time deviation sequence; the variation trend acquisition module of the reference time deviation sequence is used for acquiring the variation trend of the reference time deviation sequence; and the target sorting threshold obtaining module is used for obtaining a preset sorting threshold, and adjusting the preset sorting threshold according to the direction opposite to the change trend to obtain the target sorting threshold.
In one embodiment, the server time synchronizer further includes: the trade order acquisition module is used for acquiring a trade order; the transaction order carries a first timestamp; the trade order sending module is used for sending the trade order to the main server; the transaction order carries a time stamp acquisition request; the second timestamp receiving module is used for receiving a second timestamp returned by the main server in response to the timestamp obtaining request; and the abnormal prompt message sending module is used for sending the abnormal prompt message corresponding to the slave server to the maintenance terminal when the difference value between the first time stamp and the second time stamp is greater than the time difference value threshold.
A computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program: receiving a time synchronization instruction; responding to the time synchronization instruction, acquiring a first time deviation set corresponding to the current time period, wherein the first time deviation set comprises a plurality of target time deviations, the target time deviations are time deviations between the master server and the slave servers, and the target time deviations are obtained based on the difference of sending time and receiving time of the interactive messages between the master server and the slave servers; sequencing the target time deviations in the first time deviation set to obtain a first time sequence of each target time deviation; determining a target time deviation with link jitter in the first time deviation set based on the first time sequence of the target time deviation and a sequence threshold, and filtering the target time deviation with link jitter to obtain a filtered first time deviation set; and adjusting the time of the slave server based on the filtered first time deviation set.
A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of: receiving a time synchronization instruction; responding to the time synchronization instruction, acquiring a first time deviation set corresponding to the current time period, wherein the first time deviation set comprises a plurality of target time deviations, the target time deviations are time deviations between the master server and the slave servers, and the target time deviations are obtained based on the difference of sending time and receiving time of the interactive messages between the master server and the slave servers; sequencing the target time deviations in the first time deviation set to obtain a first time sequence of each target time deviation; determining a target time deviation with link jitter in the first time deviation set based on the first time sequence of the target time deviation and a sequence threshold, and filtering the target time deviation with link jitter to obtain a filtered first time deviation set; and adjusting the time of the slave server based on the filtered first time deviation set.
The server time synchronization method, the device, the computer equipment and the storage medium receive a time synchronization instruction from the server; responding to the time synchronization instruction, acquiring a first time deviation set corresponding to the current time period, wherein the first time deviation set comprises a plurality of target time deviations, the target time deviations are the time deviations between the master server and the slave servers, and the target time deviations are obtained based on the difference of the sending time and the receiving time of the interactive messages between the master server and the slave servers; sequencing the target time deviations in the first time deviation set to obtain a first time sequence of each target time deviation; determining a target time deviation with link jitter in a first time deviation set based on a first time sequence of the target time deviation and a sequence threshold, and filtering the target time deviation with the link jitter to obtain a filtered first time deviation set; and adjusting the time of the slave server based on the filtered first time deviation set. The target time deviation with the link jitter is filtered, and the target time deviation in the time deviation set with the target time deviation with the link jitter is utilized to adjust the slave server to realize time synchronization, so that the precision of the server time synchronization can be effectively improved.
Drawings
FIG. 1 is a diagram of an exemplary implementation of a server time synchronization method;
FIG. 2 is a flow diagram illustrating a method for server time synchronization in one embodiment;
FIG. 3 is a flowchart illustrating the step of obtaining a target time offset in one embodiment;
FIG. 4 is a flow diagram illustrating a method for deriving a target time offset between a slave server and a master server based on a first time difference and a second time difference, according to an embodiment;
FIG. 5 is a flowchart illustrating steps of a server time synchronization method according to another embodiment;
FIG. 6 is a flowchart illustrating steps for obtaining a target sorting threshold in one embodiment;
FIG. 7 is a flowchart illustrating a method for server time synchronization according to another embodiment;
FIG. 8 is a timing diagram illustrating a method for server time synchronization according to one embodiment;
FIG. 9 is a block diagram showing the construction of a server time synchronizer in one embodiment;
FIG. 10 is a diagram showing an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The server time synchronization method provided by the application can be applied to the application environment shown in fig. 1, and is particularly applied to a server time synchronization system. The server time synchronization system includes a first server 102 and a second server 104, wherein the first server 102 communicates with the second server 104 over a network. The first server 102 may act as a master server and the second server 104 may act as a slave server. The second server 104 executes a server time synchronization method, and specifically, the second server 104 receives a time synchronization instruction, and in response to the time synchronization instruction, acquires a first time deviation set corresponding to a current time period, where the first time deviation set includes a plurality of target time deviations, the target time deviation is a time deviation between the first server 102 and the second server 104, and the target time deviation is obtained based on a difference between a sending time and a receiving time of an interactive message between the first server 102 and the second server 104; sequencing the target time deviations in the first time deviation set to obtain a first time sequence of each target time deviation; determining a target time deviation with link jitter in a first time deviation set based on a first time sequence of the target time deviation and a sequence threshold, and filtering the target time deviation with the link jitter to obtain a filtered first time deviation set; the time of the second server 104 is adjusted based on the filtered set of first time deviations, and the time of the first server 102 may be kept unchanged to reduce the time deviation between the first server 102 and the second server 104. The first server 102 and the second server 104 may be implemented by separate servers or a server cluster composed of a plurality of servers.
In one embodiment, as shown in fig. 2, a server time synchronization method is provided, which is described by taking the method as an example applied to the second server in fig. 1, and includes the following steps:
step 202, a time synchronization command is received.
The time synchronization instruction refers to an instruction capable of triggering time synchronization between the server and the server. The synchronization of the server time may be started by receiving the instruction.
Specifically, when the time of the slave server needs to be synchronized with the time of the master server, the time synchronization between the slave server and the master server needs to be completed on the slave server by receiving a manually or automatically triggered time synchronization instruction.
In one embodiment, the slave server automatically triggers the script program through the script program which is provided with the slave server and receives the time synchronization instruction through the triggered script program when the slave server starts to work.
In one embodiment, the slave server receives the time synchronization instruction by receiving a user's start operation of a button corresponding to the time synchronization instruction.
Step 204, in response to the time synchronization instruction, obtaining a first time deviation set corresponding to the current time period, where the first time deviation set includes a plurality of target time deviations, the target time deviation is a time deviation between the master server and the slave server, and the target time deviation is obtained based on a difference between a sending time and a receiving time of the interactive message between the master server and the slave server.
Wherein, the target time deviation refers to the difference between the master server system time and the slave server system time. The interactive message refers to a message transmitted between the master server and the slave server. Such as a synchronization message or a delay request message, etc.
Specifically, after receiving the time synchronization instruction from the server, when responding to the time synchronization instruction, differences between a plurality of sending times corresponding to the plurality of interactive messages and a plurality of receiving times corresponding to the plurality of interactive messages are obtained, a plurality of target time deviations corresponding to the plurality of interactive messages are obtained by using the differences, and the plurality of target time deviations form a first time deviation set. For example, a target time offset is obtained by using the difference between the time when the master server sends the synchronization message to the slave server and the time when the slave server receives the synchronization message, and the difference between the time when the slave server sends the delay request message and the time when the master server sends the reply message of the delay request message, and a plurality of the target time offsets form a first time offset set corresponding to the current time period. It can be understood that the number of the sets of the synchronization message sent by the master server and the delay request message sent by the slave server may be multiple sets, the difference between the multiple sets of the message sending time and the corresponding message receiving time is obtained through the multiple sets of the synchronization message and the delay request message sent, and the first time deviation set is obtained through the multiple target time deviations obtained through the difference between the multiple sets of the message sending time and the corresponding message receiving time.
In one embodiment, when the slave server responds to the time synchronization instruction, the time point sent by the master server and corresponding to the time point sent by the master server is acquired and recorded as t 1; the time point when the slave server local end receives the synchronization message sent by the master server is marked as t2, and the time point when the slave server local end sends the delay request message to the master server is marked as t 3; the time point when the main server receives the delay request message is marked as t4, the difference between the time when the local terminal receives the synchronization message sent by the main server and the time when the local terminal sends the synchronization message corresponding to the main server is obtained and is marked as t2-t1, and the difference between the time when the main server receives the delay request message and the time when the local terminal sends the delay request message to the main server is marked as t4-t3, so that the target time deviation is obtained. If the target time offset is denoted as offset, the target time offset can be expressed as: offset is [ t2-t1- (t4-t3) ]/2; the master server and the slave server may send and receive the interactive message for multiple times, and the slave server may obtain multiple offsets in the first time offset set corresponding to the current time period.
Step 206, sorting the target time deviations in the first time deviation set to obtain a first time sorting of each target time deviation.
The time sequence refers to a sequence according to a time length. The sorting can be performed from small to large according to the time length, and can also be performed from large to small according to the time length. For example, the target time offset is denoted as offset, the time lengths of the offsets are 30S, 60S, 90S, and 120S, respectively, and the time sequence may be {30S, 60S, 90S, 120S } or {120S, 90S, 60S, 30S } in descending order of time length. Where S represents seconds, which may be the unit name of the time length.
Specifically, after the first time deviation set is obtained from the server, the target time deviations in the first time deviation set are sorted to obtain a sorted first time deviation set.
And 208, determining the target time deviation with link jitter in the first time deviation set based on the first time sequence of the target time deviation and the sequence threshold, and filtering the target time deviation with link jitter to obtain a filtered first time deviation set.
The sorting threshold is a critical value of time sorting, the target time deviation with link jitter is greater than the critical value, and the target time deviation without link jitter or with link jitter within an acceptable range is smaller than or equal to the critical value. Alternatively, a target time offset with link jitter less than the threshold is present, and a target time offset with link jitter greater than or equal to the threshold is absent or within an acceptable range.
Specifically, after the server performs time sequencing on the first time deviation set, the target time deviation with link jitter is filtered out, so as to obtain a filtered first time deviation set.
In one embodiment, the time-ordered first time deviation set has a sorting threshold of 80%, and if the first time deviation set is ordered from small to large with a target time deviation value, i.e., {30S, 60S, 90S, 120S, 150S, 180S, 210S, 240S, 270S, 300S }, if the time deviation is greater than the sorting threshold, the time deviation is filtered from more than 80% of the sorting positions, if the time deviation is greater than the sorting threshold, the time deviation is filtered from 1 to 10 of the sorting positions, and if the time deviation is greater than the sorting threshold, the time deviation is filtered from 240S of 80% of the sorting positions, the time deviation greater than the sorting position is filtered, i.e., 270S and 300S are filtered from the first time deviation set.
And step 210, adjusting the time of the slave server based on the filtered first time deviation set.
Specifically, after the slave server filters the first time deviation set, the time of the slave server is adjusted by using the target time deviation in the filtered first time deviation set. The time of the slave server may be adjusted using an average, maximum, median, or minimum of the target time offsets in the first set of time offsets, or the like.
In one embodiment, the time from the server is adjusted using the maximum value in the filtered first set of time offsets. For example, if the filtered first time offset set is {30S, 60S, 90S, 120S, 150S, 180S, 210S, 240S }, the maximum value 240S in the first time offset set is used to adjust the slave server, and 240S is added to the system time of the slave server, so that the adjusted slave server time can be synchronized with the master server.
In the server time synchronization method, a time synchronization instruction is received from the server; responding to the time synchronization instruction, acquiring a first time deviation set corresponding to the current time period, wherein the first time deviation set comprises a plurality of target time deviations, the target time deviations are the time deviations between the master server and the slave servers, and the target time deviations are obtained based on the difference of the sending time and the receiving time of the interactive messages between the master server and the slave servers; sequencing the target time deviations in the first time deviation set to obtain a first time sequence of each target time deviation; determining a target time deviation with link jitter in a first time deviation set based on a first time sequence of the target time deviation and a sequence threshold, and filtering the target time deviation with the link jitter to obtain a filtered first time deviation set; and adjusting the time of the slave server based on the filtered first time deviation set. The target time deviation with the link jitter is filtered, and the target time deviation in the time deviation set with the target time deviation with the link jitter is utilized to adjust the slave server to realize time synchronization, so that the precision of the server time synchronization can be effectively improved.
In one embodiment, as shown in fig. 3, the step of obtaining the target time offset comprises:
step 302, receiving a synchronization message sent by a master server, where the sending time of the synchronization message is a first time.
The synchronous message is a message transmitted in a synchronous transmission mode, and the synchronous transmission mode is a transmission mode for sending a data signal at a fixed clock beat.
Specifically, when the slave server needs to perform time synchronization, a target time offset between the master server and the slave server needs to be obtained first, and one of the parameters for calculating the target time offset, that is, the sending time of the synchronization message, needs to be obtained first in the process of obtaining the time offset.
In one embodiment, the master server sends the synchronization message to the slave server at a certain time interval, records the sending time of the synchronization message on the master server side, meanwhile, the master server packages the sending time of the synchronization message and sends the synchronization message to the slave server, and the slave server records the sending time of the synchronization message after receiving the sending time of the synchronization message. For example, the sending time of the synchronization message is represented as t1, the synchronization message is represented as Sync message, the master server embeds t1 in a follow _ up message to send to the slave server, and the slave server receives the sending time t1 of the master server Sync message. Wherein, the follow message is represented by the follow _ up message, and the sending time t1 of the synchronization message can be encapsulated into the follow message for transmission.
Step 304, a second time of receiving the synchronization message is recorded.
Specifically, after the master server sends the synchronization message to the slave server, the slave server correspondingly receives the synchronization message sent by the master server, and the slave server records the second time when the local terminal receives the synchronization message. For example, the second time may be represented as t 2.
Step 306, sending the delay request message to the main server, and recording a third time corresponding to the delay request message, where the third time is a time for sending the delay request message.
The delay request message is a request message of delay time and is a request message sent from the server to the main server.
Specifically, after receiving the synchronization message, the slave server sends a delay request message to the master server, and records the time for sending the delay request message at the local end of the slave server. For example, the third time recorded is denoted t 3.
And 308, receiving fourth time returned by the main server, wherein the fourth time is the time when the main server receives the delay request message.
Specifically, the master server receives the delay request message sent by the slave server, records the receiving time, and sends the receiving time to the slave server.
In one embodiment, the encapsulated fourth time message returned by the master server is received from the server. For example, the fourth time under recording is denoted t 4. The slave server may receive a message carrying the fourth time t4 through the message receiving module.
In step 310, a first time difference between the first time and the second time and a second time difference between the third time and the fourth time are obtained.
Specifically, assuming that the first time is represented by t1, the second time is represented by t2, the third time is represented by t3, the fourth time is represented by t4, the first time difference is represented by α, and the second time difference is represented by β, the first time difference is represented by α:
α=t2-t1;
the second time difference, denoted β, is expressed as:
β=t4-t3。
in step 312, a target time offset between the slave server and the master server is obtained based on the first time difference and the second time difference.
Specifically, the target time offset may be obtained by an average difference between the first time difference and the second time difference. Assuming that the target time offset is expressed as offset, the target time offset can be expressed as:
offset=(α+β)/2。
in this embodiment, the target time offset is obtained by four times generated in the process of performing message interaction between the master server and the slave server, and the purpose of accurately determining the target time offset can be achieved.
In one embodiment, as shown in fig. 4, deriving the target time offset between the slave server and the master server based on the first time difference and the second time difference comprises:
step 402, obtaining a first path delay from a master server to a slave server; the first path delay is the delay time from the master server to the slave server for sending the synchronization message.
Specifically, in the process of message interaction between the master server and the slave server, the transmission delay from the master server to the slave server and the transmission delay from the slave server to the master server may be affected by various factors, so that the transmission time may be different, and the delay time of the path needs to be considered.
In one embodiment, the first path delay is a difference between the first time difference and a target time offset. For example, if the first time difference is denoted as α, the first path delay is denoted as delay1, and the target time offset is denoted as offset, then the first path delay1 is α -offset.
Step 404, obtaining a second path delay from the server to the main server; the second path delay is the delay time from the server to the main server.
Specifically, in the process of message interaction between the slave server and the master server, the transmission delay from the slave server to the master server is affected by various factors, and the delay duration of the path needs to be considered.
In one embodiment, the second path delay may be derived from an accumulated value of the second time difference and the target time deviation. For example, if the second time difference is represented by β, the second path delay is represented by delay2, and the target time offset is represented by offset, then the second path delay2 is β + offset.
And 406, obtaining a target time deviation between the slave server and the master server according to the first path delay, the second path delay, the first time difference and the second time difference.
Specifically, if there is delay jitter in the communication link between the slave server and the master server and the communication link between the master server and the slave server, there is a difference between the first path delay and the second path delay, and if the difference between the first path delay and the second path delay is represented as δ, δ may be represented as:
δ=delay1-delay2;
wherein, delay1 ═ α -offset, delay2 ═ β + offset;
then offset is (α - β - δ)/2
In one embodiment, the target time offset may be directly obtained by the first time difference α and the second time difference β, assuming that there is no difference between the first path delay and the second path delay, i.e., δ is 0. The target time offset may be expressed as:
offset=(α-β)/2
in this embodiment, through the functional relationship between the first path delay and the second path delay and the functional relationship between the first time difference and the second time difference, the purpose of accurately obtaining the target time deviation under the condition that the communication link has delay jitter can be achieved.
In one embodiment, as shown in fig. 5, the server time synchronization method further includes:
step 502, when the number of the target time deviations in the first time deviation set is smaller than the number threshold, selecting the target time deviation closest to the current time period from the first time deviation set as a first adjustment time deviation.
The number threshold refers to a number critical value, and the method that the number of the target time deviations in the first time deviation set is smaller than the value and is greater than or equal to the selected target time deviation corresponding to the value is different.
Specifically, when the number of the target time deviations in the first time deviation set is smaller than the number threshold, the target time deviation closest to the current time period is selected from the first time deviation set as the first adjustment time deviation.
In one embodiment, a first time deviation set in a preset time period may also be obtained, and a target time deviation closest to the current time period is selected from the set as the first adjustment time deviation. For example, a first time deviation set consisting of target time deviations within 1 hour from the current time period is acquired, and the target time deviation closest to the current time period is selected from the set as a first adjustment time deviation.
In step 504, the time of the slave server is adjusted based on the first adjusted time offset.
Specifically, after the slave server determines a first adjustment time offset, the time of the slave server is adjusted using the first adjustment time offset. For example, if the first adjusted time offset is +60S and the current time from the server is 11:00, then the adjusted time from the server is the integrated value between the current time from the server and the offset, i.e., if 11:00+60S is 11:01, it is understood that the first adjusted time offset may be a negative value, and the adjusted time from the server may be obtained by the integrated value of the time on the server and the first adjusted time offset.
Step 506, when the number of the target time deviations in the first time deviation set is larger than the number threshold, sorting the target time deviations in the first time deviation set to obtain a first time sorting of each target time deviation.
Specifically, when the number of the target time deviations in the first time deviation set is greater than the number threshold, sorting the target time deviations in the first time deviation set to obtain a first time sorting of each target time deviation; determining a target time deviation with link jitter in a first time deviation set based on a first time sequence of the target time deviation and a sequence threshold, and filtering the target time deviation with the link jitter to obtain a filtered first time deviation set; and adjusting the time of the slave server based on the target time deviation in the filtered first time deviation set.
In this embodiment, by setting the number threshold, the purpose of implementing different slave server time adjustment methods can be achieved under two conditions that the number of the target time offsets in the first time offset set is greater than the number threshold and smaller than the number threshold.
In one embodiment, the first time ordering is a time ordering in which the target time offsets are arranged from small to large; determining a target time deviation with link jitter in a first time deviation set based on a first time sequence and a sequence threshold of the target time deviation, wherein the adjusting of the slave server time based on the filtered first time deviation set comprises:
and acquiring a target time deviation corresponding to the first time sequence larger than the sequence threshold value in the first time deviation set as the jitter time deviation.
The jitter time deviation refers to a time deviation with delay jitter. If the server is time-synchronized using the offset, the accuracy of the time synchronization of the server may be degraded.
Specifically, the target time deviations in the first time deviation set are arranged in a time sequence from small to large, and the target time deviations larger than the sorting threshold are screened out as jitter time deviations. For example, the first time offset set is {30S, 60S, 90S, 120S, 150S, 180S, 210S, 240S, 270S, 300S }, and if the sorting threshold is 80%, more than 80% of the sorts are sorted out as jitter time offsets, the target time offsets sorted out by the set are {270S, 300S }.
And taking the jitter time deviation as a target time deviation of the link jitter in the first time deviation set.
Specifically, after the jitter time offset is filtered out from the server, the jitter time offset is set as a target time offset in which the link jitter exists. For example, if the target time offset is 270S, 300S, then 270S and 300S are taken as the target time offset for the existence of link jitter.
Selecting the largest target time deviation from the filtered first time deviation set as a second adjustment time deviation;
specifically, after filtering the target time deviation with link jitter in the first time deviation set, the largest target time deviation is selected from the filtered first time deviation set as the second adjustment time deviation. For example, if the filtered first time offset set is {30S, 60S, 90S, 120S, 150S, 180S, 210S, 240S }, the largest target time offset 240S is selected as the second adjusted time offset. The time of the slave server is adjusted based on the second adjustment time offset.
Specifically, after the second adjustment time offset is obtained from the server, the time of the slave server is adjusted using the adjustment time offset. For example, the second adjustment time offset is +240S, and when the time of the slave server is 11:00, the adjusted time of the slave server is 11:00, and +240S is 11: 04.
In this embodiment, the time of the target time deviations arranged from small to large is sorted, the sorting threshold is set to filter the first time deviation set, and the largest target time deviation is selected from the filtered first time deviation set and used as the second adjustment time deviation to adjust the time of the slave server, so that the purpose of accurately adjusting the time of the slave server can be achieved.
In one embodiment, as shown in fig. 6, the step of obtaining the target sorting threshold comprises:
step 602, obtaining second adjustment time offsets corresponding to a plurality of forward time segments, respectively, as reference time offsets.
The forward time period refers to a time period between current time periods.
Specifically, in order to improve the time adjustment accuracy, second adjustment time offsets corresponding to a plurality of forward time periods before the current time period may be acquired as the reference time offset. For example, the first time deviation sets corresponding to the three preceding time slots are {30S, 60S, 90S, 120S, 150S, 180S, 210S, 240S, 270S, 300S }, {20S, 50S, 80S, 110S, 140S, 170S, 200S, 230S, 260S, 290S } and {10S, 40S, 70S, 100S, 130S, 160S, 190S, 220S, 250S, 280S }, respectively, and the corresponding second adjusted time deviations are 240S, 220S, and 230S, respectively, and 240S, 230S, and 220S can be used as reference time deviations.
And step 604, sequencing the reference time deviations according to the time sequence to obtain a reference time deviation sequence.
Specifically, after the reference time offset is obtained, the obtained reference time offsets are sorted in the time sequence of the preceding time period in which the reference time offset is obtained. For example, the obtained reference time offsets are 240S, 230S, and 220S, respectively, and the reference time offset sequence sorted by the time at which the reference time offset is obtained is {240S, 230S, 220S }.
And step 606, acquiring the variation trend of the reference time deviation sequence.
The variation trend refers to an overall trend presented by the magnitude arrangement sequence of the reference time deviations in the reference time deviation sequence. For example, if the acquired reference time deviation series is {240S, 230S, 220S }, the trend of the change becomes gradually smaller.
Specifically, after the reference time deviation sequence is acquired from the server, the obtained reference time deviation sequence is input into the data analysis model, and the variation trend of the reference time deviation sequence is intuitively acquired through a curve graph in the model analysis.
Step 608, obtaining a preset sorting threshold, and adjusting the preset sorting threshold according to a direction opposite to the variation trend to obtain a target sorting threshold.
The target sorting threshold is a sorting threshold obtained by analyzing the variation trend of the reference time deviation sequence. The sorting threshold may be the same as the preset sorting threshold, or may be larger than the preset sorting threshold or smaller than the preset sorting threshold.
Specifically, the slave server may adjust the preset sorting threshold according to a variation trend of the reference time deviation sequence, so as to improve the accuracy of the server time synchronization.
In one embodiment, after the preset sorting threshold and the variation trend of the reference time deviation sequence are acquired from the storage area in which the preset sorting threshold is stored by the server, the preset sorting threshold is adjusted in the opposite direction through the variation trend. For example, assuming that the preset sorting threshold is 80%, the variation trend of the reference time deviation sequence is gradually decreased, which proves that the reference time deviation is smaller and smaller, the preset sorting threshold is adjusted to be higher, for example, the preset sorting threshold may be adjusted from 80% to 90%, and the adjusted preset sorting threshold 90% is used as the target sorting threshold.
In one embodiment, after the preset sorting threshold and the variation trend of the reference time deviation sequence are acquired from the storage area in which the preset sorting threshold is stored by the server, the preset sorting threshold is adjusted in the opposite direction through the variation trend. For example, if the preset sorting threshold is 80%, the variation trend of the reference time deviation sequence is gradually increased, and it is proved that the reference time deviation is larger and larger, the preset sorting threshold is turned down, for example, the preset sorting threshold may be adjusted from 80% to 70%, and the adjusted preset sorting threshold 70% is used as the target sorting threshold.
In this embodiment, the preset sorting threshold is adjusted through analysis of the variation trend of the reference time deviation sequence, so that the purpose of adaptively adjusting the preset sorting threshold according to the variation trend of the reference time deviation sequence can be achieved.
In one embodiment, as shown in fig. 7, after adjusting the time from the server based on the filtered first time deviation set, the method further includes:
step 702, obtaining a trade order; the transaction order carries a first timestamp.
Wherein the time stamp refers to time information.
Specifically, a transaction order carrying a first timestamp is obtained from the server, and the first timestamp is time information added to the transaction order by the server according to time on the home terminal operating system.
In one embodiment, a trade order required by a user, for example, a trade order in a security system, is obtained from a server through an order placing system in a local terminal.
Step 704, sending a trade order to the main server; the trade order carries a time-stamped acquisition request.
The timestamp obtaining request refers to a request capable of obtaining a timestamp.
Specifically, a transaction order carrying a first time stamp is obtained from a slave server, and the transaction order is sent to a master server, wherein the transaction order carries a time stamp obtaining request.
In one embodiment, the trade order is encrypted by the slave server and transmitted to the master server. For example, the transaction order is encrypted using the MD5 encryption algorithm and sent to the host server. The security and integrity of the trade order may be verified by encrypting the trade order.
And step 706, receiving a second timestamp returned by the main server in response to the timestamp obtaining request.
Specifically, when the master server receives the trade order sent by the slave server, the time stamp obtaining request carried on the trade order is obtained. And according to the time stamp obtaining request, the main server prints the local time stamp, namely a second time stamp, on the received transaction order, and then returns the second time stamp to the slave server.
Step 708, when the difference between the first timestamp and the second timestamp is greater than the time difference threshold, sending an abnormal prompt message corresponding to the slave server to the maintenance terminal.
The time difference threshold refers to a critical value of the time difference between two timestamps. The response of the slave server is different between being greater than the critical value and being less than or equal to the critical value.
Specifically, when the difference between the first timestamp and the second timestamp is greater than the time difference threshold, it is indicated that an abnormality such as performance or occupation occurs in the transmission link between the master server and the slave server, and the abnormality needs to be sent to the maintenance terminal in an abnormality prompt message manner, so that the transmission link between the master server and the slave server can be maintained in time. For example, assuming that the difference threshold is 10ms, when the difference between the first timestamp and the second timestamp is 15ms, since the difference is already greater than 10ms, which is the difference threshold, at this time, the transmission link between the master server and the slave server is required to be maintained, and the slave server may send the abnormality prompting message to the maintenance terminal.
In this embodiment, the slave server sends the trade order to the master server, and by comparing the difference between the timestamp of the trade order on the slave server side and the timestamp on the master server with the time difference threshold, the situation of the transmission link abnormality can be accurately determined, and the influence on the time synchronization accuracy caused by the transmission link abnormality is reduced.
In one embodiment, as shown in fig. 8, the master server transmits a Sync message (Sync message) to the slave servers and records the Sync message transmission time t1 at the master server side, and when the Sync message is received from the slave servers, records the time t2 at which the Sync message is received at the slave servers; at the same time, the master server will embed the recorded time t1 in a Follow-up message and send it to the slave server. The slave server also sends a Delay _ Req message (Delay request message) to the master server, records the time t3 for sending the Delay _ Req message, records the time t4 for receiving the Delay _ Req message after the master server receives the Delay _ Req message, and embeds the time t4 into a Delay _ Resp message (Delay request response message) to send the Delay _ Req message to the slave server. After the message interaction between the master server and the slave server is completed, four timestamps, t1, t2, t3 and t4, are stored at the slave server. Assuming that the time offset between the slave server and the master server is denoted as offset, the path delay from the master server to the slave server is delay1, the path delay from the slave server to the master server is delay2, and the path delay jitter is denoted as δ, the above functions have the following functional relationships:
t2-t1=offset+delay1;
t4-t3=delay 2-offset;
delay1-delay 2=δ;
offset is [ t2-t1- (t4-t3) - δ ]/2; assuming that the path delay1 from the master server to the slave server is equal to the path delay2 from the slave server to the master server, the value of δ is 0, and the time offset between the slave server and the master server is represented as offset ═ t2-t1- (t4-t 3)/2.
In one embodiment, the slave server and the master server perform multiple message interactions, and during each interaction, an offset is calculated in the slave server, which can be used to time synchronize the slave server and save the offset obtained each time in the database. To save memory space, multiple offsets obtained in the last 1 to 3 hours or so may be saved.
In one embodiment, the resulting offsets may be subjected to data analysis to determine the offsets for server time synchronization. For example, each of the obtained set of offsets may be sorted in descending order, and offsets larger than a sorting threshold may be filtered out. For example, 10 offsets in the set of offsets, with a sorting threshold of 80%, are filtered out to the offset values ranked ninth and tenth in the sorting. Assuming that the set of ordered offset components is {10S, 20S, 30S, 40S, 50S, 60S, 70S, 80S, 90S, 100S }, when the ordering threshold is 80%, the set of finally obtained offset components is {10S, 20S, 30S, 40S, 50S, 60S, 70S, 80S }, and the maximum value in the set is selected as the offset between the slave server and the master server, and the slave server is time-synchronized by using the maximum value. For example, 80S is selected from the set of offsets {10S, 20S, 30S, 40S, 50S, 60S, 70S, 80S } to synchronize with the slave server. If the offset acquired in real time is larger than the maximum value in the filtered offset set, the slave server is still synchronized by using the maximum value in the offset set, and the offset acquired in real time is recorded in the database, so that a new round of offset sorting is continuously performed.
It should be understood that although the various steps in the flow charts of fig. 2-7 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2-7 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed in turn or alternately with other steps or at least some of the other steps.
In one embodiment, as shown in fig. 9, there is provided a server time synchronizer 900, including: a time synchronization command receiving module 902, a time synchronization command responding module 904, a first time sequencing obtaining module 906, a first time deviation set obtaining module 908, and a time adjusting module 910 of the server, wherein: a time synchronization instruction receiving module 902, configured to receive a time synchronization instruction; a time synchronization instruction response module 904, configured to respond to a time synchronization instruction, to obtain a first time deviation set corresponding to a current time period, where the first time deviation set includes a plurality of target time deviations, where the target time deviation is a time deviation between a master server and a slave server, and the target time deviation is obtained based on a difference between sending time and receiving time of an interactive message between the master server and the slave server; a first time ordering obtaining module 906, configured to order the target time deviations in the first time deviation set to obtain a first time ordering of each target time deviation; a first time deviation set obtaining module 908, configured to determine, based on a first time ranking of the target time deviations and a ranking threshold, a target time deviation with link jitter in the first time deviation set, and filter the target time deviation with link jitter to obtain a filtered first time deviation set; a time adjustment module 910 of the server, configured to adjust the time of the slave server based on the filtered first time deviation set.
In one embodiment, the server time synchronizer further comprises: the synchronous message receiving module is used for receiving a synchronous message sent by the main server, and the sending time of the synchronous message is a first time; the second time recording module is used for recording the second time for receiving the synchronous message; the third time recording module is used for sending the delay request message to the main server and recording third time corresponding to the delay request message, wherein the third time is the time for sending the delay request message; a first time difference and second time difference obtaining module, configured to obtain a first time difference between the first time and the second time and a second time difference between the third time and the fourth time; and the target time deviation obtaining module is used for obtaining the target time deviation between the slave server and the master server based on the first time difference and the second time difference.
In one embodiment, the target time deviation obtaining module is configured to obtain a first path delay from the master server to the slave server; the first path delay is the delay time from the master server to the slave server for sending the synchronous message; acquiring a second path delay from the server to the main server; the second path delay is the delay time length from the slave server to the master server; and obtaining the target time deviation between the slave server and the master server according to the first path delay, the second path delay, the first time difference and the second time difference.
In one embodiment, the server time synchronizer further comprises: a first adjustment time deviation determining module, configured to select, when the number of target time deviations in the first time deviation set is smaller than a number threshold, a target time deviation closest to a current time period from the first time deviation set as a first adjustment time deviation; the time adjusting module of the slave server is used for adjusting the time of the slave server based on the first adjusting time deviation; and a first time sorting obtaining module, configured to, when the number of the target time deviations in the first time deviation set is greater than the number threshold, perform sorting on the target time deviations in the first time deviation set to obtain a first time sorting of each target time deviation.
In one embodiment, the first time deviation set obtaining module 908 is configured to obtain a target time deviation, as the jitter time deviation, of the first time deviation set, where the first time ranking is greater than the ranking threshold; taking the jitter time deviation as a target time deviation of link jitter in the first time deviation set; adjusting the time of the slave server based on the filtered set of first time offsets comprises: selecting the largest target time deviation from the filtered first time deviation set as a second adjustment time deviation; the time of the slave server is adjusted based on the second adjustment time offset.
In one embodiment, the server time synchronizer includes: a second adjustment time deviation obtaining module, configured to obtain second adjustment time deviations corresponding to the multiple forward time periods, respectively, as reference time deviations; a reference time deviation sequence obtaining module, configured to sort the reference time deviations according to a time sequence to obtain a reference time deviation sequence; the variation trend acquisition module of the reference time deviation sequence is used for acquiring the variation trend of the reference time deviation sequence; and the target sorting threshold obtaining module is used for obtaining a preset sorting threshold, and adjusting the preset sorting threshold according to the direction opposite to the change trend to obtain the target sorting threshold.
In one embodiment, the server time synchronizer further comprises: the trade order acquisition module is used for acquiring a trade order; the transaction order carries a first timestamp; the trading order sending module is used for sending a trading order to the main server; the transaction order carries a time stamp acquisition request; the second timestamp receiving module is used for receiving a second timestamp returned by the main server in response to the timestamp obtaining request; and the abnormal prompt message sending module is used for sending the abnormal prompt message corresponding to the slave server to the maintenance terminal when the difference value between the first time stamp and the second time stamp is greater than the time difference value threshold.
For specific limitations of the server time synchronization apparatus, reference may be made to the above limitations of the server time synchronization method, which are not described herein again. The modules in the server time synchronizer can be wholly or partially realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 10. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used to store server time synchronization data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a server time synchronization method.
Those skilled in the art will appreciate that the architecture shown in fig. 10 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is further provided, which includes a memory and a processor, the memory stores a computer program, and the processor implements the steps of the above method embodiments when executing the computer program.
In an embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned method embodiments.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A server time synchronization method, performed by a slave server, the method comprising:
receiving a time synchronization instruction;
responding to the time synchronization instruction, acquiring a first time deviation set corresponding to the current time period, wherein the first time deviation set comprises a plurality of target time deviations, the target time deviations are time deviations between the master server and the slave servers, and the target time deviations are obtained based on the difference of sending time and receiving time of the interactive messages between the master server and the slave servers;
sequencing the target time deviations in the first time deviation set to obtain a first time sequence of each target time deviation;
determining a target time deviation with link jitter in the first time deviation set based on the first time sequence of the target time deviation and a sequence threshold, and filtering the target time deviation with link jitter to obtain a filtered first time deviation set;
and adjusting the time of the slave server based on the filtered first time deviation set.
2. The method of claim 1, wherein the step of obtaining the target time offset comprises:
receiving a synchronous message sent by a main server, wherein the sending time of the synchronous message is a first time;
recording a second time of receiving the synchronization message;
sending a delay request message to the main server, and recording a third time corresponding to the delay request message, wherein the third time is the time for sending the delay request message;
receiving a fourth time returned by the main server, wherein the fourth time is the time when the main server receives the delay request message;
obtaining a first time difference between the first time and the second time and a second time difference between the third time and the fourth time;
obtaining a target time offset between the slave server and the master server based on the first time difference and the second time difference.
3. The method of claim 2, wherein obtaining the target time offset between the slave server and the master server based on the first time difference and the second time difference comprises:
acquiring a first path delay from the master server to the slave server; the first path delay is the delay time from the main server to the slave server for sending the synchronous message;
acquiring a second path delay from the slave server to the master server; the second path delay is the delay time from the slave server to the master server when the slave server sends the delay request message;
and obtaining the target time deviation between the slave server and the master server according to the first path delay, the second path delay, the first time difference and the second time difference.
4. The method of claim 1, further comprising:
when the number of the target time deviations in the first time deviation set is smaller than a number threshold, selecting the target time deviation closest to the current time period from the first time deviation set as a first adjustment time deviation;
adjusting the time of the slave server based on the first adjusted time offset;
and when the number of the target time deviations in the first time deviation set is larger than a number threshold, sequencing the target time deviations in the first time deviation set to obtain a first time sequence of each target time deviation.
5. The method of claim 1, wherein the first time ordering is a time ordering in which the target time offsets are arranged from small to large; the determining a target time offset for which link jitter is present in the first set of time offsets based on the first temporal ordering of the target time offsets and an ordering threshold comprises:
acquiring a target time deviation corresponding to a first time sequence larger than a sequence threshold in the first time deviation set as a jitter time deviation;
taking the jitter time offset as a target time offset of link jitter in the first time offset set;
the adjusting the time of the slave server based on the filtered set of first time deviations comprises:
selecting the largest target time deviation from the filtered first time deviation set as a second adjustment time deviation;
adjusting the time of the slave server based on the second adjusted time offset.
6. The method of claim 5, wherein the step of deriving the target ranking threshold comprises:
acquiring second adjustment time deviations corresponding to the plurality of forward time periods respectively, and taking the second adjustment time deviations as reference time deviations;
sequencing the reference time deviation according to the time sequence to obtain a reference time deviation sequence;
acquiring the variation trend of the reference time deviation sequence;
and acquiring a preset sorting threshold, and adjusting the preset sorting threshold according to the direction opposite to the variation trend to obtain the target sorting threshold.
7. The method of claim 1, wherein adjusting the time of the slave server based on the filtered set of first time offsets further comprises:
acquiring a transaction order; the transaction order carries a first timestamp;
sending the trade order to a main server; the transaction order carries a time stamp acquisition request;
receiving a second timestamp returned by the main server in response to the timestamp obtaining request;
and when the difference value between the first time stamp and the second time stamp is larger than a time difference value threshold value, sending an abnormal prompt message corresponding to the slave server to a maintenance terminal.
8. A server time synchronization apparatus, the apparatus comprising:
the time synchronization instruction receiving module is used for receiving a time synchronization instruction;
a time synchronization instruction response module, configured to respond to the time synchronization instruction, to obtain a first time deviation set corresponding to a current time period, where the first time deviation set includes a plurality of target time deviations, where the target time deviations are time deviations between a master server and a slave server, and the target time deviations are obtained based on differences between sending times and receiving times of interactive messages between the master server and the slave server;
a first time ordering obtaining module, configured to order the target time deviations in the first time deviation set to obtain a first time ordering of each target time deviation;
a first time deviation set obtaining module, configured to determine, based on a first time ranking of the target time deviations and a ranking threshold, a target time deviation with link jitter in the first time deviation set, and filter the target time deviation with link jitter to obtain a filtered first time deviation set;
and the time adjusting module of the server is used for adjusting the time of the slave server based on the filtered first time deviation set.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN202110182906.XA 2021-02-10 2021-02-10 Server time synchronization method and device, computer equipment and storage medium Pending CN113014347A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110182906.XA CN113014347A (en) 2021-02-10 2021-02-10 Server time synchronization method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110182906.XA CN113014347A (en) 2021-02-10 2021-02-10 Server time synchronization method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113014347A true CN113014347A (en) 2021-06-22

Family

ID=76402150

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110182906.XA Pending CN113014347A (en) 2021-02-10 2021-02-10 Server time synchronization method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113014347A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115442244A (en) * 2022-09-02 2022-12-06 南方电网科学研究院有限责任公司 Method and device for calibrating communication interval in electric power real-time simulation and related equipment

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115442244A (en) * 2022-09-02 2022-12-06 南方电网科学研究院有限责任公司 Method and device for calibrating communication interval in electric power real-time simulation and related equipment
CN115442244B (en) * 2022-09-02 2024-01-19 南方电网科学研究院有限责任公司 Method and device for calibrating communication interval in power real-time simulation and related equipment

Similar Documents

Publication Publication Date Title
CN107733708B (en) Equipment parameter configuration method and device, computer equipment and storage medium
US7453910B1 (en) Synchronization of independent clocks
CN104809201B (en) A kind of method and apparatus of database synchronization
US7925742B2 (en) Correlating performance data of multiple computing devices
CN109558065B (en) Data deleting method and distributed storage system
CN111222089B (en) Data processing method, data processing device, computer equipment and storage medium
CN106899654B (en) Sequence value generation method, device and system
CN108965383B (en) File synchronization method and device, computer equipment and storage medium
US9753941B2 (en) Storage system and method for processing data operation request
CN111490843B (en) Time checking method and device, computer equipment and storage medium
US20110172963A1 (en) Methods and Apparatus for Predicting the Performance of a Multi-Tier Computer Software System
CN108762984B (en) Method and device for continuous data backup
CN112187393B (en) PON bus time synchronization method and device, computer equipment and storage medium
US9727394B2 (en) Establishing causality order of computer trace records
CN113014347A (en) Server time synchronization method and device, computer equipment and storage medium
CN110795026B (en) Hot spot data identification method, device, equipment and storage medium
CN111147226B (en) Data storage method, device and storage medium
CN117061049A (en) Data reporting method, device, equipment and storage medium
CN110825758B (en) Transaction processing method and device
CN111381937A (en) Experimental scene snapshot generating system and method based on time base line
CN116132630A (en) Video processing method, device, equipment and storage medium
CN113014346A (en) Server time deviation monitoring method and device, computer equipment and storage medium
CN115017233A (en) Data synchronization method, device, electronic equipment and medium
CN113946448A (en) Time sequence management method and device of server cluster and electronic equipment
CN113111074A (en) Block chain-based interactive data monitoring method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: Room 2301, building 5, Shenzhen new generation industrial park, 136 Zhongkang Road, Meidu community, Meilin street, Futian District, Shenzhen City, Guangdong Province

Applicant after: Shenzhen Huarui Distributed Technology Co.,Ltd.

Address before: Room 2301, building 5, Shenzhen new generation industrial park, 136 Zhongkang Road, Meidu community, Meilin street, Futian District, Shenzhen City, Guangdong Province

Applicant before: SHENZHEN ARCHFORCE FINANCIAL TECHNOLOGY Co.,Ltd.

CB02 Change of applicant information