Business processing methods and related equipment for distributed systems

By obtaining the local task information of the processing nodes, determining their participation status, and selecting a suitable node as the master node, the problem of efficiency being affected when the processing nodes have a large workload is solved, thereby improving the business processing efficiency and user experience of the distributed system.

CN116389220BActive Publication Date: 2026-04-03SHANGHAI BILIBILI TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-07
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

In a distributed system, when a processing node is performing log synchronization and data storage tasks, designating it as the master node when the workload is large can affect business processing efficiency and reduce user application experience.

Method used

By obtaining the local task information of the processing node, its participation status is determined, avoiding the designation of the master node when the task volume is large. The Raft consensus algorithm is used to select a suitable node as the master node.

Benefits of technology

It improves the business processing efficiency of distributed systems, enhances the user experience, and avoids the impact of high-load processing nodes on business processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116389220B_ABST
    Figure CN116389220B_ABST
Patent Text Reader

Abstract

This application proposes a business processing method and related equipment for a distributed system. The method includes: obtaining local task information of a processing node; determining the participation status of the processing node in the distributed system based on the local task information; wherein the participation status includes: a first participation status of not participating in being designated as a master node and a second participation status of participating in being designated as a master node; if the processing node's participation status is in the first participation status, then abandoning the designation of that processing node as a master node. This embodiment of the application determines the participation status of a processing node based on its local task information, and then determines whether the processing node should participate in being designated as a master node based on the participation status. This avoids impacting business processing efficiency and reducing user experience when a processing node has a large local task load and is designated as a master node.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of computer technology and blockchain technology, and in particular to a business processing method and related equipment for a distributed system. Background Technology

[0002] In a distributed system, multiple hosts are used as processing nodes to form a Raft cluster. Each processing node must at least complete the tasks of log synchronization and data storage so that if a single processing node fails, the other processing nodes can still provide services normally.

[0003] In existing processing methods, when processing nodes are handling large amounts of data for log synchronization and data storage, and simultaneously executing tasks of a distributed system, processing efficiency is affected. Summary of the Invention

[0004] This application provides a business processing method and related equipment for a distributed system to solve the problems existing in related technologies. The technical solution is as follows:

[0005] In a first aspect, embodiments of this application provide a business processing method for a distributed system, including:

[0006] Obtain local task information for the processing node;

[0007] Based on local task information, the participation status of the processing node in the distributed system is determined; wherein the participation status includes: a first participation status of not participating in the designated master node and a second participation status of participating in the designated master node;

[0008] If the participation status of the processing node is the first participation status, then the designation of the processing node as the master node is abandoned.

[0009] Secondly, embodiments of this application provide a service processing apparatus based on the Raft consensus algorithm, including:

[0010] The information acquisition module is used to acquire local task information of the processing node;

[0011] The participation status determination module is used to determine the participation status of the processing node in the distributed system based on local task information; wherein, the participation status includes: a first participation status of not participating in the designation of the master node and a second participation status of participating in the designation of the master node; the designation module is used to abandon the designation of the processing node as the master node when the participation status of the processing node is the first participation status.

[0012] Thirdly, embodiments of this application provide an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to execute the task processing method of the Raft consensus algorithm described above.

[0013] Fourthly, embodiments of this application provide a computer-readable storage medium that stores computer instructions, wherein when the computer instructions are executed on a computer, the methods in any of the above-described embodiments are performed.

[0014] The advantages or beneficial effects of the above technical solutions include at least the following:

[0015] This application embodiment determines the participation status of a processing node based on its local task information, and then determines whether the processing node can be designated as the master node based on the participation status. This avoids impacting business processing efficiency and reducing user experience when a processing node has a large local task load and is designated as the master node.

[0016] The above overview is for illustrative purposes only and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments, and features described above, further aspects, embodiments, and features of this application will become readily apparent from the accompanying drawings and the following detailed description. Attached Figure Description

[0017] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the various drawings denote the same or similar parts or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings depict only some embodiments disclosed in this application and should not be construed as limiting the scope of this application.

[0018] Figure 1 This diagram illustrates an application scenario of a business processing method for a distributed system according to an embodiment of this application.

[0019] Figure 2 A flowchart illustrating a business processing method of a distributed system according to an embodiment of this application is shown.

[0020] Figure 3 A schematic diagram of log synchronization according to an embodiment of this application is shown.

[0021] Figure 4 Show Figure 2 A flowchart illustrating the sub-steps of step S220.

[0022] Figure 5A flowchart illustrating a business processing method of a distributed system according to another embodiment of this application is shown.

[0023] Figure 6 A schematic structural block diagram of a service processing apparatus for a distributed system according to another embodiment of this application is shown.

[0024] Figure 7 This is a block diagram of an electronic device used to implement the business processing method of the distributed system in the embodiments of this application. Detailed Implementation

[0025] In the following description, only certain exemplary embodiments are briefly described. As those skilled in the art will recognize, the described embodiments can be modified in various ways without departing from the spirit or scope of this application. Therefore, the drawings and description are considered to be exemplary in nature and not restrictive.

[0026] Raft is a consensus algorithm (distributed consensus algorithm). Consensus algorithms can be applied in distributed systems or blockchain technology, meaning they enable the processing nodes in a distributed cluster to reach a consensus on certain information or states. For example... Figure 1 As shown, a Raft cluster can contain multiple processing nodes. It can tolerate the failure of some processing nodes, as long as one processing node in the cluster remains operational, the Raft cluster will continue to function normally. Each processing node includes a data storage unit and a logical processing unit. The data storage unit is used to store data in a local database, while the logical processing unit (Raft) is used at least for log recording, maintaining log synchronization across multiple processing nodes.

[0027] In a Raft cluster, one of the multiple processing nodes is selected as the leader through a predefined voting mechanism, while the others become followers. Each leader has a term. After its term expires, another leader is selected from the followers using the same rules. The leader interacts with clients, receives business requests, and performs tasks such as writing data. Followers receive tasks from the leader and perform tasks such as reading data. Multiple followers receive instructions from the leader to complete different tasks, such as reading data.

[0028] In a Raft cluster, to ensure that the Raft cluster functions correctly as long as one processing node is operational, the slave nodes need to synchronize the master node's log records, essentially replicating the same log records as the master. The slave nodes also need to receive and store data in a key-value (KV) database, such as an LSM-Tree (Log-Structured Merge Tree) database. In some cases, identical data may occupy multiple different key-value pairs. Database compaction is necessary to reduce this to a single key-value pair for the same data, thus freeing up storage space.

[0029] Therefore, in addition to interacting with the master node and other slave nodes, processing nodes in a Raft cluster also need to handle local tasks, such as log synchronization, data storage, and database compression. When a slave node has a large amount of local tasks and is then elected as the master node, it impacts the efficiency of business processing and degrades the user experience.

[0030] To improve the business processing efficiency of distributed systems, one embodiment of this application provides a business processing method based on the Raft consensus algorithm. The following description of this method takes the master node as the execution subject.

[0031] Figure 2 A flowchart illustrating a service processing method of a distributed system according to an embodiment of this application is shown. Figure 2 As shown, the business processing method of this distributed system may include:

[0032] S210, Obtain local task information of the processing node.

[0033] Obtaining local task information for a processing node can involve obtaining local task information from multiple slave nodes or from the master node.

[0034] In one example, if the Raft cluster's specified rule is that a single processing node cannot be continuously designated as the master node, then the local task information of the master node can be obtained without retrieving the local task information of the multiple slave nodes.

[0035] In this embodiment of the application, obtaining the local task information of the processing node may mean obtaining the local task information of the processing node that has the qualification of the master node.

[0036] In one example, the rule for specifying a Raft cluster might be that a processing node cannot be designated as the master node again within three terms after it has been designated as the master node. In this case, the master nodes in the three terms prior to that are not eligible to be designated as the master node and do not need to obtain the local task information of these processing nodes.

[0037] Local task information can be understood as tasks executed based on instructions from the local machine, rather than tasks executed based on requests or instructions from other nodes.

[0038] Each processing node includes at least two local tasks: log synchronization and data storage. Log synchronization ensures that the log records are identical with those of the master node, so that when the master node receives a business request, it can read data from either slave node and execute the business request.

[0039] S220, based on local task information, determines the participation status of the processing node in the distributed system. The participation status includes: a first participation status of not participating in the designated master node, and a second participation status of participating in the designated master node.

[0040] By analyzing the local task information of processing nodes, we can determine whether designating a node as the master node would impact business processing efficiency. If it wouldn't affect efficiency, its participation status can be set to second participation, meaning it participates in the master node designation. In this case, the current master node might designate this node as the next master node based on specified rules. If it would affect efficiency, its participation status can be set to first participation, meaning it doesn't participate in the master node designation, thus preventing any impact on efficiency when designated as the master node.

[0041] In this embodiment, by prioritizing the selection of nodes that will not affect business processing efficiency as master nodes, the business processing efficiency of the entire distributed system is improved, thereby enhancing the user's application experience.

[0042] S230, if the participation status of the processing node is in the first participation status, abandon the designation of the processing node as the master node.

[0043] If a processing node is determined to be in the first participation state, meaning it does not participate in being designated as the master node, its state can be adjusted to the abstention state. In this case, when selecting the master node according to the specified rules, it can be excluded from the selection process.

[0044] This application embodiment determines the participation status of a processing node based on its local task information, and then determines whether the processing node should be designated as the master node based on its participation status. This avoids reducing business processing efficiency and affecting the user's application experience when a processing node has a large local task load and is designated as the master node.

[0045] In one implementation, step S210 includes: obtaining the log synchronization data volume and database compression information of the processing node; the log synchronization data volume is the deviation between the log index and the master node log index.

[0046] When a business request task is executed by the master node, an event occurs, and a log entry is generated. By recording these log entries, it is easy to process business requests based on the log data. Slave nodes can synchronize these log entries to easily cooperate with the master node in processing business requests.

[0047] When a master node records a log entry, it assigns an index number to that log entry. When other slave nodes synchronize this log, they can record the corresponding log content based on the index number. Log synchronization is complete when all log entries corresponding to all index numbers on the master node have been recorded.

[0048] The log index numbers of the slave node and the master node can be the same or different. The log index number of the slave node can be found in the log records of the master node. For example, the index numbers of the master node are A1, A2, A3, ... An; the log index numbers of the slave node can be B1, B2, B3, ... Bn.

[0049] Based on the log index number being recorded by the slave node and the master node's index number, it can be determined how many log entries the slave node still needs to synchronize. For example, if the master node is recording log entries at index A9, and the slave node is recording log entries at index B4, then it can be determined that the slave node still has 9 - 4 = 5 log entries to synchronize.

[0050] In one example, such as Figure 3 As shown, the leader node recorded 5 log records, the first follower node recorded 4 log records, and the second follower node recorded 3 log records; therefore, the first follower node synchronized 1 log record, and the second follower node synchronized 2 log records.

[0051] Data retrieved from the master node, or data generated by executing commands from the master node, is stored locally as key-value pairs. To free up space, the database can be compressed periodically or irregularly, assigning the same key-value pairs to identical data. Database compression can be triggered, for example, when a preset amount of data has been stored; or when a user's business request is completed. A user's business request can refer to the business transactions that occur from the time a user opens the application until it closes.

[0052] When a processing node triggers database compression, the database compression information switches to a pending compression state; upon completion of log synchronization, the database compression operation is performed. During the period between the completion of database compression and the triggering of the next database compression operation, the database compression information remains in a pending compression state.

[0053] Step S220 includes: when the amount of log synchronization data exceeds a first preset threshold and the database compression information is in a state to be compressed, determining the participation state of the processing node as the first participation state.

[0054] The first preset threshold for multiple processing nodes can be the same or different. The first preset threshold can be determined by engineers based on experience, or it can be determined by considering the database compression triggering strategy.

[0055] In this embodiment, when the amount of log synchronization data exceeds a first preset threshold and the database compression information is in a pending compression state, database compression must be completed after log synchronization, and the node must also interact with the user terminal as the master node, which will affect business processing efficiency. By configuring the processing node to not participate in designating it as the master node under such extreme processing conditions, the designation of this node as the master node can be avoided, thus preventing the impact on business processing efficiency. The extreme processing conditions refer to the limit that would affect business processing efficiency when the node is the master node.

[0056] In one implementation, step S220 further includes: when the amount of log synchronization data is less than a second preset threshold and the database compression information is not in a state to be compressed, determining the participation state of the processing node as the second participation state.

[0057] In this embodiment, a log synchronization data volume less than the second preset threshold can be understood as a situation where the log synchronization task is nearly complete, rather than a situation where log synchronization must be completed. The second preset threshold can be set by engineers based on experience, or it can be determined by considering the database compression triggering strategy. If the duration of two database compression triggers is long, a larger second preset threshold can be set; conversely, if the duration of two database compression triggers is short, a smaller second preset threshold can be set to ensure that the participation status of the processing node is determined to be the second participation status only when log synchronization is nearly complete.

[0058] In this embodiment, after a processing node's participation status is determined to be in the first participation state, local task information is continuously acquired. If the local task information indicates that the processing node's local task processing is nearly complete, the processing node's participation status is then determined to be in the second participation state, thus restoring its eligibility to be designated as the master node. This allows each processing node in the distributed system to operate dynamically, ensuring the business processing efficiency of the distributed system.

[0059] The task processing method in this application embodiment further includes: when the participation state is the second participation state, selecting the processing node as the master node according to a preset specified rule.

[0060] Once a processing node reverts to its second participation state (i.e., participating in the selection of a designated master node), it becomes eligible to be designated as the master node. The master node is then designated through a specified rule (a voting mechanism in a distributed system). This means that among multiple processing nodes eligible to be designated as master nodes, one node is selected as the master node through a vote.

[0061] In one implementation, step S210 includes: obtaining database compression information of the processing node.

[0062] Correspondingly, step S220 includes:

[0063] Get the number of processing nodes in the distributed system;

[0064] If the number of processing nodes exceeds the third preset threshold, the participation status of multiple processing nodes that determine the database compression information to be in a state of pending compression is all in the first participation state.

[0065] In this embodiment of the application, considering that the main reason affecting the business processing efficiency of the master node is database compression, that is, when the processing node is performing database compression, it is relatively easy to affect the processing efficiency of the processing node as the master node in performing business processing.

[0066] Therefore, in this embodiment, the local task information considers database compression information but not the amount of log synchronization data. When there are many processing nodes, it is sufficient to select one as the master node from the majority of processing nodes, meaning there are many selection opportunities. In this case, if the database information of a processing node is in a state of pending compression, then that processing node will not be designated as the master node.

[0067] In one example, the database compression information can also be obtained as the number of processing nodes that are not in a state to be compressed or are in a state to be compressed. If the ratio of the number of processing nodes that are not in a state to be compressed to the total number of processing nodes is greater than the fourth preset threshold, the participation status of the processing nodes to be compressed can be determined as the first participation status.

[0068] In this embodiment of the application, by ensuring that a certain number of processing nodes participate in the designation of the master node, other processing nodes with a large workload, such as processing nodes whose database compression information is in a state of pending compression, can be determined not to participate in the designation of the master node. This can improve the efficiency of determining the participation status of processing nodes, while ensuring that there are processing nodes that are designated as the master node.

[0069] In one implementation, such as Figure 4 As shown, step S220 includes:

[0070] S221, based on local task information, obtain the task load of the processing node.

[0071] Local task information may include the amount of log synchronization data and / or database compression information.

[0072] In one example, the database compression triggering strategy is the same for each processing node; for example, the database compression operation is triggered after a preset amount of data has been stored. Therefore, the workload for database compression is the same for each processing node. Among multiple processing nodes where the database compression information is in a pending state, the workload for database compression is the same.

[0073] In this embodiment of the application, the workload of obtaining the processing node can be the sum of the log synchronization data volume and the database compression information workload.

[0074] In one example, one log synchronization record can be considered one task in the log synchronization data volume. When added to the database compression task volume, the database compression task weight can be set. For example, one database compression task is equivalent to 100 log synchronization tasks. Therefore, if the processing node has 50 log synchronization records and the database compression information is in a pending state, the task volume for that processing node is 150.

[0075] S222: Sort tasks based on the workload of multiple processing nodes.

[0076] By obtaining the task load of multiple processing nodes, the local task information of each node is converted into a numerical value. This numerical value can then be used to sort the task load of the multiple processing nodes. For example, the task load can be sorted in ascending order or descending order.

[0077] S223, Based on the sorting results, determine the participation status of a preset number of processing nodes as the second participation status.

[0078] The preset number can be set according to the actual situation. For example, if the total number of processing nodes is 8, the preset number can be set to 5.

[0079] The preset number can also take into account the number of processing nodes that fail. For example, if there are a total of 8 processing nodes, the preset number can be set to 5 if no processing nodes fail; 4 if 1-2 processing nodes fail; and 3 if 3-4 processing nodes fail.

[0080] In one example, the number of processing nodes that have failed can be categorized. For instance, level 0 represents the case where no processing nodes have failed; level 1 represents the case where 1-2 processing nodes have failed; level 2 represents the case where 3-4 processing nodes have failed; and the preset number can be 5 or more levels.

[0081] This application embodiment ensures that the number of processing nodes that can participate in the designated master node's processing state can be ensured by determining the participation status of a preset number of processing nodes as the second participation state.

[0082] The participation status of a preset number of processing nodes is the second parameter status. This preset number of processing nodes can be selected from the sorting results, choosing the node with the smallest task load. For example, if the total number of processing nodes is 8, and they are arranged in ascending order of task load, with a preset number of 5, then the first 5 processing nodes in the sorting result will be in the second participation status, and the last three processing nodes will be in the first participation status.

[0083] In other examples, the participation status of a predetermined number of processing nodes can be designated as the first participation status, but this application embodiment does not limit this.

[0084] In this embodiment, by obtaining the task volume of the processing nodes and sorting the task volumes, the participation status of multiple processing nodes with smaller task volumes is determined as the second participation status. This can quickly determine the participation status of multiple processing nodes and improve business processing efficiency.

[0085] In one implementation, such as Figure 5 As shown, the processing nodes include multiple nodes, including master nodes and slave nodes. The method also includes:

[0086] S240: In response to the upgrade request, the master node sends an upgrade request to multiple slave nodes, so that the multiple slave nodes respond to the upgrade request and perform the upgrade.

[0087] During system operation, upgrades are often required for various reasons. In the process of upgrading the system, multiple processing nodes are upgraded one by one to achieve the upgrade of the entire system.

[0088] When the master node receives an upgrade request, it sends the upgrade request task to multiple slave nodes, so that the slave nodes respond to the upgrade request and perform the upgrade operation.

[0089] Multiple slave nodes are not upgraded simultaneously, but one by one in a preset order. This can be achieved by sending an upgrade request to the corresponding slave node when it is determined which slave node will be upgraded, thus causing the slave node to respond to the upgrade request and execute the upgrade.

[0090] S250: The master node performs the upgrade after confirming that all slave nodes have completed the upgrade.

[0091] This application embodiment avoids the situation where, when upgrading the master node, it is necessary to switch the master node to another processing node (the next master node) during the upgrade of the master node, and then switch the master node to yet another processing node (the next master node) during the upgrade of the other processing node (the next master node). This avoids the situation where, when upgrading the master node, multiple master node switches are required.

[0092] In one implementation, step S220 includes: determining the participation state of the slave node as a first participation state when the slave node performs an upgrade.

[0093] In this embodiment, when a slave node performs an upgrade, its participation status is determined to be the first participation status, meaning it does not participate in designating a master node. Since a slave node may exit the program and be unable to perform tasks interacting with the user during an upgrade, determining it as not participating in designating a master node avoids the need to switch the master node to another slave node during the upgrade process, effectively improving upgrade efficiency and business processing efficiency.

[0094] In one example, upon receiving an upgrade request, the master node determines the upgrade order based on the local task information of multiple slave nodes. The corresponding slave nodes are then instructed to upgrade according to this order. When determining the participation status of slave nodes, the node whose processing status is determined to be the next to be upgraded based on the upgrade order can be set as the first participating node. This avoids a situation where the master node itself is selected to be upgraded again.

[0095] In one implementation, performing the upgrade includes:

[0096] Terminate log synchronization;

[0097] Perform database compression while the database compression information is in a pending state;

[0098] Once you have confirmed that database compression is complete, close the program to exit the service.

[0099] When a processing node performs an upgrade, it needs to exit the program. Before exiting, log synchronization is paused, and database compression is prioritized. Database compression is completed before exiting the program. After the upgrade is complete, when the processing node restarts, log synchronization resumes. This avoids situations where the log synchronization data volume exceeds a first preset threshold while the database compression information is still pending. It also reduces the number of processing nodes whose participation status is determined not to participate as the designated master node, thus improving business processing efficiency.

[0100] In one implementation, performing the upgrade further includes:

[0101] If the database compression information is not in a state of waiting to be compressed, database compression will be triggered based on a preset triggering strategy.

[0102] Before a processing node performs an upgrade and exits the program, if the database compression information is not in a pending compression state, a trigger strategy will be used to initiate database compression. For example, database compression can be triggered before exiting the program or upon receiving an upgrade request, ensuring the database compression information is in a pending state. This completes database compression before exiting the program, avoiding the need for compression after a restart and further improving business processing efficiency.

[0103] Figure 6 This diagram illustrates a structural block diagram of a service processing apparatus 600 based on the Raft consensus algorithm according to an embodiment of this application. The Raft consensus algorithm-based service processing apparatus 600 of this embodiment can be loaded into multiple processing nodes of a distributed system. Figure 6 As shown, the device 6000 may include:

[0104] The information acquisition module 610 is used to acquire local task information of the processing node;

[0105] The participation status determination module 620 is used to determine the participation status of the processing node based on local task information; wherein the participation status includes: a first participation status of not participating in the designated master node and a second participation status of participating in the designated master node;

[0106] Module 630 is designated to abandon designating a processing node as the master node when the processing node's participation status is in the first participation status.

[0107] In one implementation, the information acquisition module 610 is used to acquire the log synchronization data volume and database compression information of the processing node; the log synchronization data volume is the deviation between the log index and the master node log index;

[0108] The participation status determination module 620 is used to determine the participation status of the processing node as the first participation status when the amount of log synchronization data exceeds a first preset threshold and the database compression information is in a state to be compressed.

[0109] In one embodiment, the participation status determination module 620 is further configured to determine the participation status of the processing node as the second participation status when the amount of log synchronization data is less than the second preset threshold and the database compression information is not in the state to be compressed.

[0110] Module 630 is also used for:

[0111] When the participation status is the second participation status, the processing node is designated as the master node according to the preset specified rules.

[0112] In one embodiment, the information acquisition module 610 is used to acquire database compression information of the processing node;

[0113] Participation status determination module 620, used for:

[0114] Get the number of processing nodes in the distributed system;

[0115] If the number of processing nodes exceeds a third preset threshold, the participation status of multiple processing nodes whose database compression information is in a state of pending compression is determined as the first participation status.

[0116] In one implementation, the participation status determination module 620 is used for:

[0117] Based on local task information, obtain the task load of the processing node;

[0118] Based on the workload of multiple processing nodes, sort the tasks by workload.

[0119] Based on the sorting results, the participation status of a preset number of processing nodes is determined as the second participation status.

[0120] In one embodiment, there are multiple processing nodes, including master nodes and slave nodes, and the device 600 further includes:

[0121] The upgrade submodule is used by the master node to respond to an upgrade request and send an upgrade request to multiple slave nodes, so that the multiple slave nodes respond to the upgrade request and perform the upgrade.

[0122] The master node performs the upgrade only after confirming that all slave nodes have completed the upgrade.

[0123] In one implementation, the participation status determination module 620 is used for:

[0124] When performing an upgrade on a slave node, the slave node's participation status is determined to be the first participation status.

[0125] In one implementation, the upgrade submodule is used for:

[0126] Terminate log synchronization;

[0127] Perform database compression while the database compression information is in a pending state;

[0128] Once you have confirmed that database compression is complete, close the program to exit the service.

[0129] In one implementation, the upgrade submodule is further used for:

[0130] If the database compression information is not in a state of waiting to be compressed, database compression will be triggered based on a preset triggering strategy.

[0131] The functions of each module in each device in the embodiments of this application can be found in the corresponding descriptions in the above methods, and will not be repeated here.

[0132] Figure 7 A structural block diagram of an electronic device according to an embodiment of this application is shown. Figure 7 As shown, the electronic device includes a memory 710 and a processor 720. The memory 710 stores instructions that can be executed on the processor 720. When the processor 720 executes the instructions, it implements the business processing method based on the Raft consensus algorithm in the above embodiments. The number of memories 710 and processors 720 can be one or more. This electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or claimed herein.

[0133] The electronic device may also include a communication interface 730 for communicating with external devices and exchanging data. The devices are interconnected using different buses and can be mounted on a common motherboard or otherwise as needed. The processor 720 can process instructions executed within the electronic device, including instructions stored in or on memory to display graphical information of a GUI on an external input / output device (such as a display device coupled to the interface). In other embodiments, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple electronic devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). The bus can be divided into address buses, data buses, control buses, etc. For ease of illustration, Figure 7 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0134] Optionally, in a specific implementation, if the memory 710, processor 720, and communication interface 730 are integrated on a single chip, then the memory 710, processor 720, and communication interface 730 can communicate with each other through an internal interface.

[0135] It should be understood that the aforementioned processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. General-purpose processors can be microprocessors or any conventional processor. It is worth noting that the processor can be a processor supporting the Advanced Reduced Instruction Set Computing (RISC) machine (ARM) architecture.

[0136] This application provides a computer-readable storage medium (such as the memory 710 described above) that stores computer instructions, which, when executed by a processor, implement the method provided in this application.

[0137] Optionally, memory 710 may include a program storage area and a data storage area, wherein the program storage area may store the operating system and applications required for at least one function; the data storage area may store data created by the use of the electronic device for service processing based on the Raft consensus algorithm. Furthermore, memory 710 may include high-speed random access memory and may also include non-transient memory, such as at least one disk storage device, flash memory device, or other non-transient solid-state storage device. In some embodiments, memory 710 may optionally include memory remotely located relative to processor 720, and these remote memories can be connected to the electronic device for service processing based on the Raft consensus algorithm via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0138] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of those different embodiments or examples.

[0139] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "a plurality of" means two or more, unless otherwise explicitly specified.

[0140] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more (two or more) executable instructions for implementing a particular logical function or process. Furthermore, the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functionality involved.

[0141] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus or device (such as a computer-based system, a processor-included system or other system that can fetch and execute instructions from, an instruction execution system, apparatus or device).

[0142] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. All or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware, the program being stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiments.

[0143] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. This storage medium can be a read-only memory, a disk, or an optical disk, etc.

[0144] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various variations or substitutions within the technical scope disclosed in this application, and these should all be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A business processing method for a distributed system, characterized in that, include: Obtain local task information for the processing node; Based on the local task information, the participation status of the processing node in the distributed system is determined; wherein, the participation status includes: a first participation status of not participating in the designated master node and a second participation status of participating in the designated master node; If the participation status of the processing node is the first participation status, then the designation of the processing node as the master node is abandoned. The step of obtaining the local task information of the processing node includes: obtaining the log synchronization data volume and database compression information of the processing node; the log synchronization data volume is the deviation between the log index and the master node log index; Correspondingly, determining the participation status of the processing node in the distributed system based on the local task information includes: determining the participation status of the processing node as the first participation status when the amount of log synchronization data exceeds a first preset threshold and the database compression information is in a state to be compressed.

2. The method according to claim 1, characterized in that, The step of determining the participation status of the processing node in the distributed system based on the local task information further includes: determining the participation status of the processing node as the second participation status when the amount of log synchronization data is less than a second preset threshold and the database compression information is not in a state to be compressed. Correspondingly, the method further includes: When the participation state of the processing node is the second participation state, the processing node is designated as the master node according to a preset specified rule.

3. The method according to claim 1, characterized in that, The step of obtaining the local task information of the processing node includes: obtaining the database compression information of the processing node; Correspondingly, determining the participation status of the processing node based on the local task information includes: obtaining the number of processing nodes in the distributed system; When the number of processing nodes exceeds a third preset threshold, the participation status of multiple processing nodes that determine the database compression information to be in a state of pending compression is all in the first participation state.

4. The method according to claim 1, characterized in that, Determining the participation status of the processing node based on the local task information includes: Based on the local task information, the task volume of the processing node is obtained; Based on the workload of multiple processing nodes, sort the tasks by workload. Based on the sorting results, the participation status of a preset number of processing nodes is determined as the second participation status.

5. The method according to claim 1, characterized in that, The method includes multiple processing nodes, including master nodes and slave nodes, and further includes: In response to the upgrade request, the master node sends an upgrade request to multiple slave nodes, so that the multiple slave nodes respond to the upgrade request and perform the upgrade. The master node performs the upgrade after confirming that all the slave nodes have completed the upgrade.

6. The method according to claim 5, characterized in that, Determining the participation status of the processing node includes: When the slave node performs an upgrade, the slave node's participation status is determined to be the first participation status.

7. The method according to claim 5 or 6, characterized in that, The execution upgrade includes: Terminate log synchronization; When the database compression information is in a state of pending compression, database compression is performed; Once you have confirmed that database compression is complete, close the program to exit the service.

8. The method according to claim 7, characterized in that, The execution upgrade also includes: If the database compression information is not in a state to be compressed, database compression is triggered based on a preset triggering strategy.

9. A service processing device based on the Raft consensus algorithm, characterized in that, include: The information acquisition module is used to acquire local task information of the processing node; The participation status determination module is used to determine the participation status of the processing node in the distributed system based on the local task information. The participation states include: a first participation state of not participating in the designated master node and a second participation state of participating in the designated master node; A designated module is configured to abandon designating the processing node as the master node when the participation status of the processing node is the first participation status. The information acquisition module is further configured to: acquire the log synchronization data volume and database compression information of the processing node; the log synchronization data volume is the deviation between the log index and the master node log index; Correspondingly, the participation status determination module is further configured to: determine the participation status of the processing node as the first participation status when the amount of log synchronization data exceeds a first preset threshold and the database compression information is in a state to be compressed.

10. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-8.

11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed by a processor, implement the method as described in any one of claims 1-8.

12. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the steps of the method according to any one of claims 1-8.

Citation Information

Patent Citations

  • High-performance leader node election method and device of alliance chain, equipment and medium

    CN115865923A