Data processing method and device
By storing shard copies on multiple nodes in the storage cluster, and sharing the resource usage pressure through these nodes in the event of a failure, the problem of low resource usage upper limit when a node fails in the storage cluster is solved, and higher load balancing is achieved. and fault isolation capabilities.
Patent Information
- Application Number
- CN202410898927.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-10-29
AI Technical Summary
When a node fails in an existing storage cluster, it is difficult to effectively share the resource usage pressure, resulting in a low resource usage limit for a single node and insufficient fault isolation capabilities.
By storing the shard copy of a single node in the first group to multiple nodes in the second group, and when the first node fails, the nodes in the second group bear the resource usage pressure, using randomly generated storage order and copy storage The order evenly distributes shards and replicas to reduce the gap in the number of shards between nodes and improve load balancing.
It increases the upper limit of resource usage of a single node, reduces the limit of resource usage, enhances the fault isolation capability of sharding services, and improves the system's disaster recovery capability and load balancing effect.
Smart Images

Figure CN118860744A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the general field of data processing technology, and in particular to a data processing method and device. Background Art
[0002] Currently, there are two or more groups in a storage cluster, each of which includes two or more nodes, and each node in each group stores shards or copies of shards. Sharding refers to dividing a database or service into smaller, faster, and easier-to-manage parts. How to provide corresponding services through shards or copies of shards stored in each group is a technical problem that needs to be solved in this field. Summary of the invention
[0003] The present application provides a data processing method and device, which stores copies of shards of a single node in a first group in two or more nodes in a second group. In the event of a single node failure in the first group, the resource usage pressure of the service of the shard of the single node is borne by two or more nodes in the second group, thereby increasing the upper limit of resource utilization of a single node.
[0004] In a first aspect, the present application provides a data processing method, the method being used to provide services through a storage cluster, the storage cluster comprising a first group and a second group, the first group and the second group both comprising nodes, the method comprising:
[0005] storing two or more first shards in a first node included in the first group, and storing two or more copies of the first shards in two or more nodes included in the second group respectively;
[0006] When the first node is unavailable, services corresponding to two or more first shards are provided through two or more copies of the first shards.
[0007] It can be seen that in the present application, when the first node fails or other circumstances cause the first node to be in an unavailable state, two or more copies of the first shards stored by two or more nodes in the second group can be used to provide services corresponding to two or more first shards. The resource usage pressure of the first node is shared by two or more nodes in the second group. In order to avoid the resource usage pressure being shared to other nodes at this time, the resources of the other nodes themselves plus the shared resources exceed the upper limit of the available resources of the node itself, it is necessary to limit the resource usage rate of each node. The conventional practice is to share the resource usage pressure of a single node to a single node of another group, which means that the sum of the resource usage rates of the two nodes needs to be less than 100%, and the upper limit of the resource usage rate of each corresponding node can be 50%. However, the present application is to share the resource usage pressure of a single node to two or more nodes of another group, which means that the sum of the resource usage rates of three or more nodes needs to be less than 100%, and the upper limit of the resource usage rate of each corresponding node can be 67% or higher. It can be seen that the present application can reduce the restriction on the resource utilization rate of a single node while avoiding the situation where the resource utilization rate of other nodes exceeds the upper limit when the resource utilization pressure is shared to other nodes, thereby increasing the upper limit of the resource utilization rate of a single node.
[0008] In a feasible example, the two or more first shards are part or all of the two or more shards to be stored, and the two or more shards to be stored are shards that need to be stored in the nodes of the first group; before storing the two or more first shards in the first node included in the first group, and storing the copies of the two or more first shards in the two or more nodes included in the second group, the method also includes: randomly generating a first storage order in which the two or more shards to be stored are stored in the first group, and a second storage order in which the copies of the two or more shards to be stored are stored in the second group, the first storage order being different from the second storage order; storing the two or more shards to be stored in the nodes included in the first group based on the first storage order, and storing the two or more first shards in the first node; storing the copies of the two or more shards to be stored in the nodes included in the second group based on the second storage order, and storing the copies of the two or more first shards in the two or more nodes included in the second group.
[0009] In the present application, based on two randomly generated different storage orders, two or more shards to be stored are stored in the nodes included in the first group, and the copies of two or more shards to be stored are stored in the nodes included in the second group. This is beneficial in that when two or more first shards are directly or indirectly stored in the first node during the storage process, the copies of two or more first shards are respectively stored in the two or more nodes included in the second group. Thereby, the upper limit of the resource utilization rate of a single node can be increased.
[0010] In a feasible example, two or more shards to be stored are stored in nodes included in the first group based on a first storage order, including: based on the first storage order, two or more shards to be stored are stored in sequence in a second node among the nodes included in the first group, the second node being the node with the largest number of remaining storable shards among the nodes included in the first group each time a shard is stored.
[0011] In the present application, each time a shard is stored, the node with the largest number of remaining storable shards is selected for storage. In this way, during the continuous storage process, the number of remaining storable shards corresponding to the node with the largest number of remaining storable shards will gradually decrease, thereby gradually approaching the number of remaining allocatable shards of other nodes, and eventually the number of remaining storable shards between the nodes included in the first group will approach the same, so that two or more shards to be stored are evenly distributed to the nodes included in the first group, thereby achieving a load balancing effect.
[0012] In a feasible example, based on a first storage order, two or more shards to be stored are stored in sequence in a second node among the nodes included in a first group, including: determining a second shard from two or more shards to be stored according to the first storage order; determining a third node with the largest number of remaining storable shards in the first group; storing the second shard in the third node; determining a third shard that is one position after the second shard according to the first storage order; after updating the number of remaining storable shards in the third node, determining a fourth node with the largest number of remaining storable shards in the first group; storing the third shard in the fourth node, until two or more shards to be stored are stored in sequence in the second node in the first group.
[0013] In the present application, when each shard is stored through the above method, the remaining number of storable shards corresponding to each node is updated according to the storage results of the previously stored shards, which means that the remaining number of storable shards corresponding to each node is the latest each time the shards are stored, thereby improving the accuracy of determining the second node with the largest number of remaining storable shards when two or more shards to be stored are stored in sequence.
[0014] In a feasible example, after storing two or more shards to be stored in the nodes included in the first group based on the first storage order, the method also includes: if it is determined that among the nodes included in the first group, the difference between the number of shards in the fifth node and the number of shards in the sixth node is greater than the first preset difference, then the first target number of shards in the fifth node is transferred to the sixth node, so that the difference between the number of shards in the fifth node and the number of shards in the sixth node is not greater than the first preset difference, and the first target number is determined based on the first preset difference.
[0015] In the present application, according to the above method, shards are transferred between two nodes with a large difference in the number of shards. Specifically, the shards of the node with a large number of shards are transferred to the node with a small number of shards, thereby reducing the difference between the number of shards stored by any two nodes, thereby achieving a load balancing effect.
[0016] In a feasible example, the fifth shard is a shard in the first node except for the fourth shard and the sixth shard, the sixth shard is a shard corresponding to a copy in a target node included in the second group, and the target node is a node where the copy of the fourth shard is stored; in the case where the fifth shard in the first node is unavailable due to the fourth shard in the first node being in an unavailable state, after storing two or more copies of the first shard in two or more nodes included in the second group respectively, the method also includes: providing a service corresponding to the fifth shard based on the copy of the fifth shard.
[0017] In the present application, when the fifth shard in the first node is unavailable due to the fourth shard in the first node being in an unavailable state, the service of the fifth shard can still be provided based on the copy of the fifth shard, so that the service of the fifth shard will not be affected. However, in the same distribution mode corresponding to the conventional practice, the service of the shard of the first node corresponds to the service of the copy of a single node in another group. Then, when the service of the shard of the first node is in an unavailable state based on the unavailability of the fourth shard, the service of the copy of the single node in another group will also be unavailable due to the migration of the service of the fourth shard, thereby affecting the services of the shard of the first node. Therefore, the present application improves the fault isolation capability between shard services.
[0018] In a feasible example, after storing two or more shards to be stored in the nodes included in the first group based on the first storage order, the method also includes: if it is determined that among the nodes included in the first group, the difference between the first ratio corresponding to the seventh node and the first ratio corresponding to the eighth node is greater than the second preset difference, then the second target number of shards in the seventh node are transferred to the eighth node, so that the difference between the first ratio corresponding to the seventh node and the first ratio corresponding to the eighth node is not greater than the second preset difference, the first ratio is the ratio between the number of shards of the node and the total storage capacity of the shards of the node, and the first target number is determined based on the first preset difference.
[0019] In the present application, in view of the situation where it is difficult for heterogeneous nodes to determine whether there are too many or too few stored shards based on the number of shards of each node, the shard storage situation of each node can be reflected by the first ratio between the number of shards of the node and the total storage capacity of the shards of the node, and the two nodes in the first group whose first ratios have a large difference are processed for shard transfer, thereby reducing the difference in the first ratio between the two nodes, thereby achieving a load balancing effect.
[0020] In a feasible example, after storing two or more shards to be stored in the nodes included in the first group based on the first storage order, the method also includes: if it is determined that the second ratio between the number of target replicas stored by the ninth node included in the second group and the number of first shards stored by the first node is greater than a preset ratio, part of the replicas of the first shard stored by the ninth node is transferred to the tenth node included in the second group so that the second ratio is not greater than the preset ratio, and the tenth node is a node that has not previously stored a replica of the first shard.
[0021] In the present application, if the similarity between the copy stored in the ninth node and the first shard stored in the first node is too high, that is, if two or more copies of the first shard are too many in the ninth node, some copies of the target copy stored in the ninth node are transferred to other nodes. In this way, when the first node is unavailable, more nodes can share the resource usage pressure of the first node, thereby increasing the upper limit of the resource usage rate of a single node.
[0022] In a second aspect, the present application provides a data processing device, the device is used to provide a service through a cluster, the cluster includes a first group and a second group, the first group and the second group both include nodes, the device includes:
[0023] A storage unit, used to store two or more first shards in a first node included in the first group, and store two or more copies of the first shards in two or more nodes included in the second group respectively;
[0024] A processing unit is used to provide services corresponding to two or more first shards through two or more copies of the first shards when the first node is in an unavailable state.
[0025] In a third aspect, the present application provides an electronic device comprising a processor, a memory, and a communication interface. The processor, the memory, and the communication interface are interconnected and perform communication with each other. The memory stores executable program code, the communication interface is used for wireless communication, and the processor is used to call the executable program code stored in the memory to execute, for example, some or all of the steps described in any method of the first aspect.
[0026] In a fourth aspect, the present application provides a computer-readable storage medium, in which electronic data is stored. When the electronic data is executed by a processor, it is used to execute the electronic data to implement some or all of the steps described in the first aspect of the present application.
[0027] In a fifth aspect, the present application provides a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps described in the first aspect of the present application. The computer program product may be a software installation package. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the conventional technology, the drawings required for use in the embodiments or the conventional technology descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0029] Figure 1 A schematic diagram of the structure of a storage cluster provided in an embodiment of the present application;
[0030] Figure 2 A flowchart of a data processing method provided in an embodiment of the present application;
[0031] Figure 3 A schematic diagram of the structure of a dual-group storage cluster provided in an embodiment of the present application;
[0032] Figure 4 A schematic diagram of the structure of another dual-group storage cluster provided in an embodiment of the present application;
[0033] Figure 5 A block diagram of the functional units of a data processing device provided in an embodiment of the present application;
[0034] Figure 6 A block diagram of the functional units of another data processing device provided in an embodiment of the present application;
[0035] Figure 7 A structural block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0036] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0037] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps is not limited to the listed steps, but optionally includes steps that are not listed, or optionally includes other steps inherent to these processes, methods, products or devices.
[0038] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0039] See also Figure 1 , Figure 1 A schematic diagram of a storage cluster structure provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the storage cluster 100 includes a first group 101, a second group 102, and the like.
[0040] The first group 101 and the second group 102 both include two or more nodes. The two or more nodes included in the first group 101 store two or more shards to be stored corresponding to a complete service, and the two or more nodes included in the second group 102 store copies of the two or more shards to be stored. It can be understood that there is only a single copy of the shard to be stored, but there can be multiple copies, that is, the other groups included in the subsequent storage cluster 100 should also store copies of the two or more shards to be stored. A single node can correspond to a single server.
[0041] The present application stores two or more first shards of two or more shards to be stored in the first node included in the first group 101, and stores two or more first shards in two or more nodes included in the second group 102. In this way, when the first node is unavailable, the services corresponding to the two or more first shards can be provided through two or more copies of the first shards. In this way, when the first node of the first group fails, the resources required by the first node can be assumed by two or more nodes of the second group, thereby increasing the upper limit of the resource utilization rate of a single node. The resources may include bandwidth resources, CPU resources, shard resources, and the like.
[0042] Based on this, an embodiment of the present application provides a data processing method, and the embodiment of the present application is described in detail below in conjunction with the accompanying drawings.
[0043] See also Figure 2 , Figure 2 A flow chart of a data processing method provided in an embodiment of the present application, the method is used to provide services through the above storage cluster, such as Figure 2 As shown, the method comprises the following steps:
[0044] Step S201: store two or more first shards in a first node included in a first group, and store copies of two or more first shards in two or more nodes included in a second group, respectively.
[0045] According to the above steps, each of the two or more nodes included in the second group can store a partial copy of two or more copies of the first shard.
[0046] Step S202, when the first node is in an unavailable state, provide services corresponding to two or more first shards through two or more copies of the first shards.
[0047] In this way, when the first node fails or other circumstances cause the first node to be unavailable, two or more copies of the first shards stored in two or more nodes in the second group can be used to provide services corresponding to two or more first shards. The resource usage pressure of the first node is shared by two or more nodes in the second group, so that the restrictions on the resource usage rate of a single node can be reduced, thereby increasing the upper limit of the resource usage rate of a single node. It is understandable that a single shard can also independently provide the service corresponding to the shard.
[0048] In addition, in a feasible embodiment, the fifth shard is a shard in the first node except for the fourth shard and the sixth shard, the sixth shard is a shard corresponding to a copy in a target node included in the second group, and the target node is a node where the copy of the fourth shard is stored; in the case where the fifth shard in the first node is unavailable due to the fourth shard in the first node being in an unavailable state, after storing two or more copies of the first shard in two or more nodes included in the second group, respectively, the method also includes: providing a service corresponding to the fifth shard based on the copy of the fifth shard.
[0049] Among them, if the fourth shard is attacked by a bad request, even if the service corresponding to the fourth shard is migrated to the replica of the fourth shard, the replica of the fourth shard will still be attacked by the bad request, causing the first node storing the fourth shard to be unavailable, and the node storing the replica of the fourth shard will also be unavailable. If according to the existing fixed mode storage, the shards in the node storing the fourth shard and the replicas in the node storing the replica of the fourth shard will correspond to each other, then at this time, the shards in the node storing the fourth shard will all be unavailable, and the replicas in the node storing the replica of the fourth shard will also be unavailable. The services of the shards in the node storing the fourth shard are all affected.
[0050] In this embodiment, since two or more copies of the first shard are respectively stored in two or more nodes included in the second group, when the fourth shard is unavailable, resulting in the fifth shard in the first node being unavailable, the service of the fifth shard can still be provided through the copy of the fifth shard. Therefore, in this embodiment, there will be no situation where the services of the shards in the first node are all affected.
[0051] In the present application, when the fifth shard in the first node is unavailable due to the fourth shard in the first node being in an unavailable state, the service of the fifth shard can still be provided based on the copy of the fifth shard, so that the service of the fifth shard will not be affected. However, in the same distribution mode corresponding to the conventional practice, the service of the shard of the first node corresponds to the service of the copy of a single node in another group. Then, when the service of the shard of the first node is in an unavailable state based on the unavailability of the fourth shard, the service of the copy of the single node in another group will also be unavailable due to the migration of the service of the fourth shard, thereby affecting the services of the shard of the first node. Therefore, the present application improves the fault isolation capability between shard services.
[0052] The above storage steps are described in detail below:
[0053] In a feasible embodiment, the two or more first shards are part or all of the two or more shards to be stored, and the two or more shards to be stored are shards that need to be stored in the nodes of the first group; before storing the two or more first shards in the first node included in the first group, and storing the copies of the two or more first shards in the two or more nodes included in the second group, the method also includes: randomly generating a first storage order in which the two or more shards to be stored are stored in the first group, and a second storage order in which the copies of the two or more shards to be stored are stored in the second group, the first storage order being different from the second storage order; storing the two or more shards to be stored in the nodes included in the first group based on the first storage order, and storing the two or more first shards in the first node; storing the copies of the two or more shards to be stored in the nodes included in the second group based on the second storage order, and storing the copies of the two or more first shards in the two or more nodes included in the second group.
[0054] Among them, two or more shards to be stored can be obtained by dividing the data of a complete service, such as horizontal or vertical data division. The randomly generated first storage order should be different from the second storage order, which can be set according to the random generation algorithm during random generation. Exemplarily, the first storage order and the second storage order are randomly generated using a random seed, and the random seed corresponding to the generation of the first storage order is different from the random seed corresponding to the generation of the second storage order. Random seeds can be used to control the generation of random numbers. When generating random numbers, the random numbers generated by the same random seeds are the same. When the storage order is randomly generated for the first time, the current random seed can be determined according to the timestamp. Each subsequent time the storage order is randomly generated, static variables can be added to the random seed in turn to generate different random seeds.
[0055] For example, when storing two or more shards to be stored for the first group, if there are four shards to be stored at this time, they are named 1, 2, 3, and 4, and the first storage order corresponding to the four randomly generated shards to be stored is [1, 2, 3, 4], and the four shard data are stored in the nodes included in the first group in sequence based on the first storage order; when storing four shards to be stored for the second group, the second storage order corresponding to the four randomly generated shards to be stored is [2, 4, 3, 1], and the four shard data are stored in the nodes included in the second group in sequence based on the second storage order. It can be understood that each time different groups are stored in shards, the order of how to select corresponding nodes from the group to store shards or copies should be the same, so that on the basis of the difference between the first storage order and the second storage order, the distribution of two or more shards to be stored in the first group is different from the distribution of two or more copies of the shards to be stored in the second group.
[0056] Furthermore, when two or more shards to be stored are stored in the nodes included in the first group based on the first storage order, two or more first shards need to be stored in the first node, and when two or more copies of the shards to be stored are stored in the nodes included in the second group based on the second storage order, two or more copies of the first shards need to be stored in the two or more nodes included in the second group, respectively. Thus, when the first node is unavailable, the resource usage pressure of the shards of the first node can be shared by the two or more nodes of the second group.
[0057] In a specific embodiment, the number of shards with the highest similarity ranking between the first storage order and the second storage order is lower than a preset number, and the preset number is lower than the ratio between the number of two or more shards to be stored and the number of nodes in the first group. The similarity ranking means that there are copies of two or more adjacent shards in the first storage order, which are also adjacent in the second storage order, and the order between the two or more adjacent shards is also the same as the order between the two or more adjacent shards. For example, the first storage order is [1, 2, 3, 4], and the second storage order is [4, 2, 3, 1], then the copies of shards 2 and 3 that are adjacent in the first storage order are also the same in the second storage order, and the order between the two is also the same, then it can be determined that the number of shards with the highest similarity ranking between the two is 2.
[0058] In the present application, based on two randomly generated different storage orders, two or more shards to be stored are stored in the nodes included in the first group, and the copies of two or more shards to be stored are stored in the nodes included in the second group. This is beneficial in that when two or more first shards are directly or indirectly stored in the first node during the storage process, the copies of two or more first shards are respectively stored in the two or more nodes included in the second group. Thereby, the upper limit of the resource utilization rate of a single node can be increased.
[0059] Specifically, in a feasible embodiment, two or more shards to be stored are stored in nodes included in the first group based on a first storage order, including: based on the first storage order, two or more shards to be stored are stored in sequence in a second node among the nodes included in the first group, the second node being the node with the largest number of remaining storable shards among the nodes included in the first group each time a shard is stored.
[0060] Among them, in the scenario where two or more shards to be stored are stored in the nodes included in the first group according to the first storage order, each time a single shard is stored, the node with the largest number of remaining storable shards among the nodes included in the first group will be selected as the second node for storing the current shard, so that the shards are preferentially stored in the nodes with a larger number of remaining storable shards, thereby achieving an effect of evenly distributing two or more shards to be stored among the nodes included in the first group. If there are two or more second nodes, the storage priority of each node in the nodes included in the first group can also be set, so as to determine the second node for storage according to the storage priority. The number of remaining storable shards can refer to the number of storage units for storing shards included in a single node, that is, each storage unit can store one shard, and the storage unit can be a disk or other information carrier.
[0061] It is understandable that storing two or more copies of the shards to be stored in the nodes included in the second group based on the second storage order is also the same, that is, each time a single copy is allocated, the node with the largest number of remaining copies that can be stored is selected from the nodes included in the second group. No further details will be given here.
[0062] In the present application, each time a shard is stored, the node with the largest number of remaining storable shards is selected for storage. In this way, during the continuous storage process, the number of remaining storable shards corresponding to the node with the largest number of remaining storable shards will gradually decrease, thereby gradually approaching the number of remaining allocatable shards of other nodes, and eventually the number of remaining storable shards between the nodes included in the first group will approach the same, so that two or more shards to be stored are evenly distributed to the nodes included in the first group, thereby achieving a load balancing effect.
[0063] In addition, in a feasible embodiment, based on the first storage order, two or more shards to be stored are stored in sequence in the second node of the nodes included in the first group, including: determining the second shard from the two or more shards to be stored according to the first storage order; determining the third node with the largest number of remaining storable shards in the first group; storing the second shard in the third node; determining the third shard after the second shard according to the first storage order; after updating the number of remaining storable shards in the third node, determining the fourth node with the largest number of remaining storable shards in the first group; storing the third shard in the fourth node, until two or more shards to be stored are stored in sequence in the second node in the first group.
[0064] Among them, the number of remaining storable shards corresponding to the nodes included in the first group will be updated after each shard is stored. For example, when storing the second stored shard, it is necessary to update the number of remaining storable shards corresponding to the nodes included in the first group according to the storage result of the first stored shard. Similarly, when storing the third stored shard data, it is also necessary to update the number of remaining storable shards corresponding to the nodes included in the first group according to the storage result of the second stored shard, and so on, until two or more shards to be stored are stored in sequence in the second node in the first group.
[0065] It can be understood that the storage of the copies of the shards to be stored in the second group is also similar, and will not be elaborated here.
[0066] In the present application, when each shard is stored through the above method, the remaining number of storable shards corresponding to each node is updated according to the storage results of the previously stored shards, which means that the remaining number of storable shards corresponding to each node is the latest each time the shards are stored, thereby improving the accuracy of determining the second node with the largest number of remaining storable shards when two or more shards to be stored are stored in sequence.
[0067] Specifically, a small root heap can also be established for each node in the group, and the upper and lower limits of the number of shards that each node can store are initialized according to the remaining number of storable shards, and the shards are sorted according to the remaining number of storable shards; each time a single shard is stored, a node is taken from the small root heap to store the current shard. After the storage is completed, the remaining number of storable shards of the node is updated and the node is put back into the small root heap; until two or more shards to be stored are stored.
[0068] In addition, after the storage of two or more shard data is completed, the application also includes the following contents:
[0069] In a feasible embodiment, after storing two or more shards to be stored in the nodes included in the first group based on the first storage order, the method also includes: if it is determined that among the nodes included in the first group, the difference between the number of shards in the fifth node and the number of shards in the sixth node is greater than the first preset difference, then the first target number of shards in the fifth node is transferred to the sixth node, so that the difference between the number of shards in the fifth node and the number of shards in the sixth node is not greater than the first preset difference, and the first target number is determined based on the first preset difference.
[0070] Among them, after the storage of two or more shards to be stored is completed, or when the nodes of the first group need to be expanded later, it is possible to check whether there are two nodes in the first group with a large difference in the storage number of shards. If so, some shards in the fifth node with too many storage shards are transferred to the sixth node with too few storage shards, so that the shards stored in the nodes included in the first group are evenly distributed.
[0071] In addition, how to determine the fifth node and the sixth node is described in detail below:
[0072] Specifically, it is determined that among the nodes included in the first group, there is a first target difference greater than the first preset difference in the difference between the number of shards stored by any two nodes respectively. If the first target difference is determined to be single, the two nodes corresponding to the first target difference are directly determined to be the fifth node and the sixth node. If the first target difference is two or more, the second target difference with the largest value among the two or more first target differences is determined, and the two nodes corresponding to the second target difference are determined to be the fifth node and the sixth node. Further, if there are also two or more second target differences, the two nodes corresponding to any one of the two or more second target differences can be randomly determined to be the fifth node and the sixth node. Moreover, after the first target number of shards in the fifth node is transferred to the sixth node, it is also possible to recheck whether the fifth node and the sixth node still exist in the nodes included in the first group according to the above steps.
[0073] It can be seen that according to the above method, the fifth node and the sixth node are determined as the two nodes with the largest difference in the number of shard storage among the nodes included in the first group. Since the difference in the number of shard storage between these two nodes and other nodes is too large, after the shards are transferred between the two nodes, not only the difference in the number of shard storage between the two nodes is reduced, but also the difference in the number of shard storage with other nodes is reduced, thereby improving the efficiency of reducing the difference in the number of shards stored by any two nodes in the group.
[0074] For example, determine the node 1 and node 2 corresponding to the second target difference with the largest median value of two or more first target differences, and if it is determined that the number of shards in node 1 is greater than the number of shards in node 2, then transfer the first target number of shards in node 1 to node 2 according to the first target difference, so that the difference between the number of shards in node 1 and the number of shards in node 2 is less than the first preset difference. Subsequently, the shard storage status of the nodes included in the first group can be updated, and then determine whether the above situation exists.
[0075] Exemplarily, if there are three nodes in the current group, the number of shards in node 3 is 5, the number of shards in node 4 is 2, and the number of shards in node 5 is 4. At this time, it can be determined that the first difference between the number of shards in node 3 and the number of shards in node 4 is 3, the second difference between the number of shards in node 3 and the number of shards in node 5 is 1, and the third difference between the number of shards in node 5 and the number of shards in node 4 is 2. If the first preset difference is determined to be 1, it is determined that both the first difference 3 and the third difference 2 are greater than the first preset difference 1. At this time, it is determined that the value of the first difference 3 is the largest, and the first target number of shards in node 3 corresponding to the first difference 3 is transferred to node 4. The first target number can be determined according to the first difference 3, for example, the first target number 1 is determined according to the ratio of the first difference 3 to the number 2 of the two nodes. After the transfer is completed, it is determined that the number of shards in node 3 is 4, the number of shards in node 4 is 3, and the number of shards in node 5 is 4. It can be determined that among the three nodes, the difference between the number of shards stored in any two nodes does not exist in the first target difference that is greater than the first preset difference.
[0076] In the present application, according to the above method, shards are transferred between two nodes with a large difference in the number of shards. Specifically, the shards of the node with a large number of shards are transferred to the node with a small number of shards, thereby reducing the difference between the number of shards stored by any two nodes, thereby achieving a load balancing effect.
[0077] In addition, the current embodiment can also be implemented by the following method:
[0078] In a feasible embodiment, after storing two or more shards to be stored in the nodes included in the first group based on the first storage order, the method also includes: if it is determined that among the nodes included in the first group, the difference between the first ratio corresponding to the seventh node and the first ratio corresponding to the eighth node is greater than the second preset difference, then the second target number of shards in the seventh node are transferred to the eighth node, so that the difference between the first ratio corresponding to the seventh node and the first ratio corresponding to the eighth node is not greater than the second preset difference, the first ratio is the ratio between the number of shards of the node and the total storage capacity of the shards of the node, and the first target number is determined based on the first preset difference.
[0079] Among them, if there are heterogeneous nodes in the first group, that is, there are two nodes in the first group with different total shard storage capacities. At this time, it is difficult to determine whether a node has too many stored shards relative to other nodes, resulting in load imbalance, based on the difference between the number of shards. For example, if the total shard storage capacity of node 6 is 8, of which the number of stored shards is 4, the total shard storage capacity of node 7 is 4, but the number of shards it stores is 4. Although the number of shards stored by node 6 is the same as the number of shards stored by node 7, the number of shards stored by 4 has little impact on the total shard storage capacity of node 6 itself. The total shard storage capacity is different from the remaining shard storage capacity. The total shard storage capacity refers to the number of all storage units in the node for storing shards, and the remaining shard storage capacity refers to the number of storage units that can be used to store shards in addition to the storage units that have already stored shards.
[0080] Therefore, in the current situation, if the present application determines that among the nodes included in the first group, there is a difference between the first ratio corresponding to the seventh node and the first ratio corresponding to the eighth node that is greater than the second preset difference, then it is determined that there is a load imbalance between the seventh node and the eighth node. At this time, it is necessary to transfer the second target number of shards in the seventh node to the eighth node so that the difference between the first ratio corresponding to the seventh node and the first ratio corresponding to the eighth node is not greater than the second preset difference. The first ratio is the ratio between the number of shards of a node and the total storage capacity of the shards of the node.
[0081] Similarly, the following is a detailed description of how to determine the seventh node and the eighth node:
[0082] If there is at least one third target difference greater than the second preset difference in the difference between the first ratios corresponding to any two nodes in the nodes included in the first group, then the two nodes corresponding to the fourth target difference with the largest value in the at least one third target difference are determined to be the seventh node and the eighth node respectively; if the fourth target difference with the largest value is also two or more, then the two nodes corresponding to any one of the fourth target differences can be randomly determined to be the seventh node and the eighth node respectively. The second target quantity is determined based on the fourth target difference and the total capacity of the storable shards corresponding to the eleventh node and the twelfth node respectively.
[0083] Exemplarily, a third target number may be determined according to the product of the fourth target difference and the total capacity of storable shards corresponding to the eleventh node, and a fourth target number may be determined according to the product of the fourth target difference and the total capacity of storable shards corresponding to the twelfth node, and a fifth target number may be determined according to the sum of the third target number and the fourth target number, and the second target number may be determined according to the ratio of the fifth target number to 4. The reason why the second target number is determined according to the ratio of the fifth target number to 4 is that after two values are determined according to the product of the four target differences and the total capacity of storable shards corresponding to the two nodes, the two values are added together. Therefore, for the number to be transferred, the added value needs to be multiplied by one-half to determine the number of shards that the seventh node has more than the eighth node, and finally multiplied by one-half to determine the number of shards that need to be transferred.
[0084] In the present application, in view of the situation where it is difficult for heterogeneous nodes to determine whether there are too many or too few stored shards based on the number of shards of each node, the shard storage situation of each node can be reflected by the first ratio between the number of shards of the node and the total storage capacity of the shards of the node, and the two nodes in the first group whose first ratios have a large difference are processed for shard transfer, thereby reducing the difference in the first ratio between the two nodes, thereby achieving a load balancing effect.
[0085] In addition, in a feasible embodiment, after storing two or more shards to be stored in the nodes included in the first group based on the first storage order, the method also includes: if it is determined that the second ratio between the number of target replicas stored by the ninth node included in the second group and the number of first shards stored by the first node is greater than a preset ratio, part of the replicas of the first shard stored by the ninth node is transferred to the tenth node included in the second group so that the second ratio is not greater than the preset ratio, and the tenth node is a node that has not previously stored a replica of the first shard.
[0086] Among them, if it is determined that the similarity between the copies stored by the ninth node and the shards stored by the first node in the second group is too high, that is, the second ratio between the number of target copies stored by the ninth node and the number of first shards stored by the first node is greater than the preset ratio, part of the target copies stored in the ninth node can be transferred to the tenth node included in the second group, thereby reducing the similarity between the copies stored by the ninth node and the shards stored by the first node.
[0087] In the present application, if the similarity between the copy stored in the ninth node and the first shard stored in the first node is too high, that is, if two or more copies of the first shard are too many in the ninth node, some copies of the target copy stored in the ninth node are transferred to other nodes. In this way, when the first node is unavailable, more nodes can share the resource usage pressure of the first node, thereby increasing the upper limit of the resource usage rate of a single node.
[0088] It can be understood that the method shown in the above embodiment is applicable to the second group and other groups in the storage cluster.
[0089] The following is a summary of the data processing method in this application:
[0090] Obtain two or more shards to be stored, determine the first group currently being stored, randomly generate the first storage order of two or more shards to be stored, determine the fifth shard currently being stored according to the first storage order, and determine the second node with the largest number of remaining shards that can be stored from the first group currently being stored, and store the fifth shard in the second node; update the number of remaining shards that can be stored on the second node, and switch to the next shard to be stored, until two or more shards to be stored are stored in the first group currently being stored; after the storage is completed, check whether there are two nodes in the current first group with a large difference in the number of shards stored, if so, perform shard transfer processing on the two nodes, so that the difference between the number of shards stored by the two nodes is reduced. Switch to the next group to be stored (such as the second group), and repeat the above steps to store the copies of the two or more shards to be stored in the nodes included in the group, until all groups in the storage cluster complete the storage of shards or copies.
[0091] The following diagrams compare the conventional sharded data storage and the sharded data storage provided by this application:
[0092] For example, see Figure 3 , Figure 3 A schematic diagram of a dual-group storage cluster structure provided in an embodiment of the present application is shown in FIG. Figure 3 As shown, the dual-group storage cluster includes a third group 301 and a fourth group 302. The third group 301 and the fourth group 302 each include four nodes, and each node includes four storage units that can be used to store shards or replicas. The number of shards to be stored is 16, and the 16 shards are named 1, 2, 3...15, 16 in sequence, and the replicas of the shards are also named the same. After the shards to be stored are stored in the third group 301, the replicas of the shards to be stored are stored in the fourth group 302 according to a fixed pattern, presenting Figure 3Both nodes shown in are of the same distribution pattern.
[0093] It can be seen that if there is a fault in the thirteenth node 303 where the shards 1, 2, 3, and 4 in the third group 301 are located, it is necessary to migrate the services corresponding to the shards 1, 2, 3, and 4 in the thirteenth node 303 to the fourteenth node 304 where the replicas 1, 2, 3, and 4 in the third group 301 are located. Therefore, in order to ensure that the resources originally required by the fourteenth node 304 in the fourth group 302 plus the resources required for the services migrated from the thirteenth node 303 do not exceed the resource upper limit, it can be determined that the inequality is: p+p<1, p<50%, p is used to represent the resource utilization rate of a single node, so that the resource utilization rate of a single node does not exceed 50% of the resource upper limit. The resources shown in this application can be mainly for the resources used by the services provided by the primary shards. The primary shard refers to the shard that mainly provides write services, and the non-primary shard refers to the shard that mainly provides read services. It can be understood that the service migration shown in this embodiment refers to providing shard services through copies of shards, or providing shard copies of services through shards.
[0094] For example, see Figure 4 , Figure 4 A schematic diagram of the structure of another dual-group storage cluster provided in an embodiment of the present application, such as Figure 4 As shown, the dual-group storage cluster includes a fifth group 401 and a sixth group 402. The fifth group 401 and the sixth group 402 also include four nodes respectively, and each node includes four storage units that can be used to store shards or replicas. It can be seen that if the shards to be stored are stored in the fifth group 401 and the replicas of the shards to be stored are stored in the sixth group 402 according to the method shown in the present application, the present Figure 4 The two nodes shown are not in the same distribution mode, and the shards stored between any two nodes in the two groups are not exactly the same.
[0095] It can be seen that if there is a fault in the fifteenth node 403 where the shards 1, 2, 3, and 4 in the fifth group 401 are located, if at this time there are two shards 1 and 2 in the fifteenth node 403 as the main shards, the services provided by the two shards 1 and 2 in the fifteenth node 403 are migrated to the sixteenth node 404 and the seventeenth node 405 where the two copies 1 and 2 in the sixth group 402 are located, at this time, in order to ensure that the resources originally required by the sixteenth node 404 and the seventeenth node 405 in the sixth group 402 plus the resources required for the services migrated from the fifteenth node 403 do not exceed the resource upper limit, the inequality of the resource utilization rate of the three nodes can be determined as: p+p / 2<1, p<67%, thereby obtaining that the resource utilization rate of a single node does not exceed 67% of the resource upper limit. Therefore, based on the shard data storage method shown in this application, the upper limit of the resource utilization rate of a single node can be increased.
[0096] Further, if the number of nodes to which the shards on the faulty node are allocated is larger, the upper limit of the pressure that a single node can bear is greater. In the case of a single node failure, it can be determined that the inequality of the resource utilization rate of the node is: p + p / n < 1, and we get p < n / (n + 1), where n is used to represent the number of nodes in another group to which the resource usage pressure of a single node failure can be分摊. Similarly, in the case of two node failures, it can be determined that the inequality of the resource utilization rate of the node is: p + 2*p / n < 1, and we get p < n / (n + 2). At this time, the limit of n needs to be determined. Since the resources shown in this application are mainly for the resources used by the services provided by the primary shards or primary replicas, then n can be determined by the number of primary shards or primary replicas M in a single group, and can also be determined by the total number of nodes N in another group to which it needs to be分摊. Thus, it can be determined that n = min(M, N).
[0097] Since a single group of nodes in the storage cluster stores two or more shards or replicas to be allocated corresponding to a complete service, and for the primary shards or primary replicas, there needs to be a primary shard providing write service for each of the two or more shards to be allocated in a storage cluster. That is, the write service can be provided by the replicas of the shards instead of the shards. For example, the first group includes shards 1, 2, 3, 4, and the second group includes replicas 1, 2, 3, 4 as well. If it is required that shards 1 and 2 in the first group provide write services, and 3 and 4 are not required to provide write services, then it is required that replicas 3 and 4 included in the second group provide write services, and replicas 1 and 2 can not provide write services.
[0098] And in order to make the distribution of the write service more uniform, half of the shards in the first group need to have the ability to provide write services, and the corresponding replicas of the other half of the shards in the second group also need to have the ability to provide write services. Corresponding to a single node in a single group, half of the shards in a single node also need to have the ability to provide write services. In this way, the number of primary shards or primary replicas M = the number of shards / (2*N). Usually, the number of shards is 128, 256, 512, 1024, 2048, etc. If the number of shards is taken as 128, it can be determined that n = min{64 / N, N}, and the maximum value of n at this time can be obtained as 8. Substituting it into the above inequality of the resource utilization rate of the node, it can be determined that when one node is faulty, p < 88.9%, and when two nodes are faulty, p < 80%. In other words, when the resource utilization rate of a single node is less than 88.9%, it can tolerate the failure of one node; when the resource utilization rate of a single node is less than 80%, it can tolerate the failure of two nodes. The upper limit of the single-machine resource usage for tolerating a single node failure is increased from 50% to 88.9%, enabling a single node to use more resources with low risk.
[0099] In addition, if the status of the shards in the node is abnormal due to external factors, such as bad requests similar to attacks that cause the overall service of the node to be abnormal, or even cause the node to completely crash, the services of the shards on the node after the crash need to be migrated to other nodes. Since the current crash is caused by external factors, the services of the replicas of the shards of the migrated node will also face the same situation as the shards of the node before the migration, and will be attacked to abnormal service status until the node crashes. In this way, the services are repeatedly migrated, and the shards on the node will be affected.
[0100] like Figure 3 As shown, if shard 1 in the thirteenth node 303 is attacked by a bad request, after the thirteenth node 303 is affected, the services corresponding to shards 1, 2, 3, and 4 in the thirteenth node 303 will be migrated to the fourteenth node 304 where the replicas 1, 2, 3, and 4 of the shards in the fourth group 302 are located. However, after migrating to the fourteenth node 304, shard 1 will still be attacked by the bad request, causing the services of shards 1, 2, 3, and 4 to be repeatedly migrated between the thirteenth node 303 and the fourteenth node 304. As a result, the number of services of the affected shards is 4, accounting for 1 / 4 of the services of the entire shards.
[0101] like Figure 4 As shown, if the shard 1 in the fifteenth node 403 is attacked by a bad request, after the fifteenth node 403 is affected, the services corresponding to the shards 1, 2, 3, and 4 in the fifteenth node 403 will be migrated to the four nodes in the sixth group 402, among which the service of shard 1 is migrated to the replica 1 in the sixteenth node 404, and the services of shards 2, 3, and 4 are migrated to the replicas 2, 3, and 4 in the other three nodes, thereby effectively isolating the fault. After the migration, shard 1 will still be attacked by a bad request on the sixteenth node 404. At this time, the services of replicas 5, 9, and 13 in the sixteenth node 404 are also migrated to the shards of the other three nodes in the fifth group 401, and are also effectively isolated. Finally, the number of services of the shards affected in the storage cluster is 1, accounting for 1 / 16 of the services of the entire shard.
[0102] Assuming that the number of shards is S, the number of nodes in a single group is N, and the number of shards on a single node is S / N, the services of the shards on a single node in the fixed storage mode will all be affected, and the impact rate is S / N / S=1 / N. However, in the storage method shown in the present application, the number of services of the affected shards is the ratio between the number of shards of a single node and the number of nodes in another group, that is, S / N / N=S / (N^2), which means that after a single node is attacked by a bad request and migrated, at least S / (N^2) copies of the shards are still on the same node in another group. In other words, the services of S / (N^2) shards will be affected by the attack, making the impact rate S / (N^2) / S=1 / (N^2). Therefore, the storage method shown in the present application reduces the impact rate of the sharded services from 1 / N to 1 / (N^2).
[0103] In summary, according to the data processing method shown in the present application, while improving the disaster recovery capability of the system, the upper limit of resource utilization of a single node is increased, and the fault isolation capability of the system is enhanced.
[0104] In accordance with the above-mentioned embodiments, please refer to Figure 5 , Figure 5 A block diagram of the functional units of a data processing device provided in an embodiment of the present application, such as Figure 5 As shown, the data processing device 50 includes:
[0105] A storage unit 501 is used to store two or more first shards in a first node included in a first group, and store two or more copies of the first shards in two or more nodes included in a second group respectively;
[0106] The processing unit 502 is used to provide services corresponding to two or more first shards through two or more copies of the first shards when the first node is in an unavailable state.
[0107] In a feasible embodiment, the two or more first shards are part or all of the two or more shards to be stored, and the two or more shards to be stored are shards that need to be stored in the nodes of the first group; before the storage unit 501 is used to store the two or more first shards in the first node included in the first group, and store the copies of the two or more first shards in the two or more nodes included in the second group, it is also used to: randomly generate a first storage order in which the two or more shards to be stored are stored in the first group, and a second storage order in which the copies of the two or more shards to be stored are stored in the second group; by storing the two or more shards to be stored in the nodes included in the first group based on the first storage order, the two or more first shards are stored in the first node; by storing the copies of the two or more shards to be stored in the nodes included in the second group based on the second storage order, the copies of the two or more first shards are stored in the two or more nodes included in the second group.
[0108] In a feasible embodiment, in terms of storing two or more shards to be stored in the nodes included in the first group based on the first storage order, the storage unit 501 is specifically used to: based on the first storage order, store the two or more shards to be stored in sequence in the second node among the nodes included in the first group, the second node being the node with the largest number of remaining storable shards among the nodes included in the first group each time a shard is stored.
[0109] In a feasible embodiment, in terms of storing two or more shards to be stored in sequence in the second node of the nodes included in the first group based on the first storage order, the storage unit 501 is specifically used to: determine the second shard from the two or more shards to be stored according to the first storage order; determine the third node with the largest number of remaining storable shards in the first group; store the second shard in the third node; determine the third shard after the second shard according to the first storage order; after updating the number of remaining storable shards in the third node, determine the fourth node with the largest number of remaining storable shards in the first group; store the third shard in the fourth node, until two or more shards to be stored are stored in sequence in the second node in the first group.
[0110] In a feasible embodiment, the storage unit 501 is also used to store two or more shards to be stored in the nodes included in the first group based on the first storage order. If it is determined that among the nodes included in the first group, the difference between the number of shards in the fifth node and the number of shards in the sixth node is greater than the first preset difference, the shards of the first target number in the fifth node are transferred to the sixth node so that the difference between the number of shards in the fifth node and the number of shards in the sixth node is not greater than the first preset difference, and the first target number is determined based on the first preset difference.
[0111] In a feasible embodiment, the fifth shard is a shard in the first node except for the fourth shard and the sixth shard, the sixth shard is a shard corresponding to a copy in a target node included in the second group, and the target node is a node where the copy of the fourth shard is stored; when the fifth shard in the first node is unavailable due to the fourth shard in the first node being in an unavailable state, the processing unit 502 is also used to provide a service corresponding to the fifth shard according to the copy of the fifth shard after the storage unit 501 stores two or more copies of the first shard in two or more nodes included in the second group respectively.
[0112] In a feasible embodiment, the storage unit 501 is also used to store two or more shards to be stored in the nodes included in the first group based on the first storage order. If it is determined that among the nodes included in the first group, the difference between the first ratio corresponding to the seventh node and the first ratio corresponding to the eighth node is greater than the second preset difference, then the second target number of shards in the seventh node are transferred to the eighth node, so that the difference between the first ratio corresponding to the seventh node and the first ratio corresponding to the eighth node is not greater than the second preset difference, the first ratio is the ratio between the number of shards of the node and the total storage capacity of the shards of the node, and the first target number is determined based on the first preset difference.
[0113] In a feasible embodiment, the storage unit 501 is also used to, after storing two or more shards to be stored in the nodes included in the first group based on the first storage order, if it is determined that the second ratio between the number of target copies stored by the ninth node included in the second group and the number of first shards stored by the first node is greater than a preset ratio, then part of the copies of the first shard stored by the ninth node is transferred to the tenth node included in the second group so that the second ratio is not greater than the preset ratio, and the tenth node is a node that has not previously stored a copy of the first shard.
[0114] It can be understood that since the method embodiment and the device embodiment are different presentation forms of the same technical concept, the content of the method embodiment part in this application should be synchronously adapted to the device embodiment part and will not be repeated here.
[0115] In the case of an integrated unit, such as Figure 6 As shown, Figure 6 This is a block diagram of the functional units of another data processing device provided in an embodiment of the present application. Figure 6 In the embodiment, the data processing device 50 includes: a processing module 612 and a communication module 611. The processing module 612 is used to control and manage the actions of the data processing device, for example, the steps of the storage unit 501 and the processing unit 502, and / or other processes for executing the technology described herein. The communication module 611 is used to support the interaction between the data processing device and other devices. Figure 6 As shown, the data processing device 50 may further include a storage module 613, and the storage module 613 is used to store program codes and data of the data processing device.
[0116] Among them, the processing module 612 can be a processor or a controller, for example, a central processing unit (CPU), a general processor, a digital signal processor (DSP), an ASIC, an FPGA or other programmable logic device, a transistor logic device, a hardware component or any combination thereof. It can implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements a computing function, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like. The communication module 611 can be a transceiver, an RF circuit or a communication interface, and the like. The storage module 613 can be a memory.
[0117] Among them, all relevant contents of each scenario involved in the above method embodiment can be referred to the functional description of the corresponding functional module, and will not be repeated here. The above data processing device 50 can execute the above Figure 2 The data processing method shown.
[0118] The above embodiments can be implemented in whole or in part by software, hardware, firmware or any other combination. When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When a computer instruction or computer program is loaded or executed on a computer, a process or function according to an embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. Computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired or wireless means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center containing one or more available media sets. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state hard disk.
[0119] Figure 7 This is a structural block diagram of an electronic device provided in an embodiment of the present application. Figure 7 As shown, the electronic device 700 may include one or more of the following components: a processor 701, a memory 702 and a communication interface 703. The processor 701, the memory 702 and the communication interface 703 are interconnected and perform communication work with each other, wherein the memory 702 may store one or more computer programs, and the one or more computer programs may be configured to implement the methods described in the above embodiments when executed by one or more processors 701.
[0120] The processor 701 may include one or more processing cores. The processor 701 uses various interfaces and lines to connect the various parts of the entire electronic device 700, and executes various functions and processes data of the electronic device 700 by running or executing instructions, programs, code sets or instruction sets stored in the memory 702, and calling data stored in the memory 702. Optionally, the processor 701 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 701 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processor (Graphics Processing Unit, GPU) and a modem. It is understandable that the above-mentioned modem may not be integrated into the processor 701, and may be implemented separately through a communication chip.
[0121] The memory 702 may include a random access memory (RAM) or a read-only memory (ROM). The memory 702 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 702 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc. The data storage area may also store data created by the electronic device 700 during use, etc.
[0122] It is understandable that the electronic device 700 may include more or fewer structural elements than those in the above structural block diagram, for example, including a power module, physical buttons, a WiFi (Wireless Fidelity) module, a speaker, a Bluetooth module, a sensor, etc., which are not limited here.
[0123] The electronic device 700 may be a part of the storage cluster 100 or a device independent of the storage cluster 100 .
[0124] An embodiment of the present application provides a computer-readable storage medium, wherein program data is stored in the computer-readable storage medium, and when the program data is executed by a processor, it is used to execute part or all of the steps of any one of the data processing methods recorded in the above method embodiments.
[0125] The present application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps of any data processing method described in the above method embodiment. The computer program product may be a software installation package.
[0126] It should be noted that, for the method embodiments of any of the aforementioned data processing methods, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the present application.
[0127] Although the present application is described herein in conjunction with various embodiments, in the process of implementing the claimed application, those skilled in the art may understand and implement other variations of the disclosed embodiments by viewing the drawings, the disclosure, and the appended claims. In the claims, the word "comprising" does not exclude other components or steps, and "a" or "one" does not exclude multiple situations. Certain measures are recorded in different dependent claims, but this does not mean that these measures cannot be combined to produce good results.
[0128] A person skilled in the art can understand that all or part of the steps in the various methods of the method embodiments of any of the above-mentioned data processing methods can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory, and the memory can include: a flash drive, a read-only memory (English: Read-Only Memory, abbreviated as: ROM), a random access memory (English: Random Access Memory, abbreviated as: RAM), a disk or an optical disk, etc.
[0129] The embodiments of the present application are introduced in detail above. Specific examples are used herein to illustrate the principle and implementation method of a data processing method and device of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for a person skilled in the art, according to the idea of a data processing method and device of the present application, there may be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
[0130] The present application is described with reference to the flowcharts and / or block diagrams of the methods, hardware products, and computer program products of the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0131] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0132] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0133] It can be understood that any product that is controlled or configured to execute the processing method of the flowchart described in a method embodiment of a data processing method of the present application, such as the terminal and computer program product in the above flowchart, falls within the scope of the related products described in the present application.
[0134] Obviously, those skilled in the art can make various changes and modifications to the data processing method and device provided by the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A data processing method, It is characterized in that The method is used to provide services through a storage cluster, the storage cluster includes a first group and a second group, the first group and the second group both include nodes, and the method includes: storing two or more first shards in a first node included in the first group, and storing copies of the two or more first shards in two or more nodes included in the second group respectively; When the first node is in an unavailable state, services corresponding to the two or more first shards are provided through the replicas of the two or more first shards.
2. The method according to claim 1, It is characterized in that The two or more first shards are part or all of the two or more shards to be stored, and the two or more shards to be stored are shards that need to be stored in the nodes of the first group; The storing of the two or more first shards in the first node included in the first group, and storing the copies of the two or more first shards in two or more nodes included in the second group, respectively, includes: Randomly generate a first storage order in which the two or more to-be-stored shards are stored in the first group, and a second storage order in which the copies of the two or more to-be-stored shards are stored in the second group, wherein the first storage order is different from the second storage order; By storing the two or more to-be-stored shards in the nodes included in the first group based on the first storage order, the two or more first shards are stored in the first node; By storing the copies of the two or more shards to be stored in the nodes included in the second group based on the second storage order, the copies of the two or more first shards are respectively stored in the two or more nodes included in the second group.
3. The method according to claim 2, It is characterized in that The storing the two or more to-be-stored shards in the nodes included in the first group based on the first storage order includes: Based on the first storage order, the two or more shards to be stored are stored in sequence in the second node among the nodes included in the first group, and the second node is the node with the largest number of shards remaining to be stored among the nodes included in the first group each time a shard is stored.
4. The method according to claim 3, It is characterized in that The storing, based on the first storage order, the two or more shards to be stored in sequence in a second node among the nodes included in the first group includes: Determine a second shard from the two or more shards to be stored according to the first storage order; Determine a third node with the largest number of shards remaining in the first group; Storing the second shard on the third node; Determine a third fragment that is one digit after the second fragment according to the first storage order; After updating the number of remaining storable shards in the third node, determining a fourth node having the largest number of remaining storable shards in the first group; The third shard is stored in the fourth node until the two or more shards to be stored are sequentially stored in the second node in the first group.
5. The method according to any one of claims 2 to 4, It is characterized in that After storing the two or more to-be-stored shards in the nodes included in the first group based on the first storage order, the method further includes: If it is determined that among the nodes included in the first group, the difference between the number of shards in the fifth node and the number of shards in the sixth node is greater than the first preset difference, the first target number of shards in the fifth node is transferred to the sixth node so that the difference between the number of shards in the fifth node and the number of shards in the sixth node is not greater than the first preset difference, and the first target number is determined based on the first preset difference.
6. The method according to any one of claims 1 to 5, It is characterized in that The fifth shard is a shard in the first node except the fourth shard and the sixth shard, the sixth shard is a shard corresponding to a replica in a target node included in the second group, and the target node is a node where the replica of the fourth shard is stored; In a case where the fifth shard in the first node is unavailable due to the fourth shard in the first node being in an unavailable state, after storing the copies of the two or more first shards in the two or more nodes included in the second group, the method further includes: A service corresponding to the fifth shard is provided according to the copy of the fifth shard.
7. The method according to any one of claims 2 to 4, It is characterized in that After storing the two or more to-be-stored shards in the nodes included in the first group based on the first storage order, the method further includes: If it is determined that among the nodes included in the first group, the difference between the first ratio corresponding to the seventh node and the first ratio corresponding to the eighth node is greater than the second preset difference, the second target number of shards in the seventh node are transferred to the eighth node so that the difference between the first ratio corresponding to the seventh node and the first ratio corresponding to the eighth node is not greater than the second preset difference, the first ratio is the ratio between the number of shards of a node and the total storage capacity of the shards of the node, and the first target number is determined based on the first preset difference.
8. The method according to any one of claims 2 to 5, It is characterized in that After storing the two or more to-be-stored shards in the nodes included in the first group based on the first storage order, the method further includes: If it is determined that the second ratio between the number of target copies stored by the ninth node included in the second group and the number of first shards stored by the first node is greater than a preset ratio, part of the copies of the first shard stored by the ninth node is transferred to the tenth node included in the second group so that the second ratio is not greater than the preset ratio. The tenth node is a node that has not previously stored a copy of the first shard.
9. A data processing device, It is characterized in that The device is used to provide services through a cluster, the cluster includes a first group and a second group, the first group and the second group both include nodes, and the device includes: A storage unit, configured to store two or more first shards in a first node included in the first group, and store copies of the two or more first shards in two or more nodes included in the second group respectively; A processing unit is used to provide services corresponding to the two or more first shards through copies of the two or more first shards when the first node is in an unavailable state.
10. An electronic device, It is characterized in that The device comprises: A processor, a memory, and a communication interface, wherein the processor, the memory, and the communication interface are connected to each other and perform communication work between them; The memory stores executable program code, and the communication interface is used for wireless communication; The processor is used to call the executable program code stored in the memory to execute the method according to any one of claims 1-8.
11. A computer-readable storage medium, It is characterized in that A computer program for electronic data exchange is stored, wherein the computer program enables a computer to execute the method according to any one of claims 1 to 8.
Citation Information
Cited By
Data query method based on cloud search service, medium, equipment and product
CN121116971A
