A method and device for unitary deployment

By using the voting and election mechanisms to determine the switching of the backup processing unit to the main processing unit in the distributed architecture, the problems of low efficiency of the main and backup switching of the unit and data in the prior art are solved, and efficient and secure data processing is achieved.

CN115834356BActive Publication Date: 2025-07-18CHINA UNIONPAY
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211450911.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-19
Publication Date
2025-07-18
Estimated Expiration
2042-11-19

AI Technical Summary

Technical Problem

In the prior art, the unit main and backup switching efficiency in distributed architecture is low, manual switching depends on operation and maintenance personnel and is time-consuming, and preset sequence switching cannot ensure data consistency in the case of network interruption or partitioning.

Method used

When the heartbeat of the main processing unit is not received within the preset period and the voting request is not received, the backup processing unit sends a voting request, determines the switching to the main processing unit based on the number of votes, and uses the election time and voting mechanism to ensure the security and data consistency of the backup processing unit.

Benefits of technology

The efficiency of unit main and backup switching is improved, the security and accuracy of data processing is ensured, and data inconsistency is avoided.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115834356B_ABST
    Figure CN115834356B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for unitized deployment, including: when the first standby processing unit does not receive the heartbeat of the main processing unit within a preset period and does not receive a voting request within the election duration of the first standby processing unit, the first standby processing unit sends a voting request to the second standby processing unit; receiving the ballot sent by the second standby processing unit based on the voting request, and if it is determined that the number of ballots is greater than the preset ballot threshold, switching the first standby processing unit to the main processing unit; the first standby processing unit is any unit among the standby processing units; the second standby processing unit is any unit other than the first standby processing unit; the voting request is sent by the second standby processing unit after not receiving the heartbeat and after passing the election duration of the second standby processing unit; the main processing unit and the standby processing unit are units with consistent functions in a distributed architecture; thereby ensuring the efficiency of switching the processing unit, ensuring data consistency, and improving the security and accuracy of data processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular, to a method and device for unitized deployment. Background Art

[0002] With the development of computer technology, to meet requirements such as high performance and scalability, more and more systems adopt a distributed architecture and use unitized deployment in the distributed architecture. Among them, unitized deployment means that units are used as the basic units in the distributed architecture, multiple units with different functions are deployed in the distributed architecture, and any unit is deployed with the required application nodes; a unit refers to a self - contained set that can complete business operations, including the services and data required by the business.

[0003] Currently, in order to enable units with different functions in the distributed architecture to have the ability to handle catastrophic failures, for any unit with a certain function, the unit includes a primary processing unit and a standby processing unit. Among them, the standby processing unit is used to perform primary - standby switching when the primary processing unit fails, so that the standby processing unit processes data as the primary processing unit.

[0004] When there are multiple standby processing units, the primary - standby switching methods include manual switching and preset - order switching; however, the manual switching method has low efficiency and high requirements for operation and maintenance personnel. The preset - order switching method will result in data inconsistency when a network interruption, network partition, etc. occur in a certain unit, and cannot guarantee data consistency. Summary of the Invention

[0005] Embodiments of the present invention provide a method and device for unitized deployment, which are used to ensure the efficiency of unit primary - standby switching, ensure data consistency, and improve the accuracy of data processing.

[0006] In a first aspect, an embodiment of the present invention provides a method for unitized deployment, including:

[0007] When a first standby processing unit does not receive a heartbeat from a primary processing unit within a preset time period and does not receive a voting request within the election duration of the first standby processing unit, the first standby processing unit sends a voting request to a second standby processing unit; wherein, the first standby processing unit is any unit among the standby processing units; the second standby processing unit is any unit among the standby processing units except the first standby processing unit; the voting request is sent by the second standby processing unit when the second standby processing unit does not receive the heartbeat of the primary processing unit and after the election duration of the second standby processing unit; the primary processing unit and the standby processing unit belong to units with the same function in the distributed architecture;

[0008] The first standby processing unit receives the ballots sent by the second standby processing unit based on the voting request. If it is determined that the number of ballots is greater than the preset ballot threshold, the first standby processing unit is switched to the main processing unit.

[0009] In the above technical solution, the preset time period and the heartbeat of the main processing unit are used to determine whether the main processing unit has crashed or failed, etc., so as to improve the efficiency and flexibility of determining that the main processing unit has crashed or failed, etc. Specifically, when it is determined that the heartbeat of the main processing unit has not been received within the preset time period, it means that the main processing unit has crashed or failed, etc.; when it is determined that the heartbeat of the main processing unit has been received within the preset time period, it means that the main processing unit has not crashed or failed, etc. and is in a normal working state.

[0010] After determining that the main processing unit has crashed or failed, it is determined whether the first standby processing unit participates in the election of the main processing unit according to the election duration of the first standby processing unit; specifically, when no voting request is received within the election duration of the first standby processing unit, it means that the first standby processing unit participates in the election; when a voting request is received within the election duration of the first standby processing unit, it means that the first standby processing unit does not participate in the election.

[0011] After determining the election of the first standby processing unit, a voting request is sent to the second standby processing unit, and it is determined whether to be elected as the main processing unit according to the ballots sent by the second standby processing unit based on the voting request, so as to determine the standby processing unit to be switched to the main processing unit.

[0012] It can be seen that determining the standby processing unit to be switched to the main processing unit by means of election ensures the efficiency of switching the processing unit; because it is necessary to determine whether the standby processing unit participates in the election according to the election duration of the standby processing unit, and participates in the election according to the voting request, it can be ensured that the standby processing unit in the event of network interruption, network partition, etc. cannot participate in the election, that is, cannot be switched to the main processing unit, so as to ensure data consistency and improve the security and accuracy of data processing.

[0013] Optionally, when the first standby processing unit does not receive the heartbeat of the main processing unit within the preset time period and does not receive a voting request within the election duration of the first standby processing unit, sending a voting request to the second standby processing unit includes:

[0014] The first standby processing unit determines whether it has received the heartbeat of the main processing unit within the preset time period according to the heartbeat module of any application node in the first standby processing unit; the states of the application nodes in the first standby processing unit are consistent;

[0015] When the first standby processing unit determines that it has not received the heartbeat of the main processing unit within the preset time period, it starts an election timer according to the election module of the application node;

[0016] After starting the election timer, when the first standby processing unit determines that no voting request sent by the second standby processing unit is received within the election duration of the first standby processing unit according to the election timer, the first standby processing unit is set as a candidate, and the term number of the first standby processing unit is increased.

[0017] The first standby processing unit sends a voting request to the second standby processing unit.

[0018] In the above technical solution, any application node in the first standby processing unit is used to represent the first standby processing unit for the election. Since each module is included in the application node to implement different functions, the decoupling and modularization of functions in the election process are realized, the flexibility of unitized deployment is improved, and the requirements of different service scenarios are adapted.

[0019] Optionally, before the first standby processing unit sends a voting request to the second standby processing unit, it further includes:

[0020] The first standby processing unit detects whether the first standby processing unit meets the sending requirements according to the self-check module of the application node.

[0021] If the number of abnormal application nodes in the first standby processing unit is not greater than the abnormal threshold, it is determined that the first standby processing unit meets the sending requirements.

[0022] If the number of abnormal application nodes in the first standby processing unit is greater than the abnormal threshold, it is determined that the first standby processing unit does not meet the sending requirements.

[0023] In the above technical solution, when the first standby processing unit is a candidate, before sending a voting request, it performs self-abnormality detection on itself to ensure the security and accuracy of the first standby processing unit, and further ensure the security and accuracy of switching the main processing unit.

[0024] Optionally, the method further includes:

[0025] After starting the election timer, when the first standby processing unit determines that a voting request sent by the second standby processing unit is received within the election duration of the first standby processing unit according to the election timer, the first standby processing unit is set as a follower.

[0026] If the first standby processing unit determines that the term number of the second standby processing unit is greater than the term number of the first standby processing unit and the first standby processing unit has not sent a ballot, the first standby processing unit sends a ballot to the second standby processing unit.

[0027] If the first standby processing unit determines that the tenure number of the second standby processing unit is not greater than that of the first standby processing unit or the first standby processing unit has already sent a ballot, it will not send a ballot to the second standby processing unit.

[0028] In the above technical solution, when the first standby processing unit acts as a follower, it participates in the election of a candidate (i.e., the second standby processing unit); among them, the ballot of the follower is unique, and only one ballot can be sent to ensure the uniqueness of determining the main processing unit.

[0029] Optionally, the election duration of the first standby processing unit and the election duration of the second standby processing unit are randomly generated, and the election duration of the first standby processing unit is inconsistent with that of the second standby processing unit.

[0030] In the above technical solution, the election duration is used as a condition for the standby processing unit to be set as a candidate; among them, the election duration is randomly generated within a preset duration range (such as 100ms - 500ms), so as to ensure that each standby processing unit has the opportunity to become a candidate and guarantee the balance and flexibility of candidate selection.

[0031] Optionally, after switching the first standby processing unit to the main processing unit, it further includes:

[0032] The first standby processing unit sends a synchronization request to the second standby processing unit according to the status synchronization module of any application node in the first standby processing unit; the synchronization request is used to instruct the second standby processing unit to perform data synchronization with the first standby processing unit.

[0033] In the above technical solution, the data consistency of each standby processing unit and the main processing unit is ensured through the status synchronization module of the application node.

[0034] Optionally, the method further includes:

[0035] The first standby processing unit performs data persistence according to the persistence module of any application node in the first standby processing unit.

[0036] In a second aspect, an embodiment of the present invention provides a unitized deployment device, including:

[0037] A judgment module, configured to send a voting request to a second standby processing unit when the heartbeat of the main processing unit is not received within a preset time period and no voting request is received within the election duration of the first standby processing unit; wherein, the first standby processing unit is any one of the standby processing units; the second standby processing unit is any one of the standby processing units other than the first standby processing unit; the voting request is sent by the second standby processing unit when the heartbeat of the main processing unit is not received and after the election duration of the second standby processing unit has elapsed; the main processing unit and the standby processing units are units with the same function in a distributed architecture;

[0038] A processing module, configured to receive the ballot sent by the second standby processing unit based on the voting request, and if it is determined that the number of ballots is greater than a preset ballot threshold, switch the first standby processing unit to the main processing unit.

[0039] Optionally, the judgment module is specifically configured to:

[0040] Determine whether the heartbeat of the main processing unit is received within a preset time period according to the heartbeat module of any application node in the first standby processing unit; the states of the application nodes in the first standby processing unit are the same;

[0041] When it is determined that the heartbeat of the main processing unit is not received within the preset time period, start an election timer according to the election module of the application node;

[0042] After starting the election timer, when it is determined that no voting request sent by the second standby processing unit is received within the election duration of the first standby processing unit, set the first standby processing unit as a candidate and increase the term number of the first standby processing unit;

[0043] Send a voting request to the second standby processing unit.

[0044] Optionally, the judgment module is further configured to:

[0045] Before sending a voting request to the second standby processing unit, detect whether the first standby processing unit meets the sending requirements according to the self-check module of the application node;

[0046] If the number of abnormal application nodes in the first standby processing unit is not greater than the abnormal threshold, it is determined that the first standby processing unit meets the sending requirements;

[0047] If the number of abnormal application nodes in the first standby processing unit is greater than the abnormal threshold, it is determined that the first standby processing unit does not meet the sending requirements.

[0048] Optionally, the judgment module is further configured to:

[0049] After starting the election timer, when a voting request sent by the second standby processing unit is received within the election duration of the first standby processing unit determined according to the election timer, the first standby processing unit is set as a follower;

[0050] If it is determined that the term number of the second standby processing unit is greater than the term number of the first standby processing unit and the first standby processing unit has not sent a ballot, a ballot is sent to the second standby processing unit;

[0051] If it is determined that the term number of the second standby processing unit is not greater than the term number of the first standby processing unit or the first standby processing unit has already sent a ballot, a ballot is not sent to the second standby processing unit.

[0052] Optionally, the election duration of the first standby processing unit and the election duration of the second standby processing unit are randomly generated, and the election duration of the first standby processing unit and the election duration of the second standby processing unit are inconsistent.

[0053] Optionally, the processing module is further configured to:

[0054] After switching the first standby processing unit to the main processing unit, a synchronization request is sent to the second standby processing unit according to the status synchronization module of any application node in the first standby processing unit; the synchronization request is used to instruct the second standby processing unit to perform data synchronization with the first standby processing unit.

[0055] Optionally, the processing module is further configured to:

[0056] Perform data persistence according to the persistence module of any application node in the first standby processing unit.

[0057] In a third aspect, an embodiment of the present invention further provides a computer device, including:

[0058] A memory for storing program instructions;

[0059] A processor for calling the program instructions stored in the memory and executing the method of unitized deployment as described above according to the obtained program.

[0060] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to cause a computer to execute the method of unitized deployment as described above. Description of the Drawings

[0061] To more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the accompanying drawings required for the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.

[0062] Figure 1 It is a schematic diagram of a system architecture provided by an embodiment of the present invention;

[0063] Figure 2 It is a schematic diagram of the architecture of an application node provided by an embodiment of the present invention;

[0064] Figure 3 It is a schematic flowchart of a method for unitized deployment provided by an embodiment of the present invention;

[0065] Figure 4 It is a schematic diagram of unitized deployment provided by an embodiment of the present invention;

[0066] Figure 5 It is a schematic diagram of unitized deployment provided by an embodiment of the present invention;

[0067] Figure 6 It is a schematic diagram of unitized deployment provided by an embodiment of the present invention;

[0068] Figure 7 It is a schematic diagram of unitized deployment provided by an embodiment of the present invention;

[0069] Figure 8 It is a schematic diagram of unitized deployment provided by an embodiment of the present invention;

[0070] Figure 9 It is a schematic diagram of the structure of a device for unitized deployment provided by an embodiment of the present invention. Detailed implementation manners

[0071] In order to make the objectives, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts belong to the scope of protection of the present invention.

[0072] With the development of computer technology, to meet requirements such as high performance and scalability, more and more systems adopt a distributed architecture. Among them, the distributed architecture is the application and tool of distributed computing technology, and mature technologies include J2EE, CORBA, and.NET (DCOM), etc. It refers to a system architecture where hardware or software components are distributed on different network computers and communicate and coordinate with each other only through message passing.

[0073] Based on the distributed architecture, unitized deployment is adopted, with the unit as the basic unit of deployment to build a unitized architecture. Among them, a unit refers to a self - contained set that can complete all business operations, which includes all services required for all businesses and the data allocated to this unit.

[0074] However, in the field of computer technology, there are potential hazards of catastrophic failures in services, computer rooms, nodes, architectures, units, etc. Among them, a catastrophic failure refers to a sudden and complete failure that cannot be recovered. That is, a sudden failure causes the unit to be unusable.

[0075] Therefore, in order to enable the unit to have the ability to handle catastrophic failures, the unit is replicated to obtain multiple units, including a primary processing unit and multiple standby processing units; the functions of the primary processing unit and multiple standby processing units are the same. The primary processing unit is used to receive requests from clients and respond to the requests of clients; the standby processing unit is used to take over the primary processing unit to process client requests when a catastrophic failure occurs in the primary processing unit. It is equivalent to a primary - standby switch (i.e., the primary processing unit switches to the standby processing unit).

[0076] Currently, the methods to achieve primary - standby switching generally include the following two:

[0077] 1. After determining that the primary processing unit fails, manually specify a certain standby processing unit for primary - standby switching.

[0078] 2. Each processing unit has a preset serial number, such as s1, s2, s3, etc. After determining that the primary processing unit (such as the preset serial number is s1) fails, select a standby processing unit in the order of the preset serial number (i.e., select the standby processing unit with the preset serial number s2) for primary - standby switching.

[0079] To meet the CAP (Consistency, Availability, Partition tolerance) principle, the data consistency of each processing unit is achieved by sending synchronization requests through a third - party component or the selected standby processing unit.

[0080] However, in the above technical solution, during the master-slave switching process, the faulty unit needs to be isolated as soon as possible to make the RTO (Recovery Time Objective, which means the time period from the IT system downtime causing business suspension to the IT system recovery to support the operation of various departments and resume operations after a catastrophic failure) close to 0. In other words, it takes several minutes to isolate a faulty unit, resulting in low switching efficiency and high requirements for operation and maintenance personnel.

[0081] During the master-slave switching process according to the preset sequence number, it cannot be guaranteed that the selected standby processing unit is a safe and normal processing unit. In the case of network interruption, network partition, etc., there is a risk that the selected standby processing unit is faulty and unavailable, resulting in data inconsistency, that is, data consistency cannot be guaranteed.

[0082] In addition, when achieving data consistency between processing units, there is a risk of unreliable third-party components, and there are security risks in the selected backup processing units, which leads to data inconsistency and the inability to ensure data consistency.

[0083] Therefore, there is an urgent need for a unitized deployment method to ensure the efficiency of unit master-slave switching, ensure data consistency, and improve the accuracy of data processing.

[0084] Figure 1 A system architecture applicable to the embodiment of the present invention is exemplarily shown, and the system architecture includes unit A 100, unit B 200 and unit C 300. It should be noted that the embodiment of the present invention only exemplarily shows that the architecture includes three units, but does not limit the number of units.

[0085] In the embodiment of the present invention, the A unit 100 is taken as the main processing unit as an example; any unit includes multiple application nodes; Figure 1 As shown, unit A 100 includes application nodes a1, a2, a3 and a4; unit B 200 includes application nodes b1, b2, b3 and b4; unit C 300 includes application nodes c1, c2, c3 and c4; wherein, the service functions between any two units are consistent; for example, the service functions of unit A 100 and unit C 300 are consistent. The service functions of two application nodes in different units may be the same or different, and are not limited here; for example, the service functions of application node a1 and application node c1 may be consistent, and the service functions of application node a1 and application node b1 may be inconsistent.

[0086] In the embodiment of the present invention, any application node in any unit includes a function module and a service module; wherein the function module is used to participate in the election of the unit; and the service module is used to implement specific service functions, which are not specifically limited here.

[0087] Figure 2 A schematic diagram of the architecture of an application node shown exemplarily for the present invention is as follows Figure 2 shown, the application node includes a function module and a service module; the function module specifically includes a registration module, a heartbeat module, a status synchronization module, a self-check module, and a persistence module.

[0088] Among them, the registration module is used to register and start other modules to be loaded (that is, the heartbeat module, the status synchronization module, the self-check module, and the persistence module) according to the configuration.

[0089] The heartbeat module is used to connect with the heartbeat modules of other units, obtain the heartbeats of other units, and calculate the heartbeat interval according to the heartbeat time recorded in the cache.

[0090] The status synchronization module is used to achieve data consistency among units.

[0091] The self-check module is used to perform anomaly detection on itself and determine the number of abnormal application nodes.

[0092] The persistence module is used to write the data generated during the execution of the solution into the distributed cache to achieve data persistence.

[0093] In the embodiments of the present invention, the states of the function modules of each application node in the same unit are consistent, so any application node in any unit is allowed to represent the unit to participate in the election of the main processing unit. The states of the function module include the states of the registration module, the heartbeat module, the status synchronization module, the self-check module, and / or the persistence module.

[0094] It should be noted that the above Figure 1 and Figure 2 The shown architecture is only an example, and the embodiments of the present invention do not limit this.

[0095] Based on the above description, Figure 3 An exemplary schematic diagram of the process of a method for unitized deployment provided by the embodiments of the present invention is shown. This process can be executed by a unitized deployment device.

[0096] As Figure 3 shown, this process specifically includes:

[0097] Step 310, when the first standby processing unit does not receive the heartbeat of the main processing unit within a preset period and does not receive a voting request within the election duration of the first standby processing unit, it sends a voting request to the second standby processing unit.

[0098] In an embodiment of the present invention, the first standby processing unit is any unit in the standby processing units; the second standby processing unit is any unit in the standby processing units except the first standby processing unit; the voting request is sent by the second standby processing unit after not receiving the heartbeat of the main processing unit and after the election duration of the second standby processing unit has elapsed; the main processing unit and the standby processing units are units with the same function in a distributed architecture.

[0099] Taking the above Figure 1 as an example, the main processing units are unit A, unit B, and unit C, which are units with the same function in a distributed architecture; among them, unit A is the main processing unit, unit B is the first standby processing unit, and unit C is the second standby processing unit.

[0100] Step 320: The first standby processing unit receives the ballot sent by the second standby processing unit based on the voting request. If it is determined that the number of ballots is greater than the preset ballot threshold, the first standby processing unit is switched to the main processing unit.

[0101] In an embodiment of the present invention, the preset ballot threshold can be a value preset according to experience. For example, the preset ballot threshold is half of the sum of the number of the main processing unit and the standby processing units (for example, if the sum of the number of the main processing unit and the standby processing units is 8, the preset ballot threshold is 4), and specific limitations are not made here.

[0102] In step 310, it is determined whether the heartbeat of the main processing unit is received within a preset period according to the heartbeat module of any application node in the first standby processing unit. Among them, the preset period can be a value preset according to experience, such as 30s, etc.

[0103] Taking the above Figure 1 and Figure 2 as an example, the application node b1 represents the first standby processing unit (i.e., unit B). The first standby processing unit obtains the heartbeat of the main processing unit (i.e., unit A) according to the heartbeat module of the application node b1 and records the reception time. For example, the reception time is 12:00:00; assuming that the heartbeat of the main processing unit is not received from 12:00:00 to 12:00:30, it means that the main processing unit has a catastrophic failure and a main-standby switch needs to be performed.

[0104] To better illustrate the technical solution of the present invention, different states are set for each unit. The states include leader, candidate, and follower. Among them, the leader is the main processing unit and is used to process client requests and other operations; the candidate is generated when it is determined that the main processing unit fails and serves as the main processing unit to be switched; the follower is used to participate in the election of the leader. Based on the above Figure 1 , Figure 4 exemplarily shows a schematic diagram of unitized deployment. As Figure 4As shown, Unit A is the leader, and Unit B and Unit C are the followers.

[0105] In the embodiment of the present invention, after determining that the main processing unit fails, the state of the main processing unit is set to the follower state. Based on the above Figure 4 , Figure 5 An exemplary schematic diagram of unitized deployment is shown. As Figure 5 shown, Unit A, Unit B, and Unit C are all followers, which is equivalent to selecting a leader from each unit as the main processing unit.

[0106] After the states of each unit are followers, each unit starts its own election timer to determine candidates from each unit. Among them, the election timer is used to randomly generate an election duration within a preset time range. In the embodiment of the present invention, the election durations of any two units are inconsistent.

[0107] Among them, the preset time range can be a value preset according to experience. For example, the preset time range is 100ms - 500ms. Further, for example, the election duration of Unit A is 350ms, the election duration of Unit B is 150ms, and the election duration of Unit C is 200ms.

[0108] In an implementable manner, after the first standby processing unit starts the election timer, when it is determined that no voting request sent by the second standby processing unit is received within the election duration of the first standby processing unit according to the election timer, the first standby processing unit is set as a candidate, and the term number of the first standby processing unit is increased.

[0109] Based on the above embodiment for example, Figure 6 An exemplary schematic diagram of unitized deployment is shown. As Figure 6 shown, because the voting request of any unit is sent after the election duration of that unit, and the election durations of Unit A and Unit C are greater than that of Unit B (i.e., the first standby processing unit), it can be determined that within the election duration of Unit B, no voting requests sent by Unit A and Unit C are received, and thus Unit B is used as a candidate.

[0110] After the first standby processing unit is set as a candidate, the term number of the first standby processing unit is updated, and a voting request is sent to the second standby processing unit (i.e., sent to the followers). Among them, the term number is used for the followers to determine whether to send a ballot to the candidate. In the embodiment of the present invention, the update method is increment, that is, the term number of the first standby processing unit is increased. It can be imagined that other update methods can also be used to update the term number of the first standby processing unit, such as decrement, etc., which are not specifically limited here. As Figure 6 shown, after increasing the term number of the first standby processing unit, the term number of the first standby processing unit is 1.

[0111] To ensure the security of candidates, before a candidate sends a voting request, it is detected by the self-check module of any application node in the candidate whether the candidate meets the sending requirements (i.e., whether it meets the security requirements).

[0112] Specifically, if the number of abnormal application nodes in the first standby processing unit is not greater than the abnormal threshold, it is determined that the first standby processing unit meets the sending requirements. If the number of abnormal application nodes in the first standby processing unit is greater than the abnormal threshold, it is determined that the first standby processing unit does not meet the sending requirements. Among them, the abnormal threshold can be a preset value based on experience, such as the abnormal threshold is half of the number of application nodes in the unit, etc.

[0113] Based on the above Figure 1 and Figure 2 For example, the number of application nodes in Unit B is 4, and assume the abnormal threshold is 2. If it is detected by the self-check module of application node b1 that the number of abnormal application nodes in Unit B is 1, it is determined that Unit B meets the sending requirements, and then a voting request is sent to Unit A and Unit C. If it is detected by the self-check module of application node b1 that the number of abnormal application nodes in Unit B is 3, it is determined that Unit B does not meet the sending requirements, and then Unit B is prohibited from sending a voting request to Unit A and Unit C.

[0114] In another implementable manner, after the first standby processing unit starts the election timer, when it receives a voting request sent by the second standby processing unit within the election duration of the first standby processing unit according to the election timer, the first standby processing unit is set as a follower.

[0115] Based on the above description, for example, assume the election duration of Unit A is 250 ms, the election duration of Unit B is 450 ms, and the election duration of Unit C is 200 ms. Unit C starts the election timer and sends a voting request after 200 ms. Unit B starts the election timer and receives the voting request sent by Unit C after 300 ms, which means that Unit B cannot be a candidate and has no probability of being elected as the leader.

[0116] At this time, Unit B will not increase the term number either (i.e., the term number of Unit B is 0 and the term number of Unit C is 1).

[0117] Based on the above embodiments, for example Figure 7 An exemplary schematic diagram of unitized deployment is shown. As Figure 7 shown, because the election durations of Unit B and Unit A are greater than that of Unit C, and Unit B receives the voting request sent by Unit C within the election duration of Unit B, and then regards Unit C as a candidate.

[0118] After receiving the voting request sent by the second standby processing unit (i.e., the C unit), the first standby processing unit (i.e., the B unit) determines whether to send a ballot to the C unit in response to the voting request.

[0119] Specifically, if the first standby processing unit determines that the term number of the second standby processing unit is greater than the term number of the first standby processing unit and the first standby processing unit has not sent a ballot, it sends a ballot to the second standby processing unit.

[0120] Based on Figure 7 For example, if the term number of the B unit is 0 and the term number of the C unit is 1, it is determined that the term number of the second standby processing unit is greater than the term number of the first standby processing unit; assuming that the B unit has not sent a ballot, it sends a ballot to the C unit; assuming that the B unit has already sent a ballot to the A unit, it does not send a ballot to the C unit.

[0121] If the first standby processing unit determines that the term number of the second standby processing unit is not greater than the term number of the first standby processing unit or the first standby processing unit has already sent a ballot, it does not send a ballot to the second standby processing unit.

[0122] Based on the above description, for example, assuming that the B unit does not receive the voting requests sent by the A unit and the C unit within 450 ms, the B unit is also set as a candidate. At this time, the term number of the B unit is also 1. Then it is determined that the term number of the second standby processing unit is not greater than the term number of the first standby processing unit, so it does not send a ballot to the C unit.

[0123] In step 320, after the first standby processing unit receives the ballots feedback by the second standby processing unit based on the voting request sent by the first standby processing unit as a candidate, it counts the number of ballots. In the embodiment of the present invention, the candidate will send its own ballot to itself.

[0124] Based on the above Figure 6 For example, the B unit sends its own ballot to itself, and the A unit and the C unit send ballots to the B unit, and then the number of ballots counted is 3.

[0125] After the first standby processing unit counts the number of ballots, it compares with a preset ballot threshold; among them, the preset ballot threshold can be a value preset according to experience; for example, the preset ballot threshold is half of the number of units; if the number of units is 3, the preset ballot threshold is 1.5.

[0126] Furthermore, if the number of ballots is greater than the preset ballot threshold, the first standby processing unit is switched to the main processing unit. If the number of ballots is not greater than the preset ballot threshold, the first standby processing unit is not switched to the main processing unit, and the above election process is re-executed until the main processing unit is selected.

[0127] After the first standby processing unit switches to the main processing unit, the first standby processing unit sends a synchronization request to the second standby processing unit according to the status synchronization module of any application node in the first standby processing unit, so that the second standby processing unit synchronizes data with the first standby processing unit. Among them, the data synchronization includes term number synchronization.

[0128] Based on the above Figure 6 , Figure 8 An exemplary schematic diagram of unitized deployment is shown. As Figure 8 shown, after the B unit switches to the main processing unit, it sends heartbeats and synchronization requests to the A unit and the C unit, so that the term numbers of the A unit and the C unit are consistent with the term number of the B unit, and the data of the A unit and the C unit are consistent with the data of the B unit.

[0129] In the embodiment of the present invention, the persistence module of the application node is used to store the data generated during the unitized deployment process into the distributed cache, so as to achieve data persistence.

[0130] Based on the above technical solution, it is possible to determine whether the main processing unit has crashed or failed, etc. through a preset period and the heartbeat of the main processing unit, so as to improve the efficiency and flexibility of determining that the main processing unit has crashed or failed, etc.

[0131] Specifically, as described above Figure 4 shown, when the B unit determines that it has not received the heartbeat of the A unit within the preset period, it means that the A unit has crashed or failed, etc. After determining that the A unit has crashed or failed, as Figure 6 shown, according to the election duration of the B unit, it is determined that the B unit participates in the election of the main processing unit; then a voting request is sent to the A unit and the C unit, and the votes sent by the A unit and the C unit are received. Finally, as Figure 6 shown, it is determined that the B unit is elected as the leader (i.e., the main processing unit), so that it can be determined that the standby processing unit that switches to the main processing unit is the B unit.

[0132] It can be seen that determining the standby processing unit to be switched to the main processing unit by means of election ensures the efficiency of switching the processing unit; because it is necessary to determine whether the standby processing unit participates in the election according to the election duration of the standby processing unit, and participates in the election according to the voting request, it can be ensured that the standby processing unit in the event of network interruption, network partition, etc. cannot participate in the election, that is, cannot be switched to the main processing unit, so as to ensure data consistency and improve the security and accuracy of data processing.

[0133] In addition, when the A unit sends a network partition, through the votes of the B unit itself and the votes of the C unit, it is still possible to determine that the B unit is the standby processing unit to be switched, ensuring the availability of the primary and standby switchover.

[0134] Based on the same inventive concept, Figure 9 Exemplarily, a schematic structural diagram of a device for unitized deployment provided by an embodiment of the present invention is shown. This device can execute the process of the method for unitized deployment.

[0135] As Figure 9 shown, the device specifically includes:

[0136] A judgment module 910, configured to send a voting request to a second standby processing unit when no heartbeat of the main processing unit is received within a preset time period and no voting request is received within the election duration of a first standby processing unit; wherein, the first standby processing unit is any unit among the standby processing units; the second standby processing unit is any unit among the standby processing units except the first standby processing unit; the voting request is sent by the second standby processing unit when no heartbeat of the main processing unit is received and after the election duration of the second standby processing unit has passed; the main processing unit and the standby processing units are units with consistent functions in a distributed architecture;

[0137] A processing module 920, configured to receive the ballot sent by the second standby processing unit based on the voting request, and if it is determined that the number of ballots is greater than a preset ballot threshold, switch the first standby processing unit to the main processing unit.

[0138] Optionally, the judgment module 910 is specifically configured to:

[0139] Determine whether the heartbeat of the main processing unit is received within a preset time period according to the heartbeat module of any application node in the first standby processing unit; the states of the application nodes in the first standby processing unit are consistent;

[0140] When it is determined that the heartbeat of the main processing unit is not received within the preset time period, start an election timer according to the election module of the application node;

[0141] After starting the election timer, when it is determined that no voting request sent by the second standby processing unit is received within the election duration of the first standby processing unit, set the first standby processing unit as a candidate and increase the tenure number of the first standby processing unit;

[0142] Send a voting request to the second standby processing unit.

[0143] Optionally, the judgment module 910 is further configured to:

[0144] Before sending a voting request to the second standby processing unit, detect whether the first standby processing unit meets the sending requirements according to the self-check module of the application node;

[0145] If the number of abnormal application nodes in the first standby processing unit is not greater than the abnormal threshold, it is determined that the first standby processing unit meets the sending requirement;

[0146] If the number of abnormal application nodes in the first standby processing unit is greater than the abnormal threshold, it is determined that the first standby processing unit does not meet the sending requirement.

[0147] Optionally, the judgment module 910 is further configured to:

[0148] After starting the election timer, when it is determined that a vote request sent by the second standby processing unit is received within the election duration of the first standby processing unit according to the election timer, set the first standby processing unit as a follower;

[0149] If it is determined that the term number of the second standby processing unit is greater than the term number of the first standby processing unit and the first standby processing unit has not sent a ballot, send a ballot to the second standby processing unit;

[0150] If it is determined that the term number of the second standby processing unit is not greater than the term number of the first standby processing unit or the first standby processing unit has already sent a ballot, do not send a ballot to the second standby processing unit.

[0151] Optionally, the election duration of the first standby processing unit and the election duration of the second standby processing unit are randomly generated, and the election duration of the first standby processing unit is inconsistent with the election duration of the second standby processing unit.

[0152] Optionally, the processing module 920 is further configured to:

[0153] After switching the first standby processing unit to the main processing unit, send a synchronization request to the second standby processing unit according to the status synchronization module of any application node in the first standby processing unit; the synchronization request is used to instruct the second standby processing unit to perform data synchronization with the first standby processing unit.

[0154] Optionally, the processing module 920 is further configured to:

[0155] Perform data persistence according to the persistence module of any application node in the first standby processing unit.

[0156] Based on the same technical concept, an embodiment of the present invention further provides a computer device, including:

[0157] A memory for storing program instructions;

[0158] A processor for calling the program instructions stored in the memory and executing the method of unitized deployment as described above according to the obtained program.

[0159] Based on the same inventive concept, an embodiment of the present invention further provides a computer-readable storage medium storing computer-executable instructions for causing a computer to execute the method of unitized deployment described above.

[0160] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0161] The present application is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram can be implemented by computer program instructions, and the combination of flows and / or blocks in the flowchart and / or block diagram can also be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for realizing the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 block or multiple blocks.

[0162] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device that realizes the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 block or multiple blocks.

[0163] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for realizing the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 block or multiple blocks.

[0164] Obviously, those skilled in the art can make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalent technologies, this application is also intended to include these modifications and variations.

Claims

1. A method for unitized deployment in a distributed architecture, characterized in that Applied to a distributed architecture for unitized deployment, including: When the first standby processing unit does not receive the heartbeat of the primary processing unit within a preset period and does not receive a voting request within the election duration of the first standby processing unit, it sends a voting request to the second standby processing unit; wherein, the first standby processing unit is any unit among the standby processing units; the second standby processing unit is any unit among the standby processing units except the first standby processing unit; the voting request is sent by the first standby processing unit after it does not receive the heartbeat of the primary processing unit and after the election duration of the first standby processing unit; the primary processing unit and the standby processing units are units with the same function in the distributed architecture; any unit includes multiple application nodes; each of the application nodes includes a self-check module; the self-check module is used to perform anomaly detection on itself before sending a voting request, determine the number of abnormal application nodes in the unit, and determine whether the unit meets the sending requirements; The first standby processing unit receives the ballot sent by the second standby processing unit based on the voting request. If it determines that the number of ballots is greater than the preset ballot threshold, it switches the first standby processing unit to the primary processing unit; The method further includes: After the first standby processing unit starts an election timer, when it determines that it receives a voting request sent by the second standby processing unit within the election duration of the first standby processing unit according to the election timer, it sets the first standby processing unit as a follower; If the first standby processing unit determines that the term number of the second standby processing unit is greater than the term number of the first standby processing unit and the first standby processing unit has not sent a ballot, it sends a ballot to the second standby processing unit; If the first standby processing unit determines that the term number of the second standby processing unit is not greater than the term number of the first standby processing unit or the first standby processing unit has already sent a ballot, it does not send a ballot to the second standby processing unit.

2. The method according to claim 1, characterized in that, When the first standby processing unit does not receive the heartbeat of the primary processing unit within a preset period and does not receive a voting request within the election duration of the first standby processing unit, sending a voting request to the second standby processing unit includes: The first standby processing unit determines whether it receives the heartbeat of the primary processing unit within a preset period according to the heartbeat module of any application node in the first standby processing unit; the states of the application nodes in the first standby processing unit are the same; When the first standby processing unit determines that it does not receive the heartbeat of the primary processing unit within a preset period, it starts an election timer according to the election module of the application node; After the first standby processing unit starts the election timer, when it determines that it does not receive a voting request sent by the second standby processing unit within the election duration of the first standby processing unit, it sets the first standby processing unit as a candidate and increases the term number of the first standby processing unit; The first standby processing unit sends a voting request to the second standby processing unit.

3. The method according to claim 2, wherein Before the first standby processing unit sends a voting request to the second standby processing unit, it further includes: The first standby processing unit detects whether the first standby processing unit meets the sending requirement according to the self-check module of the application node; If the number of abnormal application nodes in the first standby processing unit is not greater than the abnormal threshold, it is determined that the first standby processing unit meets the sending requirement; If the number of abnormal application nodes in the first standby processing unit is greater than the abnormal threshold, it is determined that the first standby processing unit does not meet the sending requirement.

4. The method according to claim 1, wherein The election duration of the first standby processing unit and the election duration of the second standby processing unit are randomly generated, and the election duration of the first standby processing unit is inconsistent with the election duration of the second standby processing unit.

5. The method according to claim 1, characterized in that After switching the first standby processing unit to the main processing unit, it further includes: The first standby processing unit sends a synchronization request to the second standby processing unit according to the status synchronization module of any application node in the first standby processing unit; the synchronization request is used to instruct the second standby processing unit to perform data synchronization with the first standby processing unit.

6. The method according to any one of claims 1 to 5, characterized in that The method further includes: The first standby processing unit performs data persistence according to the persistence module of any application node in the first standby processing unit.

7. A unitized deployment device, characterized in that, Applied to a distributed architecture with unitized deployment, it includes: A judgment module, configured to send a voting request to the second standby processing unit when the heartbeat of the main processing unit is not received within a preset period and the voting request is not received within the election duration of the first standby processing unit; wherein, the first standby processing unit is any unit among the standby processing units; the second standby processing unit is any unit among the standby processing units except the first standby processing unit; the voting request is sent by the first standby processing unit when the heartbeat of the main processing unit is not received and after the election duration of the first standby processing unit; the main processing unit and the standby processing unit are units with the same function in the distributed architecture; any unit includes multiple application nodes; any application node includes a self-check module; the self-check module is used to perform abnormal detection on itself before sending a voting request, determine the number of abnormal application nodes in the unit, and determine whether the unit meets the sending requirement; A processing module, configured to receive the ballot sent by the second standby processing unit based on the voting request, and if it is determined that the number of ballots is greater than the preset ballot threshold, switch the first standby processing unit to the main processing unit; The judgment module is further configured to: after starting the election timer, when it is determined that the voting request sent by the second standby processing unit is received within the election duration of the first standby processing unit according to the election timer, set the first standby processing unit as a follower; if it is determined that the term number of the second standby processing unit is greater than the term number of the first standby processing unit and the first standby processing unit has not sent a ballot, send a ballot to the second standby processing unit; if it is determined that the term number of the second standby processing unit is not greater than the term number of the first standby processing unit or the first standby processing unit has already sent a ballot, do not send a ballot to the second standby processing unit.

8. A computer device, characterized in that, It includes: A memory, configured to store program instructions; A processor, configured to call program instructions stored in the memory and execute the method according to any one of claims 1 to 6 based on the obtained program.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions for causing a computer to execute the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Management node election method and device, storage medium and electronic equipment

    CN114465879A