A method and device for detecting synchronization delay
Detecting synchronization delays between Kafka nodes by regularly calling Kafka scripts and sliding window algorithms solves the problem of being unable to detect delays in time during Mirror Maker synchronization and improves business availability.
Patent Information
- Application Number
- CN202311284275.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-28
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2043-09-28
AI Technical Summary
In the existing technology, the synchronization delay problem cannot be detected in time during the Mirror Maker synchronization process, causing business availability to be affected.
Query the sharding and consumer group increments of node A and node B by regularly calling the script provided by Kafka, using the sliding window algorithm to calculate the difference between the increment and the consumer group increment, detect the synchronization delay, and publish it after reaching the preset number of times Warning and anomaly detection records ensure that synchronization delays are detected in time.
It effectively improves the accuracy of synchronization delay detection, helps the business operation and maintenance team locate problems in a timely manner, and ensures the availability of platform services.
Smart Images

Figure CN117354202B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of synchronization delay detection, and in particular to a synchronization delay detection method and device. Background Art
[0002] Kafka is a message queue software that is currently used frequently in the industry. It can be used for both stream data processing and publish / subscribe messaging systems.
[0003] Kafka supports stand-alone or cluster deployment. The broker is responsible for storing and synchronizing Kafka data. The Kafka broker can further shard the topic (queue). The Producer is responsible for pushing data to the broker, and the Consumer is responsible for consuming data from the broker.
[0004] Kafka supports consumers consuming the same topic in different consumer groups. When the business platform needs to implement active-active replication, Kafka data needs to be synchronized from the current node to the disaster recovery target node. Currently, the main tools that support cross-node synchronization of Kafka data are Mirror Maker tools or third-party tools packaged based on Mirror Maker tools.
[0005] Kafka data includes queue data (including the queue's own offset) and consumer group offset data. The synchronization of these two parts of data is crucial for a high-availability system. The so-called data synchronization means that when a node server generates a piece of data, the data needs to be synchronized to other nodes in real time so that other nodes can complete necessary work or provide related services.
[0006] If Kafka data needs to be synchronized from node A to node B, Mirror Maker is located between the source node and the target node. In order to achieve cross-node data synchronization of Kafka, it simulates the consumer of Kafka node A and the producer of node B, and regularly synchronizes the message data corresponding to node A, the latest offset of the topic, and the consumption offset of the consumer group to node B.
[0007] Mirror Maker synchronizes data by simulating Kafka source node consumers and Kafka target node producers. The current highest version of Mirror Maker is Mirror Maker 2. When synchronizing data from node A to node B based on Mirror Maker 1 or 2, inconsistency in offset data will occur.
[0008] When the data corresponding to Kafka is synchronized from node A to node B, assume that the offset of a topic shard i of A is A_maxOffsetLast=10000, and the consumer group offset corresponding to consumer Z is A_consumeOffset=8000.
[0009] After being fully synchronized to node B, the offset of shard i corresponding to the topic and the offset of the consumer group corresponding to consumer Z obtained by querying node B may be B_maxOffsetLast = 5000, B_consumeOffset = 3000. Although the number of unconsumed items is the same, the offset data corresponding to A and B are usually not equal.
[0010] In summary, it is impossible to detect whether synchronization is delayed by simply comparing the offset data on both sides, so as to timely determine synchronization anomalies and take timely measures to solve business availability issues. As a middleware, when Mirror Maker itself is in suspended animation, it is impossible to detect anomalies in time through conventional process monitoring. In addition to suspended animation, there are other potential reasons for synchronization delay. It is also impossible to determine whether synchronization is delayed simply by looking at the number of unconsumed transactions. Summary of the invention
[0011] Therefore, the technical problem to be solved by the present invention is to overcome the problem in the prior art that the synchronization delay cannot be detected in time during the Mirror Maker synchronization process.
[0012] In order to solve the above technical problems, the present invention provides a synchronization delay detection method, comprising:
[0013] Step 1: Regularly call the script provided by Kafka to query the increment of the i-th shard and the increment of the consumer group of nodes A and B;
[0014] Step 2: After the query times reaches the preset number, the incremental synchronization delay detection result is obtained according to the first difference of the increment of the i-th shard of the A node queried times-2 and times-3, and the second difference of the increment of the i-th shard of the B node queried times and times-3;
[0015] Step 3: After the query times reaches the preset number, the consumer group increment synchronization delay detection result is obtained according to the third difference of the increment of the i-th shard consumer group of node A queried times-2 and times-3, and the fourth difference of the increment of the i-th shard consumer group of node B queried times and times-3;
[0016] Step 4: Repeat steps 1-3 until the query times reaches the maximum threshold.
[0017] Preferably, the execution interval of the scheduled call is equal to the Kafka synchronization interval.
[0018] Preferably, after the query number times reaches a preset number, the incremental synchronization delay detection result is obtained according to the first difference between the increment of the i-th shard of the A node queried times-2 and times-3 times, and the second difference between the increment of the i-th shard of the B node queried times and times-3 times, including:
[0019] When the query number times is not less than the preset number, if the first difference between the i-th shard increment of node A queried times-2 times and the i-th shard increment of node A queried times-3 times is greater than the first preset threshold, and the second difference between the i-th shard increment of node B queried times times and the i-th shard increment of node B queried times-3 times is less than the first difference, then an incremental synchronization delay warning is issued.
[0020] Preferably, after the query number times reaches a preset number, the consumer group increment synchronization delay detection result is obtained according to the third difference between the increments of the i-th shard consumer group of node A queried times-2 and times-3, and the fourth difference between the increments of the i-th shard consumer group of node B queried times and times-3:
[0021] When the query number times is not less than the preset number, if the third difference between the increment of the i-th shard consumer group of node A queried times-2 times and the increment of the i-th shard consumer group of node A queried times-3 times is greater than the first preset threshold, and the fourth difference between the increment of the i-th shard consumer group of node B queried times and the increment of the i-th shard consumer group of node B queried times-3 times is less than the third difference, then a consumer group increment synchronization delay warning is issued.
[0022] Preferably, before obtaining the incremental synchronization delay detection result according to the first difference of the i-th shard increment of the A node queried times-2 and times-3 times, and the second difference of the i-th shard increment of the B node queried times and times-3 times, the method further includes:
[0023] When the increment of the i-th shard of node A within unit time is less than the third preset threshold, return to step 1.
[0024] Preferably, before obtaining the consumer group increment synchronization delay detection result according to the third difference of the increment of the i-th shard consumer group of node A queried times-2 and times-3 times, and the fourth difference of the increment of the i-th shard consumer group of node B queried times and times-3 times, the method further includes:
[0025] When the increment of the i-th shard consumption group of node A within unit time is less than the fourth preset threshold, return to step 1.
[0026] Preferably, before obtaining the incremental or consumer group incremental synchronization delay detection result, the method further includes:
[0027] If there is no abnormality detection record for the current mirrorMaker process, actively detect whether the mirrorMaker process is abnormal and set the validity period of the abnormality detection record. If it is abnormal, update the last mirrorMaker failure time to the current time and restart mirrorMaker.
[0028] Preferably, after obtaining the incremental or consumer group incremental synchronization delay detection result, the method further includes:
[0029] Use a third-party tool to detect whether there is an abnormality in the mirrorMaker process. If so, update the last mirrorMaker failure time to the current time.
[0030] Preferably, before the script provided by Kafka is periodically called to query the increment of the i-th shard and the increment of the consumer group of node A and node B, the method further includes:
[0031] Determine whether the current call time exceeds the sum of the last mirrorMaker failure time and the preset failure non-detection time. If not, wait for the next call time to continue execution.
[0032] The present invention also provides a synchronization delay detection device, comprising:
[0033] The synchronization progress monitoring module is used to periodically call the script provided by Kafka to query the increment of the i-th shard and the increment of the consumer group of node A and node B;
[0034] The incremental synchronization delay detection module is used to obtain the incremental synchronization delay detection result according to the first difference of the increment of the i-th shard of the A node queried times-2 and times-3, and the second difference of the increment of the i-th shard of the B node queried times and times-3 after the query number times reaches the preset number;
[0035] The consumer group synchronization delay detection module is used to obtain the consumer group increment synchronization delay detection result according to the third difference of the increment of the i-th shard consumer group of node A queried times-2 and times-3, and the fourth difference of the increment of the i-th shard consumer group of node B queried times and times-3 after the query number times reaches the preset number;
[0036] The loop module is used to repeat the contents of the synchronization progress monitoring module, the incremental synchronization delay detection module and the consumer group synchronization delay detection module until the number of queries reaches a maximum threshold.
[0037] The above technical solution of the present invention has the following advantages compared with the prior art:
[0038] The sliding window-based synchronization delay detection method described in the present invention fully considers the influence of IO delay and the like, and by setting the comparison between the three consecutive time window increments of the target node and the corresponding one time window increment of the source node, it ensures that the synchronization delay can be detected after a certain degree of delay, so as to facilitate the business operation and maintenance team to locate the problem in time and better ensure the availability of the platform business. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to make the content of the present invention more clearly understood, the present invention is further described in detail below according to specific embodiments of the present invention in conjunction with the accompanying drawings, wherein:
[0040] Figure 1 A flow chart of an implementation of a synchronization delay detection method provided by the present invention;
[0041] Figure 2 It is a schematic diagram of a sliding time activity window;
[0042] Figure 3 It is a flow chart of an implementation of a synchronization delay detection method provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0043] The core of the present invention is to provide a synchronization delay detection method and device, which effectively improves the detection accuracy.
[0044] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0045] The present invention realizes a method for supporting synchronization delay detection of Mirror Maker type tools, which can well and timely solve the problem that the synchronization delay cannot be detected in time during the Mirror Maker synchronization process.
[0046] Please refer to Figure 1 , Figure 1 This is a flow chart of the implementation of a synchronization delay detection method provided by the present invention; the specific operation steps are as follows:
[0047] S101: Periodically call the script provided by Kafka to query the increment of the i-th shard and the increment of the consumer group of node A and node B.
[0048] S102: After the query number times reaches the preset number, the incremental synchronization delay detection result is obtained according to the first difference of the increment of the i-th shard of the A node obtained by the times-2th and times-3th queries, and the second difference of the increment of the i-th shard of the B node obtained by the times-3th and times-3th queries;
[0049] S103: After the query number times reaches the preset number, the consumer group increment synchronization delay detection result is obtained according to the third difference between the increments of the i-th shard consumer group of the A node queried times-2 and times-3, and the fourth difference between the increments of the i-th shard consumer group of the B node queried times and times-3;
[0050] S104: Repeat steps S101-S103 until the query times reaches a maximum threshold.
[0051] Based on the above embodiments, this embodiment describes step S101 in detail:
[0052] We introduce a synchronization delay detection algorithm based on a sliding time window and develop a script tool SyncMonitor based on this algorithm, which is responsible for synchronization delay detection from source node A to target node B.
[0053] The sliding window is continuously updated in units of fixed windows. If the sliding window is full, the first fixed window that enters the sliding window is deleted, and the sliding window is updated accordingly.
[0054] The configuration field for the consumer group offset synchronization interval is sync.group.offsets.interval.seconds. We define the regular synchronization time as mq_sync_interval_seconds, hereinafter referred to as the Kafka synchronization interval MST. This parameter is usually configured to be equal to sync.group.offsets.interval.seconds. Mirror Maker is responsible for starting the synchronization of Kafka data. Since it involves cross-node IO operations on both Node A and Node B, this operation usually takes more than 1 second to complete.
[0055] The processing period of this algorithm remains consistent with MST. Hereinafter, it is collectively referred to as the algorithm execution interval PT, that is, the execution interval of the timed call is equal to the Kafka synchronization interval.
[0056] Considering that Kafka synchronization is not real-time, we design the span time of B to include the span time of A. Suppose the increased value of A's offset is A_Sub. If the increased value of B's offset within the span time is less than A_Sub, it indicates a synchronization delay problem. The sliding time activity window is as Figure 2 shown. Considering that the synchronization operation with an interval of MPT may be executed within 1 second before the algorithm processing time PT, and usually the synchronization operation may take more than 1 second to complete. Therefore, even for two PTs of B, the upper limit of offset synchronization still cannot ensure that it includes one algorithm PT of A. Therefore, it is necessary to calculate three PTs of B.
[0057] In the implementation, we use 4 Kafka synchronization times MST as the sliding time window. Suppose there is a change in the offset difference corresponding to one PT interval of A in Kafka (assuming the difference is A_Sub), and the corresponding difference of B is less than A_Sub, that is, B[times] - B[times - 3] < A_Sub, then a warning is generated.
[0058] For each topic and each partition, the consumer group Z contains 4 long-type arrays and a long-type parameter A_maxOffset / / representing the offset corresponding to Node A
[0059] A_consumeOffset / / representing the A consumer group offset
[0060] B_maxOffset / / representing the offset corresponding to Node B
[0061] B_consumeOffset / / representing the B consumer group offset
[0062] The implementation of times=0 algorithm needs to consider the processing when times exceeds the maximum value. It is also recommended to use a circular array method to retain only the latest 4 elements.
[0063] Based on the above embodiments, this embodiment describes step S102 in detail:
[0064] When the query times is not less than the preset number of times, if the first difference between the increment of the i-th shard of node A queried times-2 and the increment of the i-th shard of node A queried times-3 is greater than the first preset threshold, and the second difference between the increment of the i-th shard of node B queried times and the increment of the i-th shard of node B queried times-3 is less than the first difference, then an incremental synchronization delay warning is issued:
[0065] Determine whether the difference between A_maxOffset[times-2] and A_maxOffset[times-3] of node A, A_maxOffsetSub, is greater than Max_Delay_Max_Offset. If so, determine whether the difference between B_maxOffset[times] and B_maxOffset[times-3] is less than A_maxOffsetSub. If so, prompt the current topic maximum offset synchronization delay alarm;
[0066] Anyway, execute times++.
[0067] Based on the above embodiments, this embodiment describes step S103 in detail:
[0068] When the query times is not less than the preset number of times, if the third difference between the increment of the i-th shard consumer group of node A queried times-2 and the increment of the i-th shard consumer group of node A queried times-3 is greater than the first preset threshold, and the fourth difference between the increment of the i-th shard consumer group of node B queried times and the increment of the i-th shard consumer group of node B queried times-3 is less than the third difference, then a consumer group increment synchronization delay warning is issued:
[0069] Determine whether the difference between A_consumeOffset[times-2] and A_consumeOffset[times-3] of node A, A_consumeOffsetSub, is greater than Max_Delay_Max_Offset. If so, determine whether the difference between B_consumeOffset[times] and B_consumeOffset[times-3] is less than A_consumeOffsetSub. If so, prompt the current topic consumer group offset synchronization delay alarm;
[0070] Anyway, execute times++.
[0071] Based on the above embodiment, if the offset of node A itself changes little within a unit time (such as a change of 0), in order to save computing resources, you can choose not to perform judgment processing. We introduce Min_Delay_Latest_Offset and Min_Delay_Consume_Offset as the latest offset of the same shard of the topic and the consumer group consumption offset synchronization delay detection judgment thresholds:
[0072] Before obtaining the incremental synchronization delay detection result according to the first difference of the i-th shard increment of the A node queried times-2 and times-3 times and the second difference of the i-th shard increment of the B node queried times and times-3 times, the method further includes:
[0073] When the increment of the i-th shard of the A node within the unit time is less than the third preset threshold, the process returns to S101.
[0074] Before obtaining the consumer group increment synchronization delay detection result according to the third difference of the increment of the i-th shard consumer group of node A queried times-2 and times-3 times and the fourth difference of the increment of the i-th shard consumer group of node B queried times and times-3 times, the method further includes:
[0075] When the increment of the i-th shard consumption group of node A within unit time is less than the fourth preset threshold, return to S101.
[0076] The present invention introduces a synchronization delay detection algorithm based on sliding windows, which is suitable for timely detection of delays when synchronization is implemented between Kafka nodes through Mirror Maker-type tools. The algorithm fully considers the influence of IO delays, etc., and compares the three consecutive time window increments of the target node with the corresponding one time window increment of the source node to ensure that the synchronization delay can be detected after a certain degree of delay, which facilitates the business operation and maintenance team to locate the problem in time and better ensure the availability of the platform business.
[0077] Based on the above embodiment, before obtaining the incremental or consumer group incremental synchronization delay detection result, the method further includes calling WarnProcess(topic):
[0078] WarnProcess(topic) processing logic: Determine whether warn[topic] has a value and is true. If so, end the process. Otherwise, set warn[topic] to true and set TTL to warnProcInterval. Actively detect whether the MirrorMaker process has any abnormalities. If so, configure mirrorMakerDisableTime to the current time and restart mirrorMaker:
[0079] If there is an abnormal detection record in the current mirrorMaker process, end the process and enter the synchronization delay detection result acquisition process;
[0080] If there is no abnormality detection record for the current mirrorMaker process, actively detect whether the mirrorMaker process is abnormal and set the validity period of the abnormality detection record. If it is abnormal, update the last mirrorMaker failure time to the current time and restart mirrorMaker.
[0081] Based on the above embodiment, after obtaining the incremental or consumer group incremental synchronization delay detection result, the method further includes:
[0082] Use third-party tools such as Zabbix or Prometheus to detect whether there is an abnormality in the mirrorMaker process. If so, update the last mirrorMaker failure time to the current time.
[0083] In this system, active detection of mirrorMaker anomalies and receiving passive notification of mirrorMaker anomalies from zabbix are two mechanisms to ensure that when mirrorMaker anomalies occur, notifications are received in time to avoid invalid calculations.
[0084] Based on the above embodiment, the method of periodically calling the script provided by Kafka to query the increment of the i-th shard of node A and node B and the increment of the consumer group also includes:
[0085] When executing this task, first determine whether the current time exceeds mirrorMakerDisableTime (last fault occurrence time) + disableTTL (fault non-detection duration). If not, it means that the fault has not been recovered, and this task ends, waiting for the next time window to continue execution:
[0086] Determine whether the current call time exceeds the sum of the last mirrorMaker failure time and the preset failure non-detection time. If not, wait for the next call time to continue execution.
[0087] This process is mainly used to avoid ineffective task running. When problems occur in the middleware, the task calculation is meaningless.
[0088] Local memory warn[topic], the value is true, indicating that an exception currently exists, and the validity period ttl is warnProcInterval (configurable, such as 10 minutes)
[0089] Local memory mirrorMakerDisableTime = 0 (representing the last mirrorMaker failure time), disableTTL represents the length of time that the detection task should avoid when mirrorMaker and other middleware fail. The parameters are configurable.
[0090] The above initialization parameters are used to determine whether the current state is in a failure period.
[0091] like Figure 3 , Figure 3 It is a flow chart of an implementation of a synchronization delay detection method provided by an embodiment of the present invention.
[0092] The embodiment of the present invention further provides a synchronization delay detection device; the specific device may include:
[0093] The synchronization progress monitoring module is used to periodically call the script provided by Kafka to query the increment of the i-th shard and the increment of the consumer group of node A and node B;
[0094] The incremental synchronization delay detection module is used to obtain the incremental synchronization delay detection result according to the first difference of the increment of the i-th shard of the A node queried times-2 and times-3, and the second difference of the increment of the i-th shard of the B node queried times and times-3 after the query number times reaches the preset number;
[0095] The consumer group synchronization delay detection module is used to obtain the consumer group increment synchronization delay detection result according to the third difference of the increment of the i-th shard consumer group of node A queried times-2 and times-3, and the fourth difference of the increment of the i-th shard consumer group of node B queried times and times-3 after the query number times reaches the preset number;
[0096] The loop module is used to repeat the contents of the synchronization progress monitoring module, the incremental synchronization delay detection module and the consumer group synchronization delay detection module until the number of queries reaches a maximum threshold.
[0097] The synchronization delay detection device of this embodiment is used to implement the aforementioned synchronization delay detection method. Therefore, the specific implementation method of the synchronization delay detection device can be seen in the embodiment part of the aforementioned synchronization delay detection method. For example, the synchronization progress monitoring module, the incremental synchronization delay detection module, the consumer group synchronization delay detection module, and the loop module are respectively used to implement steps S101, S102, S103, and S104 in the aforementioned synchronization delay detection method. Therefore, its specific implementation method can refer to the description of the corresponding various partial embodiments and will not be repeated here.
[0098] A specific embodiment of the present invention further provides a synchronization delay detection device, comprising: a memory for storing a computer program; and a processor for implementing the steps of the above-mentioned synchronization delay detection method when executing the computer program.
[0099] A specific embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned synchronization delay detection method are implemented.
[0100] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0101] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0102] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0103] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0104] Obviously, the above embodiments are merely examples for the purpose of clear explanation and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived therefrom are still within the scope of protection of the present invention.
Claims
1. A synchronization delay detection method, characterized in that: include: Step 1: Regularly call the script provided by Kafka to query the increment of the i-th shard and the increment of the consumer group of nodes A and B; Step 2: After the query times reaches the preset number, the incremental synchronization delay detection result is obtained according to the first difference of the increment of the i-th shard of the A node queried times-2 and times-3, and the second difference of the increment of the i-th shard of the B node queried times and times-3; Step 3: After the query times reaches the preset number, the consumer group increment synchronization delay detection result is obtained according to the third difference of the increment of the i-th shard consumer group of node A queried times-2 and times-3, and the fourth difference of the increment of the i-th shard consumer group of node B queried times and times-3; Step 4: Repeat steps 1-3 until the query times reaches the maximum threshold; The execution interval of the scheduled call is equal to the Kafka synchronization interval; After the query number times reaches the preset number, the incremental synchronization delay detection result is obtained according to the first difference of the increment of the i-th shard of the A node queried times-2 and times-3, and the second difference of the increment of the i-th shard of the B node queried times and times-3, including: When the query number times is not less than the preset number, if the first difference between the increment of the i-th shard of node A queried times-2 times and the increment of the i-th shard of node A queried times-3 times is greater than the first preset threshold, and the second difference between the increment of the i-th shard of node B queried times times and the increment of the i-th shard of node B queried times-3 times is less than the first difference, then issue an incremental synchronization delay warning; After the query number times reaches the preset number, the consumer group increment synchronization delay detection result is obtained according to the third difference of the increment of the i-th shard consumer group of node A queried times-2 and times-3, and the fourth difference of the increment of the i-th shard consumer group of node B queried times and times-3: When the query number times is not less than the preset number, if the third difference between the increment of the i-th shard consumer group of node A queried times-2 times and the increment of the i-th shard consumer group of node A queried times-3 times is greater than the first preset threshold, and the fourth difference between the increment of the i-th shard consumer group of node B queried times and the increment of the i-th shard consumer group of node B queried times-3 times is less than the third difference, then a consumer group increment synchronization delay warning is issued.
2. The synchronization delay detection method according to claim 1, characterized in that: Before obtaining the incremental synchronization delay detection result according to the first difference of the i-th shard increment of the A node queried times-2 and times-3 times and the second difference of the i-th shard increment of the B node queried times and times-3 times, the method further includes: When the increment of the i-th shard of node A within unit time is less than the third preset threshold, return to step 1.
3. The synchronization delay detection method according to claim 1, characterized in that: Before obtaining the consumer group increment synchronization delay detection result according to the third difference of the increment of the i-th shard consumer group of node A queried times-2 and times-3 times and the fourth difference of the increment of the i-th shard consumer group of node B queried times and times-3 times, the method further includes: When the increment of the i-th shard consumption group of node A within unit time is less than the fourth preset threshold, return to step 1.
4. The synchronization delay detection method according to claim 1, characterized in that: Before obtaining the incremental or consumer group incremental synchronization delay detection result, the following steps are also included: If there is no abnormality detection record for the current mirrorMaker process, actively detect whether the mirrorMaker process is abnormal and set the validity period of the abnormality detection record. If it is abnormal, update the last mirrorMaker failure time to the current time and restart mirrorMaker.
5. The synchronization delay detection method according to claim 1, characterized in that: After obtaining the incremental or consumer group incremental synchronization delay detection result, the following further includes: Use a third-party tool to detect whether there is an abnormality in the mirrorMaker process. If so, update the last mirrorMaker failure time to the current time.
6. The synchronization delay detection method according to claim 1, characterized in that: The timing call of the script provided by Kafka to query the increment of the i-th shard and the increment of the consumer group of node A and node B also includes: Determine whether the current call time exceeds the sum of the last mirrorMaker failure time and the preset failure non-detection time. If not, wait for the next call time to continue execution.
7. A synchronization delay detection device, characterized in that: include: The synchronization progress monitoring module is used to periodically call the script provided by Kafka to query the increment of the i-th shard and the increment of the consumer group of node A and node B; The incremental synchronization delay detection module is used to obtain the incremental synchronization delay detection result according to the first difference of the increment of the i-th shard of the A node queried times-2 and times-3, and the second difference of the increment of the i-th shard of the B node queried times and times-3 after the query number times reaches the preset number; The consumer group synchronization delay detection module is used to obtain the consumer group increment synchronization delay detection result according to the third difference of the increment of the i-th shard consumer group of node A queried times-2 and times-3, and the fourth difference of the increment of the i-th shard consumer group of node B queried times and times-3 after the query number times reaches the preset number; A loop module, used to repeat the contents of the synchronization progress monitoring module, the incremental synchronization delay detection module and the consumer group synchronization delay detection module until the query times reaches a maximum threshold; The execution interval of the scheduled call is equal to the Kafka synchronization interval; After the query number times reaches the preset number, the incremental synchronization delay detection result is obtained according to the first difference of the increment of the i-th shard of the A node queried times-2 and times-3, and the second difference of the increment of the i-th shard of the B node queried times and times-3, including: When the query number times is not less than the preset number, if the first difference between the increment of the i-th shard of node A queried times-2 times and the increment of the i-th shard of node A queried times-3 times is greater than the first preset threshold, and the second difference between the increment of the i-th shard of node B queried times times and the increment of the i-th shard of node B queried times-3 times is less than the first difference, then issue an incremental synchronization delay warning; After the query number times reaches the preset number, the consumer group increment synchronization delay detection result is obtained according to the third difference of the increment of the i-th shard consumer group of node A queried times-2 and times-3, and the fourth difference of the increment of the i-th shard consumer group of node B queried times and times-3: When the query number times is not less than the preset number, if the third difference between the increment of the i-th shard consumer group of node A queried times-2 times and the increment of the i-th shard consumer group of node A queried times-3 times is greater than the first preset threshold, and the fourth difference between the increment of the i-th shard consumer group of node B queried times and the increment of the i-th shard consumer group of node B queried times-3 times is less than the third difference, then a consumer group increment synchronization delay warning is issued.
