Load balancing method and apparatus for distributed system, and electronic device and medium
By performing offset-based shard migration in a distributed system, the problem of reduced efficiency of computing and storage units caused by large shard concentration is solved, achieving load balancing and efficient request processing.
Patent Information
- Application Number
- PCT/CN2025/098749
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-07-24
- Filing Date
- 2025-06-03
- Publication Date
- 2026-01-29
AI Technical Summary
In existing technologies, sharding based on the disk utilization of computing storage units can easily lead to some large shards being concentrated in a certain computing storage unit, reducing the efficiency of processing requests and even causing distributed system failures.
By performing index changes on compute storage nodes and then migrating shards based on the first, second, and third offsets, the number of shards, the total number of shards, and the utilization of storage space on each compute storage node are balanced.
It achieves load balancing in the distributed system, improves the efficiency of computing and storage nodes in processing requests, and ensures the stability and performance of the system.
Smart Images

Figure CN2025098749_29012026_PF_FP_ABST
Abstract
Description
Distributed system load balancing method and device, electronic equipment and medium
[0001] Related applications
[0002] The present application claims priority to the Chinese patent application No. 202410997429.6, filed on July 24, 2024, and entitled "Distributed system load balancing method and device, electronic equipment and medium", the contents of which are hereby incorporated by reference in its entirety. TECHNICAL FIELD
[0003] The present disclosure relates to the technical field of data network, and in particular, to a distributed system load balancing method, device, electronic equipment and medium. BACKGROUND
[0004] A distributed system includes a scheduling node and multiple independent computing storage nodes. An index is a multi-field data body (such as a data table) to be computed and stored. The index is divided into shards by the scheduling node and stored on each computing storage node for computation and storage. To ensure the performance state of the distributed system, a load balancing algorithm is generally used to determine the number of shards allocated to each computing storage unit.
[0005] One of the existing load balancing algorithms allocates shards to each computing storage unit based on the disk usage of the computing storage unit. That is, when allocating shards of the index, shards are preferentially allocated to computing storage units with smaller disk usage. However, this method can cause some relatively large shards to be relatively concentrated in a computing storage unit, and the computing storage unit can reduce the efficiency of processing requests due to the concentration of relatively large shards, and in severe cases, can even cause the entire distributed system to fail. How to achieve load balancing of the distributed system while improving the efficiency of the computing storage unit in processing requests is a problem to be discussed and solved at present. SUMMARY
[0006] The present disclosure provides a distributed system load balancing method, device, electronic equipment and medium.
[0007] According to an aspect of the present disclosure, a distributed system load balancing method is provided, applied to a scheduling node in a distributed system, the distributed system including the scheduling node and multiple computing storage nodes, an index stored in the distributed system being divided into shards and stored in the multiple computing storage nodes, the index being a multi-field data body to be computed and stored, the distributed system load balancing method comprising:
[0008] In response to an index change request, performing index change on the multiple computing storage nodes;
[0009] determine a first offset of each of the computing storage nodes after the index change, the first offset being an offset of a number of shards of a single index stored by the computing storage node relative to an average number of shards of the single index stored by each of the computing storage nodes;
[0010] determine a second offset of each of the computing storage nodes after the index change, the second offset being an offset of a total number of shards stored by the computing storage node relative to an average total number of shards stored by each of the computing storage nodes;
[0011] determine a third offset of each of the computing storage nodes after the index change, the third offset being an offset of a storage space utilization of the computing storage node relative to an average storage space utilization of each of the computing storage nodes; and
[0012] migrate the shards on the plurality of computing storage nodes based on the first offset, the second offset, and the third offset, such that the first offset, the second offset, and the third offset of each of the computing storage nodes after the migration are less than a first threshold, a second threshold, and a third threshold, respectively.
[0013] According to an aspect of the present disclosure, there is provided a distributed system load balancing apparatus applied to a scheduling node in a distributed system, the distributed system comprising the scheduling node and a plurality of computing storage nodes, an index stored in the distributed system being decomposed into shards stored in the plurality of computing storage nodes, the index being a multi-field data body to be computed and stored, the distributed system load balancing apparatus comprising:
[0014] a response unit configured to perform an index change on the plurality of computing storage nodes in response to an index change request;
[0015] a first determination unit configured to determine a first offset of each of the computing storage nodes after the index change, the first offset being an offset of a number of shards of a single index stored by the computing storage node relative to an average number of shards of the single index stored by each of the computing storage nodes; determine a second offset of each of the computing storage nodes after the index change, the second offset being an offset of a total number of shards stored by the computing storage node relative to an average total number of shards stored by each of the computing storage nodes; determine a third offset of each of the computing storage nodes after the index change, the third offset being an offset of a storage space utilization of the computing storage node relative to an average storage space utilization of each of the computing storage nodes; and
[0016] a migration unit, configured to migrate the shards on the plurality of compute storage nodes based on the first offset, the second offset and the third offset, so that after the migration, the first offset on each of the compute storage nodes is less than a first threshold, the second offset is less than a second threshold, and the third offset is less than a third threshold.
[0017] According to an aspect of the present disclosure, there is provided an electronic device comprising a memory storing a computer program and a processor, wherein the processor implements the distributed system load balancing method as described above when executing the computer program.
[0018] According to an aspect of the present disclosure, there is provided a computer readable storage medium storing a computer program, wherein the computer program is executed by a processor to implement the distributed system load balancing method as described above.
[0019] According to an aspect of the present disclosure, there is provided a computer program product comprising a computer program, wherein the computer program is read and executed by a processor of a computer device, so that the computer device executes the distributed system load balancing method as described above.
[0020] Other features and advantages of the present disclosure will be set forth in the following description, and in part will be apparent from the description, or can be learned by practice of the present disclosure. The objects and other advantages of the present disclosure will be realized and attained by the structure particularly pointed out in the description. BRIEF DESCRIPTION OF DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments will be briefly introduced as follows. Obviously, the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained from the disclosed drawings without creative labor.
[0022] FIG. 1A-FIG. 1B are architecture diagrams of the distributed system load balancing method according to an embodiment of the present disclosure;
[0023] FIG. 2A-FIG. 2B are application scenario diagrams of the distributed system load balancing method according to an embodiment of the present disclosure;
[0024] FIG. 3 is a general flowchart of the distributed system load balancing method according to an embodiment of the present disclosure;
[0025] FIG. 4A is a diagram of shards of various indexes in a distributed system according to an embodiment of the present disclosure;
[0026] FIG. 4B is a schematic diagram of index decomposition into shards and storage in multiple compute storage nodes, according to an embodiment of the present disclosure;
[0027] FIG. 5A is a schematic diagram of migration of shards on compute storage nodes, according to an embodiment of the present disclosure;
[0028] FIG. 5B is a schematic diagram of shards stored by compute storage nodes after performing migration of shards, according to an embodiment of the present disclosure;
[0029] FIG. 6 is a detailed flow diagram of performing index change on multiple compute storage nodes in response to an index change request, according to an embodiment of the present disclosure;
[0030] FIG. 7A-7B are schematic diagrams of performing index change on multiple compute storage nodes in response to an index allocation request for a target index, according to an embodiment of the present disclosure;
[0031] FIG. 8A-8B are schematic diagrams of performing index change on multiple compute storage nodes in response to an index deletion request for a target index, according to an embodiment of the present disclosure;
[0032] FIG. 9 is a detailed flow diagram of splitting a target index into multiple shards, according to an embodiment of the present disclosure;
[0033] FIG. 10 is a schematic diagram of determining a number of shards based on an index size of a target index, an average storage capacity, and an average storage space utilization, according to an embodiment of the present disclosure;
[0034] FIG. 11 is a detailed flow diagram of performing migration of shards on multiple compute storage nodes based on a first offset, a second offset, and a third offset, according to an embodiment of the present disclosure;
[0035] FIG. 12 is a schematic diagram of performing migration of shards on multiple compute storage nodes based on a first offset, a second offset, and a third offset, according to an embodiment of the present disclosure;
[0036] FIG. 13 is a detailed flow diagram of performing migration of shards on multiple compute storage nodes based on a first offset, a second offset, and a third offset for an index traversed to, according to an embodiment of the present disclosure;
[0037] FIG. 14 is a detailed flow diagram of performing a first sorting of multiple compute storage nodes based on a first offset, a second offset, and a third offset, according to an embodiment of the present disclosure;
[0038] FIG. 15 is a schematic diagram of performing a first sorting of multiple compute storage nodes based on a first offset, a second offset, and a third offset, according to an embodiment of the present disclosure;
[0039] FIG. 16 is a specific flow chart of first sorting a plurality of computing storage nodes based on weighting and from large to small order according to an embodiment of the present disclosure;
[0040] FIG. 17 is a schematic diagram of first sorting a plurality of computing storage nodes based on weighting and from large to small order according to an embodiment of the present disclosure;
[0041] FIG. 18 is a specific flow chart of migrating shards on a traversed computing storage node to a computing storage node with a first offset smaller than the traversed computing storage node according to an embodiment of the present disclosure;
[0042] FIG. 19 is a schematic diagram of initializing a first target migration computing storage node as a first computing storage node in a second order according to an embodiment of the present disclosure;
[0043] FIGS. 20A-20B are schematic diagrams of migrating a first target shard from a traversed computing storage node to a first target migration computing storage node according to an embodiment of the present disclosure;
[0044] FIG. 21 is a specific flow chart of selecting a first target shard on a traversed computing storage node according to an embodiment of the present disclosure;
[0045] FIG. 22 is a schematic diagram of obtaining shard sizes of each shard on a traversed computing storage node according to an embodiment of the present disclosure;
[0046] FIG. 23 is a specific flow chart of migrating shards on a traversed computing storage node to a computing storage node with a second offset smaller than the traversed computing storage node according to an embodiment of the present disclosure;
[0047] FIG. 24 is a schematic diagram of matching other computing storage nodes with a second multiple and a first difference as target computing storage nodes according to an embodiment of the present disclosure;
[0048] FIG. 25 is a specific flow chart of determining a target shard according to an embodiment of the present disclosure;
[0049] FIG. 26 is a specific flow chart of migrating shards on a traversed computing storage node to a computing storage node with a second offset smaller than the traversed computing storage node according to an embodiment of the present disclosure;
[0050] FIG. 27 is a schematic diagram of initializing a second target migration computing storage node as a first computing storage node in a third order according to an embodiment of the present disclosure;
[0051] FIGS. 28A-28B are schematic diagrams of migrating a second target shard from a traversed computing storage node to a second target migration computing storage node according to an embodiment of the present disclosure;
[0052] FIG. 29 is a specific flow chart of migrating the shard on the traversed compute storage node to a compute storage node whose second offset is less than that of the traversed compute storage node, according to an embodiment of the present disclosure;
[0053] FIG. 30 is a schematic diagram of initializing the third target migration compute storage node as the first compute storage node in the fourth order, according to an embodiment of the present disclosure;
[0054] FIG. 31A-FIG. 31B are schematic diagrams of migrating the third target shard from the traversed compute storage node to the third target migration compute storage node, according to an embodiment of the present disclosure;
[0055] FIG. 32 is an embodiment details diagram of the distributed system load balancing method, according to an embodiment of the present disclosure;
[0056] FIG. 33 is a module block diagram of the distributed system load balancing apparatus, according to an embodiment of the present disclosure;
[0057] FIG. 34 is a terminal structure diagram of performing the distributed system load balancing method, according to an embodiment of the present disclosure;
[0058] FIG. 35 is a server structure diagram of performing the distributed system load balancing method, according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0059] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.
[0060] Before further detailed description of the embodiments of the present disclosure, the terms and phrases involved in the embodiments of the present disclosure are explained, and the terms and phrases involved in the embodiments of the present disclosure are applicable to the following explanations:
[0061] Distributed system: The distributed system is composed of multiple independent compute storage units. Data is scattered in each independent compute storage unit in a distributed manner. Each compute storage unit is responsible for processing a part of data of a distributed request, and a distributed request is efficiently completed in a parallel manner.
[0062] Load balancing algorithm: Load balancing algorithm is a method of evenly distributing network traffic in a resource pool that supports an application. Modern applications must handle millions of users simultaneously and return the correct text, video, image, and other data to each user in a fast and reliable manner. To handle such high traffic, most applications have many resource servers, which contain a lot of duplicate data between them, and load balancing algorithms can ensure equal use of all resource servers.
[0063] Elasticsearch: Elasticsearch is a very popular open source distributed retrieval analysis engine at present. In Elasticsearch, a computing storage unit (Node) can be part of a cluster or independent. A computing storage unit can contain one or more indexes (Index). Index is a logical data storage in Elasticsearch, which contains a group of documents with similar characteristics. Document is the data unit in Elasticsearch, and the document contains fields and field values.
[0064] The read and write speed of Elasticsearch follows the principle of the shortest log, that is, if a computing storage unit performs poorly, it will slow down the entire request latency, and in severe cases, it may even cause online failure. Therefore, keeping the load balance between computing storage units as much as possible can not only ensure the optimal performance of the cluster, but also maximize the use of hardware resources and ensure the stability of the cluster.
[0065] The distributed system includes a scheduling node and multiple independent computing storage nodes. The index is a multi-field data body (such as a data table) to be calculated and stored. The scheduling node divides the index into shards and stores them on each computing storage node for calculation and storage. To ensure the performance state of the distributed system, the load balancing algorithm is generally used to determine the number of shards allocated to each computing storage unit.
[0066] One of the load balancing algorithms in the prior art is based on the disk usage of the computing storage unit to allocate shards to each computing storage unit. That is, when allocating shards of the index, the shards are preferentially allocated to the computing storage unit with smaller disk usage. However, this method can easily cause some larger shards to be relatively concentrated in a computing storage unit, and the computing storage unit can also reduce the efficiency of processing requests because of the concentration of larger shards, and in severe cases, it can even cause the entire distributed system to fail. How to achieve load balancing of the distributed system while improving the efficiency of the computing storage unit in processing requests is a problem that needs to be discussed and solved at present.
[0067] Based on this, the embodiment of the present disclosure provides a distributed system load balancing method, device, electronic equipment and medium. The distributed system load balancing method provided by the embodiment of the present disclosure can perform migration of shards on multiple computing storage nodes based on the first offset, the second offset and the third offset after the computing storage node performs index change, so that each computing storage node realizes the balance of the dimension of the number of shards of a single index stored by the computing storage node, the balance of the dimension of the total number of shards stored by the computing storage node and the balance of the dimension of the storage space utilization of the computing storage node after migration, realizing the load balancing of the distributed system while improving the efficiency of the computing storage node in processing requests.
[0068] System architecture and scenario to which the embodiment of the present disclosure is applied
[0069] FIGS. 1A-1B are system architecture diagrams to which the distributed system load balancing method according to the embodiment of the present disclosure is applied. FIG. 1A includes a terminal 140, the Internet 130, a gateway 120, a server 110, etc.
[0070] The terminal 140 includes desktop computers, laptop computers, PDAs (personal digital assistants), mobile phones, vehicle-mounted terminals, home theater terminals, special-purpose terminals, etc. in various forms. In addition, it can be a single device or a collection of multiple devices. The terminal 140 can communicate with the Internet 130 in a wired or wireless manner and exchange data.
[0071] The server 110 refers to a computer system capable of providing certain services to the terminal 140. Compared with the ordinary terminal 140, the server 110 has higher requirements in stability, security, performance, etc. The server 110 can be a high-performance computer in a network platform, a cluster of multiple high-performance computers, a part of a high-performance computer (such as a virtual machine), a combination of parts of multiple high-performance computers (such as virtual machines), etc. In a distributed system, multiple servers 110 are connected as computing storage units to transmit data and coordinate task processing by using shared communication lines.
[0072] The gateway 120 is also known as an inter-network connector or a protocol converter. The gateway realizes network interconnection at the transport layer and is a computer system or device that acts as a conversion role. In the use of different communication protocols, data formats or languages, or even two systems with completely different architectures, the gateway is a translator. At the same time, the gateway can also provide filtering and security functions. The messages sent by the terminal 140 to the server 110 are sent to the corresponding server 110 through the gateway 120. The messages sent by the server 110 to the terminal 140 are also sent to the corresponding terminal 140 through the gateway 120.
[0073] The scheduling node and the computing storage node of the distributed system load balancing method of the embodiments of the present disclosure can be the terminal 140 or the server 110. That is, the distributed system load balancing method of the embodiments of the present disclosure can be implemented completely on the terminal 140, completely on the server 110, partially on the terminal 140, or partially on the server 110.
[0074] Referring to FIG. 1B, one cluster of the distributed system includes multiple scheduling nodes and multiple computing storage nodes. Metadata synchronization can be implemented between different scheduling nodes to ensure that the data in the distributed system remains consistent. The scheduling node can also issue metadata or requests to the computing storage node, so that the computing storage node stores the metadata or forwards the request to other computing storage nodes.
[0075] Metadata synchronization refers to the data synchronization operation between different scheduling nodes in the distributed system, which aims to ensure that the data in the distributed system remains consistent, so that the system metadata information mastered by each scheduling node is the same, so as to accurately issue metadata or requests to the computing storage node.
[0076] Further, the computing storage node in the distributed system carries the functions of data storage and computation. The data in the cluster is stored in the form of an index. The index is a multi-field data body to be calculated and stored, and the index can also be understood as a logic of data storage. An index will be divided into multiple shards and stored in various computing storage nodes in the distributed system. Each index is composed of a primary shard and multiple replica shards to improve data availability and performance. The primary shard is one of the components of the index after the index is divided. Each index is composed of a primary shard and multiple replica shards. The primary shard plays a key role in data storage and processing and is the main storage location of data to improve data availability and performance. The replica shard is one of the components of the index after the index is divided and, together with the primary shard, constitutes an index. The replica shard is a copy of the primary shard and is used to improve data availability and performance. When the primary shard fails or is unavailable, the replica shard can replace the primary shard to provide data services.
[0077] For example, assume that index A is divided into shard 1, shard 4, and shard 7, index B is divided into shard 2, shard 5, and shard 8, and index C is divided into shard 3, shard 6, and shard 9. Then, in the distributed system, the computing storage node 1 can store shard 1, shard 2, and shard 3. The computing storage node 2 can store shard 4, shard 5, and shard 6. The computing storage node 3 can store shard 7, shard 8, and shard 9.
[0078] The distributed system load balancing method of the embodiments of the present disclosure can be applied to a distributed retrieval analysis engine to improve the efficiency of the distributed retrieval analysis engine in processing requests. The distributed system load balancing method of the embodiments of the present disclosure can also be applied to a distributed application to improve the data processing capability of the distributed application.
[0079] FIGS. 2A-2B are schematic diagrams of application scenarios of the distributed system load balancing method according to an embodiment of the present disclosure. Referring to FIG. 2A, it is assumed that a user requests to upload a target index E. After receiving the request to upload the target index E, a scheduling node in the distributed retrieval analysis engine will divide the target index E into multiple shards to be respectively stored in each computing storage node. Moreover, after performing the operation of index allocation of each computing storage node, the scheduling node will perform load balancing on the multiple shards in each computing storage node by using the distributed load balancing method according to an embodiment of the present disclosure, so as to improve the efficiency of the computing storage node in processing requests, thereby improving the efficiency of the distributed retrieval analysis engine in processing requests.
[0080] Referring to FIG. 2B, it is assumed that a user requests to delete an index A. After receiving the request to delete the index A, a scheduling node in the distributed retrieval analysis engine will delete the shards of the index A that have been stored in each computing storage node until there is no shard of the index A in each computing storage node. Moreover, after performing the operation of index deletion of each computing storage node, the scheduling node will perform load balancing on the multiple shards in each computing storage node by using the distributed load balancing method according to an embodiment of the present disclosure, so as to improve the efficiency of the distributed retrieval analysis engine in processing requests.
[0081] It should be understood that the above only illustrates the description of part of the application scenarios of the present disclosure. The business scenarios to which the present disclosure can be applied can include but are not limited to the specific embodiments described above.
[0082] General Description of Embodiments of the Present Disclosure
[0083] It should be emphasized that the embodiments of the present disclosure can be applied to various application scenarios, such as distributed retrieval analysis engines, distributed application programs, and the like. In the related art, there is a load balancing algorithm that allocates shards to each computing storage unit based on the disk usage of the computing storage unit. That is, when allocating shards of an index, shards are preferentially allocated to computing storage units with smaller disk usage. However, this method can easily cause some relatively large shards to be concentrated in a certain computing storage unit, and the computing storage unit can also reduce the efficiency of processing requests because it concentrates the storage of relatively large shards, and in a serious case, it can even cause the entire distributed system to fail. Some embodiments of the present disclosure provide a distributed system load balancing method, device, electronic equipment and medium, which can perform migration of shards on multiple computing storage nodes based on a first offset, a second offset and a third offset after a computing storage node performs index changes, so that each computing storage node realizes the balance of the dimension of the number of shards of a single index stored by the computing storage node, the balance of the dimension of the total number of shards stored by the computing storage node, and the balance of the dimension of the storage space utilization of the computing storage node after migration, while also improving the efficiency of the computing storage node in processing requests.
[0084] Load balancing refers to distributing shards to multiple computing storage nodes for storage, so that the load of each computing storage node reaches a balanced state. Maintaining the balance of the load between computing storage nodes as much as possible can not only ensure that the performance of the cluster is in the optimal state, but also maximize the use of hardware resources in the cluster, and ensure the stability of the cluster.
[0085] According to one embodiment of the present disclosure, a distributed system load balancing method is provided. The method can be applied to a distributed retrieval analysis engine as shown in FIGS. 2A-2B, and can also be applied to distributed databases, distributed application programs, and the like.
[0086] As shown in FIG. 3, according to one embodiment of the present disclosure, the scheduling node is applied in a distributed system including a scheduling node and multiple computing storage nodes, an index stored in the distributed system is divided into shards, the shards are stored in the multiple computing storage nodes, the index is a multi-field data body to be calculated and stored, and the distributed system load balancing method includes:
[0087] Step 310, in response to an index change request, performing index changes on the multiple computing storage nodes.
[0088] Step 320, determining a first offset of each computing storage node after the index change, the first offset being an offset of the number of shards of a single index stored by the computing storage node relative to an average number of shards of the single index stored by each computing storage node; determining a second offset of each computing storage node after the index change, the second offset being an offset of a total number of shards stored by the computing storage node relative to an average total number of shards stored by each computing storage node; determining a third offset of each computing storage node after the index change, the third offset being an offset of a storage space utilization of the computing storage node relative to an average storage space utilization of each computing storage node. The order of determining the first offset, the second offset and determining the third offset can be any order, including sequentially executing in a specific order, or executing in parallel.
[0089] Step 330, based on the first offset, the second offset and the third offset, migrating shards on the plurality of computing storage nodes, so that the first offset on each computing storage node after migration is less than a first threshold, the second offset is less than a second threshold, and the third offset is less than a third threshold.
[0090] The steps 310-330 described above are briefly described as follows.
[0091] In step 310, in response to an index change request, an index change is performed on the plurality of computing storage nodes.
[0092] According to an embodiment of the present disclosure, the scheduling node and the computing storage node in the distributed system can be servers, wherein the scheduling node refers to a server for scheduling shards stored by the computing storage node, and the computing storage node refers to a server for storing and processing shards.
[0093] The index refers to a multi-field data body to be computed and stored, and the index contains a group of documents with similar characteristics, each document has a unique identifier, and the identifier can be used to refer to the document corresponding to the identifier. For example, in a distributed retrieval analysis engine, the index can be understood as a database for storing and managing documents. In a distributed database, the index can be understood as a data table, which contains multiple fields, and the types of each field can be specified.
[0094] In the distributed system, the indexes are divided into multiple shards, which are stored in multiple computing storage nodes. A shard refers to a data shard used to store and manage documents. For example, referring to FIG. 4A, it is assumed that the distributed system includes index A, index B, index C, index D, and index E, index A is divided into 12 shards to be stored in multiple computing storage nodes, index B is divided into 9 shards to be stored in multiple computing storage nodes, index C is divided into 2 shards to be stored in multiple computing storage nodes, index D is divided into 2 shards to be stored in multiple computing storage nodes, and index E is divided into 2 shards to be stored in multiple computing storage nodes. Referring to FIG. 4B, computing storage node 1 stores 4 shards of index A, 3 shards of index B, 1 shard of index C, and 1 shard of index D. Computing storage node 2 stores 4 shards of index A, 3 shards of index B, 1 shard of index C, and 1 shard of index E. Computing storage node 3 stores 4 shards of index A, 3 shards of index B, 1 shard of index D, and 1 shard of index E.
[0095] According to an embodiment of the present disclosure, the index change request refers to a request to change the number of shards stored in multiple computing storage nodes in the distributed system. The index change request can be a request to add a new index to the distributed system, or a request to delete an existing index in the distributed system, or a request to migrate a shard in a computing storage node to another computing storage node.
[0096] For example, in the case where the index change request is a request to add a new index to the distributed system, the scheduling node will respond to the index change request by dividing the new index into multiple shards and assigning the shards of the new index to multiple computing storage nodes after receiving the index change request. In the case where the index change request is a request to delete an existing index in the distributed system, the scheduling node will respond to the index change request by deleting the shards of the index stored in the computing storage nodes after receiving the index change request. When the index change request is a request to migrate shard H in computing storage node A to computing storage node B, the scheduling node will respond to the index change request by migrating shard H in computing storage node A to computing storage node B after receiving the index change request.
[0097] It should be noted that when the storage space utilization of a computing storage node in the distributed system exceeds the preset water level, an index change request will be triggered, so that the scheduling node responds to the index change request by migrating part of the shards in the computing storage node to another computing storage node.
[0098] In step 320, a first offset of each computing storage node after the index change is determined, the first offset being an offset of the number of shards of a single index stored by the computing storage node relative to an average number of shards of the single index stored by each computing storage node; a second offset of each computing storage node after the index change is determined, the second offset being an offset of a total number of shards stored by the computing storage node relative to an average total number of shards stored by each computing storage node; and a third offset of each computing storage node after the index change is determined, the third offset being an offset of a storage space utilization of the computing storage node relative to an average storage space utilization of each computing storage node.
[0099] According to an embodiment of the present disclosure, the first offset refers to an offset of the number of shards of a single index stored by the computing storage node after the index change relative to an average number of shards of the single index stored by each computing storage node. For example, assuming that index A is divided into 10 shards, computing storage node 1 in the distributed system stores 2 shards of index A, computing storage node 2 stores 3 shards of index A, computing storage node 3 stores 1 shard of index A, and computing storage node 4 stores 4 shards of index A. Through calculation, it can be obtained that the average number of shards of index A stored by each computing storage node is 2.5, and thus the first offset of computing storage node 1 is -0.5, the first offset of computing storage node 2 is 0.5, the first offset of computing storage node 3 is -1.5, and the first offset of computing storage node 4 is 1.5.
[0100] The second offset refers to an offset of a total number of shards stored by the computing storage node after the index change relative to an average total number of shards stored by each computing storage node. For example, referring to FIG. 4B, assuming that the distributed system includes computing storage node 1, computing storage node 2, and computing storage node 3, the total number of shards stored by computing storage node 1 is 1500, the total number of shards stored by computing storage node 2 is 1400, and the total number of shards stored by computing storage node 3 is 1600. Through calculation, it can be obtained that the average total number of shards stored by each computing storage node is 1500, and thus the second offset of computing storage node 1 is 0, the second offset of computing storage node 2 is -100, and the second offset of computing storage node 3 is 100.
[0101] The third offset refers to an offset of the storage space utilization rate of a computing storage node after index change relative to the average storage space utilization rate of each computing storage node. For example, referring to FIG. 4B, assuming that the distributed system includes computing storage node 1, computing storage node 2 and computing storage node 3, the storage space utilization rate of computing storage node 1 is 65%, the storage space utilization rate of computing storage node 2 is 60%, and the storage space utilization rate of computing storage node 3 is 70%. Through calculation, the average storage space utilization rate of each computing storage node is 65%, and thus the third offset of computing storage node 1 is 0, the third offset of computing storage node 2 is -5%, and the third offset of computing storage node 3 is 5%.
[0102] In step 330, based on the first offset, the second offset and the third offset, migration of the shards on the plurality of computing storage nodes is performed so that the first offset on each computing storage node after migration is less than the first threshold, the second offset is less than the second threshold, and the third offset is less than the third threshold.
[0103] According to an embodiment of the present disclosure, the first threshold refers to a critical value of the first offset that can be allowed. When the first offset of the number of shards of a certain index of a certain computing storage node reaches the first threshold, it means that the number of shards of the index stored by the computing storage node is far more than the number of shards of the index stored by other computing storage nodes in the distributed system. At this time, the distributed system does not reach a state of load balancing, and in this case, the efficiency of the computing storage node in processing requests will be greatly reduced. In practical applications, the first threshold can be 1. The second threshold refers to a critical value of the second offset that can be allowed. When the second offset of a certain computing storage node reaches the second threshold, it means that the total number of shards stored by the computing storage node is far more than the total number of shards stored by other computing storage nodes in the distributed system. At this time, the distributed system does not reach a state of load balancing, and in this case, the efficiency of the computing storage node in processing requests will be greatly reduced. In practical applications, the second threshold can be 5% of the average total number of shards stored by each computing storage node. The third threshold refers to a critical value of the third offset that can be allowed. When the third offset of a certain computing storage node reaches the third threshold, it means that the storage space utilization rate of the computing storage node is far more than the storage space utilization rate of other computing storage nodes in the distributed system. At this time, the distributed system does not reach a state of load balancing, and in this case, the efficiency of the computing storage node in processing requests will be greatly reduced. In practical applications, the third threshold can be 5% of the average storage space utilization rate of each computing storage node.
[0104] The first threshold value is 1, which is based on a large number of experiments and practical application experience. When the offset of the number of shards of a single index stored by a computing storage node relative to the average number of shards reaches 1, it will significantly affect the load balancing and processing efficiency of the system. The second threshold value is 5% of the average total number of shards stored by each computing storage node, which is a comprehensive consideration of the stability and resource utilization of the system. When the total number of shards stored by a certain computing storage node exceeds 5% of the average total number of shards, it may cause the node to be overloaded. The third threshold value is 5% of the average storage space utilization of each computing storage node, which is to avoid the storage space utilization of a certain computing storage node being too high to affect the overall performance of the system. The value is determined after multiple tests and optimizations.
[0105] It can be understood that when the first offset of a certain computing storage node in the distributed system reaches the first threshold value, or the second offset of a certain computing storage node reaches the second threshold value, or the third offset of a certain computing storage node reaches the third threshold value, it means that the distributed system has not reached a state of load balancing at this time. In order to achieve load balancing of the distributed system and improve the efficiency of the computing storage node in processing requests, the embodiments of the present disclosure need to migrate shards on multiple computing storage nodes so that the first offset of each computing storage node after migration is less than the first threshold value, the second offset is less than the second threshold value, and the third offset is less than the third threshold value.
[0106] The migration process of the shards on the plurality of computing storage nodes is explained in conjunction with FIG. 5A and FIG. 5B: Referring to FIG. 5A, the distributed system includes computing storage node 1, computing storage node 2 and computing storage node 3, computing storage node 1 stores 4 shards of index A, 3 shards of index B, 1 shard of index C and 1 shard of index D, computing storage node 2 stores 4 shards of index A, 3 shards of index B, 1 shard of index C and 1 shard of index E. Assuming the first threshold is 1, if 1 shard of index A stored by computing storage node 2 is migrated to computing storage node 1 in the shard migration process, after the migration, computing storage node 1 will store 5 shards of index A and computing storage node 2 will store 3 shards of index A, which will cause the first offset of the shards of index A of computing storage node 1 to reach the first threshold. Therefore, it is not feasible to migrate 1 shard of index A stored by computing storage node 2 to computing storage node 1. If 1 shard of index E stored by computing storage node 2 is migrated to computing storage node 1 in the shard migration process, referring to FIG. 5B, after the migration, computing storage node 1 will store 1 shard of index E and computing storage node 2 will not store any shard of index E. At this time, the first offset of the shards of index E of computing storage node 1 and the first offset of the shards of index E of computing storage node 2 are both less than the first threshold. Therefore, it is feasible to migrate 1 shard of index E stored by computing storage node 2 to computing storage node 1.
[0107] In the embodiments of steps 310 to 330, the scheduling node receives the index change request, which indicates that the index in the distributed system needs to be changed. In the case that the index in the distributed system needs to be changed, the scheduling node will perform the index change on the plurality of computing storage nodes. After the plurality of computing storage nodes perform the index change, the number of shards stored by the computing storage nodes will also change. In order to reduce the possibility that a certain computing storage node reduces the efficiency of processing requests due to the centralized storage of some relatively large shards after the plurality of computing storage nodes perform the index change, the scheduling node will further determine the first offset, the second offset and the third offset of each computing storage node after the index change. The first offset indicates the offset of the number of shards of a single index stored by the computing storage node relative to the average number of shards of a single index stored by each computing storage node, the second offset indicates the offset of the total number of shards stored by the computing storage node relative to the average total number of shards stored by each computing storage node, and the third offset indicates the offset of the storage space utilization of the computing storage node relative to the average storage space utilization of each computing storage node. Therefore, based on the first offset, the second offset and the third offset, the deviation of each computing storage node in the distributed system from other computing storage nodes in the distributed system can be determined. Further, based on the first offset, the second offset and the third offset, the migration of shards on the plurality of computing storage nodes can be performed, so that the first offset of each computing storage node after the migration is less than a first threshold, the second offset is less than a second threshold, and the third offset is less than a third threshold. It can be understood that, by making the first offset of each computing storage node less than the first threshold, the embodiments of the present disclosure achieve the balance of the dimension of the number of shards of a single index stored by the computing storage node, reduce the possibility that some relatively large shards are relatively concentrated in a certain computing storage node, and improve the efficiency of each computing storage node in the distributed system in processing requests. Moreover, by making the second offset of each computing storage node less than the second threshold, the embodiments of the present disclosure achieve the balance of the dimension of the total number of shards stored by the computing storage node, and by making the third offset of each computing storage node less than the third threshold, the embodiments of the present disclosure achieve the balance of the dimension of the storage space utilization of the computing storage node. Based on this, the embodiments of the present disclosure can also avoid the situation that a certain computing storage node reduces the efficiency of processing requests due to the storage of too many shards in the case that there is a large amount of idle disk space in the certain computing storage node, and improve the running efficiency of the distributed system.
[0108] The above is the overall description of steps 310 to 330. Since step 320 has been described in sufficient detail above, only the specific implementation process of steps 310 and 330 will be described in detail below.
[0109] Detailed description of step 310
[0110] Step 310, in response to the index change request, performing index change on the plurality of computing storage nodes.
[0111] In an embodiment, the index change request is an index allocation request for a target index, referring to FIG. 6, step 310 comprises:
[0112] Step 610, dividing the target index into a plurality of shards.
[0113] Step 620, allocating the plurality of shards on the plurality of computing storage nodes, such that for the target index, a first offset on each computing storage node is less than a first threshold.
[0114] The steps 610 to 620 are described in detail as follows:
[0115] In step 610, the target index is divided into a plurality of shards.
[0116] The target index refers to a new index added in the distributed system by an external request in the load balancing method of the distributed system, which needs to be allocated and processed by the scheduling node, divided into a plurality of shards and allocated to the plurality of computing storage nodes when the index change request is an index allocation request.
[0117] According to an embodiment of the present disclosure, the index change request can be an index allocation request for a target index, the index allocation request refers to adding a new index in the distributed system by an external request, and the scheduling node needs to allocate the new index in response to the index allocation request after receiving the index allocation request. Based on this, the scheduling node will divide the target index into a plurality of shards in response to the index allocation request for the target index after receiving the index allocation request for the target index, so as to facilitate subsequent allocation of shards of the target index to the plurality of computing storage nodes.
[0118] For example, referring to FIG. 7A and FIG. 7B, assuming that the distributed system includes scheduling node 1, scheduling node 2, scheduling node 3, computing storage node 1, computing storage node 2 and computing storage node 3. The scheduling node 2 will divide the target index E into 3 shards in response to the index allocation request for the target index E after receiving the index allocation request for the target index E, so as to facilitate subsequent allocation of the target index E to the computing storage node 1, the computing storage node 2 and the computing storage node 3.
[0119] The specific method of "dividing the target index into a plurality of shards" will be described in detail below.
[0120] In step 620, the plurality of shards are allocated on the plurality of computing storage nodes, such that for the target index, a first offset on each computing storage node is less than a first threshold.
[0121] According to an embodiment of the present disclosure, in order to guarantee the balance of the dimension of the number of shards of a single index stored by a computing storage node, when allocating shards of a target index, the scheduling node needs to consider the number of shards of the target index allocated to each computing storage node, so as to guarantee that the number of shards of the target index on each computing storage node is balanced as much as possible. Based on this, when allocating a plurality of shards on a plurality of computing storage nodes, an embodiment of the present disclosure needs to ensure that after completing the allocation of shards of the target index, the first offset of the shards of the target index allocated to each computing storage node is less than a first threshold.
[0122] For example, referring to FIG. 7B, it is assumed that the first threshold is 1. After receiving the index allocation request for the target index E, the scheduling node 2 will respond to the index allocation request for the target index E by dividing the target index E into 3 shards. In order to guarantee that the number of shards of the target index on the computing storage node 1, the computing storage node 2 and the computing storage node 3 is balanced as much as possible, the scheduling node 2 allocates 1 shard of the target index E to the computing storage node 1, 1 shard of the target index E to the computing storage node 2, and 1 shard of the target index E to the computing storage node 3. Through this allocation mode, it is guaranteed that the first offset of the shards of the target index E allocated to each computing storage node is less than the first threshold, and the load balancing of the distributed system is achieved.
[0123] It can be understood that the index change request can be an index deletion request for a target index, and the index deletion request refers to an external request to delete an index stored in the distributed system, and the scheduling node needs to respond to the index deletion request by deleting the specified index after receiving the index deletion request. For example, referring to FIG. 8A, the distributed system includes the scheduling node 1, the scheduling node 2, the scheduling node 3, the computing storage node 1, the computing storage node 2 and the computing storage node 3. After receiving the index deletion request for the index E, the scheduling node 2 will respond to the index deletion request for the index E by deleting 1 shard of the index E stored by the computing storage node 1, 1 shard of the index E stored by the computing storage node 2 and 1 shard of the index E stored by the computing storage node 3. As shown in FIG. 8B, after the scheduling node 2 deletes the index E in the distributed system in response to the index deletion request for the index E, there is no shard of the index E in the computing storage node 1, the computing storage node 2 and the computing storage node 3.
[0124] The embodiments of steps 610 to 620 can divide the target index into multiple shards in response to the index allocation request for the target index, and consider the number of shards of the target index allocated to each computing storage node when allocating the shards of the target index, so that the first offset on each computing storage node is less than the first threshold after the shards of the target index are allocated. By ensuring that the first offset of the shards of the target index allocated to each computing storage node is less than the first threshold, the balance of the number of shards of a single index stored by the computing storage node in the dimension is achieved.
[0125] In an embodiment, referring to FIG. 9, step 610 includes:
[0126] Step 910, obtaining the storage capacity and storage space utilization of each computing storage node;
[0127] Step 920, calculating the average storage capacity of each computing storage node based on the storage capacity of each computing storage node;
[0128] Step 930, calculating the average storage space utilization of each computing storage node based on the storage space utilization of each computing storage node;
[0129] Step 940, determining the number of shards based on the index size of the target index, the average storage capacity, and the average storage space utilization;
[0130] Step 950, dividing the target index based on the number of shards to obtain multiple shards.
[0131] The steps 910 to 950 are described in detail as follows:
[0132] In step 910, the storage capacity and storage space utilization of each computing storage node are obtained.
[0133] According to an embodiment of the present disclosure, the storage capacity refers to the capacity of the space used by the computing storage node to store shards, and the computing storage node uses the storage capacity to store shards of each index. The larger the storage capacity, the more shards the computing storage node can store, and correspondingly, the smaller the storage capacity, the fewer shards the computing storage node can store. The storage space utilization refers to the ratio of the storage capacity occupied by the shards already stored by the computing storage node to the storage capacity of the computing storage node. The larger the storage space utilization, the more storage capacity has been used by the computing storage node, and correspondingly, the smaller the storage space utilization, the less storage capacity has been used by the computing storage node.
[0134] In step 920, the average storage capacity of each computing storage node is calculated based on the storage capacity of each computing storage node.
[0135] According to an embodiment of the present disclosure, the average storage capacity refers to an average value of storage capacities of the computing storage nodes in the distributed system. Assuming that the distributed system comprises computing storage node 1, computing storage node 2, computing storage node 3 and computing storage node 4, the storage capacity of computing storage node 1 is 15 GB, the storage capacity of computing storage node 2 is 10 GB, the storage capacity of computing storage node 3 is 20 GB, and the storage capacity of computing storage node 4 is 15 GB. It can be determined by calculation that the average storage capacity of each computing storage node in the distributed system is 15 GB.
[0136] In step 930, the average storage space utilization of each computing storage node is calculated based on the storage space utilization of each computing storage node.
[0137] According to an embodiment of the present disclosure, the average storage space utilization refers to an average value of storage space utilizations of the computing storage nodes in the distributed system. Assuming that the distributed system comprises computing storage node 1, computing storage node 2, computing storage node 3 and computing storage node 4, the storage space utilization of computing storage node 1 is 50%, the storage space utilization of computing storage node 2 is 40%, the storage space utilization of computing storage node 3 is 44%, and the storage space utilization of computing storage node 4 is 46%. It can be determined by calculation that the average storage space utilization of each computing storage node in the distributed system is 45%.
[0138] In step 940, the number of shards is determined based on the index size of the target index, the average storage capacity and the average storage space utilization.
[0139] According to an embodiment of the present disclosure, the index size of the target index refers to the capacity occupied by the target index, and the number of shards refers to the number of shards corresponding to the target index after the target index is split.
[0140] It can be understood that determining the number of shards based on the index size of the target index, the average storage capacity and the average storage space utilization comprises: determining a first fraction based on the average storage capacity; determining a second fraction based on the average storage space utilization; determining a shard size based on the first fraction and the second fraction; and determining the number of shards based on the shard size and the index size of the target index.
[0141] It can be understood that determining the first fraction based on the average storage capacity can adopt a lookup table manner. The average storage capacity is looked up in a pre-set average storage capacity and first fraction correspondence table to obtain the first fraction corresponding to the average storage capacity. Determining the first fraction based on the average storage capacity can also adopt an imputation manner. The average storage capacity is imputed into a pre-set function related to the average storage capacity and the first fraction to obtain the first fraction corresponding to the average storage capacity.
[0142] It can be understood that the second score is determined based on the average storage space utilization, and a lookup table can be used. A pre-set average storage space utilization and second score correspondence table is looked up according to the average storage space utilization, to obtain the second score corresponding to the average storage space utilization. The second score can also be determined based on the average storage space utilization by substitution. The average storage space utilization is substituted into a pre-set function related to the average storage space utilization and the second score, to obtain the second score corresponding to the average storage space utilization.
[0143] In some embodiments, the first score is determined based on the average storage capacity, specifically, a pre-set average storage capacity and first score correspondence table is looked up according to the average storage capacity, to obtain the first score corresponding to the average storage capacity. For example, when the average storage capacity is less than 10 GB, the first score is 2; when the average storage capacity is between 10 GB and 20 GB, the first score is 5; and when the average storage capacity is greater than 20 GB, the first score is 8. The average storage capacity can also be substituted into a pre-set function related to the average storage capacity and the first score y=ax+b (where x represents the average storage capacity, y is the first score, a is the slope, and b is the intercept), to obtain the first score corresponding to the average storage capacity. The second score is determined based on the average storage space utilization, and a pre-set average storage space utilization and second score correspondence table is looked up according to the average storage space utilization, to obtain the second score corresponding to the average storage space utilization. For example, when the average storage space utilization is less than 30%, the second score is 2; when the average storage space utilization is between 30% and 60%, the second score is 5; and when the average storage space utilization is greater than 60%, the second score is 8. The average storage space utilization can also be substituted into a pre-set function related to the average storage space utilization and the second score n=cm+d (where m represents the average storage space utilization, n is the second score, c is the slope, and d is the intercept), to obtain the second score corresponding to the average storage space utilization.
[0144] The first score and the second score are determined based on the slice size. A weighted sum of the first score and the second score can be calculated, and the weighted sum of the first score and the second score is used as a basis for dividing the slice size. For example, after the weighted sum of the first score and the second score is determined as a basis for dividing the slice size, a correspondence table of the weighted sum of the first score and the second score and the slice size is looked up according to the weighted sum of the first score and the second score, and the slice size corresponding to the weighted sum of the first score and the second score is obtained. Alternatively, the weighted sum of the first score and the second score can be substituted into a function of the weighted sum of the first score and the second score and the slice size, and the slice size corresponding to the weighted sum of the first score and the second score is obtained. The number of slices is determined based on the slice size and the index size of the target index. After the slice size is determined, the index size of the target index is divided by the slice size to determine the number of slices corresponding to the target index.
[0145] After the first score and the second score are determined, a weighted sum of the first score and the second score can be calculated, and the weighted sum of the first score and the second score is used as a basis for dividing the slice size. Of course, the sum or the average of the first score and the second score can also be used as a basis for dividing the slice size. Compared with the sum or the average, the weighted sum has the advantage that the influence of the average storage capacity and the average storage space utilization on the slice size can be flexibly set by adjusting the weights of the first score and the second score.
[0146] For example, the weighted sum of the first score and the second score is determined as a basis for dividing the slice size, and then a table lookup method can be used to determine the slice size. A correspondence table of the weighted sum of the first score and the second score and the slice size is looked up according to the weighted sum of the first score and the second score, and the slice size corresponding to the weighted sum of the first score and the second score is obtained. The weighted sum of the first score and the second score can also be determined by substitution. The weighted sum of the first score and the second score is substituted into a function of the weighted sum of the first score and the second score and the slice size, and the slice size corresponding to the weighted sum of the first score and the second score is obtained.
[0147] It can be understood that the number of slices is determined based on the slice size and the index size of the target index. After the slice size is determined, the index size of the target index is divided by the slice size to determine the number of slices corresponding to the target index.
[0148] For example, referring to FIG. 10, it is assumed that the sum of the first score and the second score is taken as the basis for dividing the size of the shard by employing a lookup table to determine the first score and the second score. In the case where the average storage capacity of each computing storage node in the distributed system is 35 GB and the average storage space utilization is 63%, it can be determined that the first score corresponding to the average storage capacity is 8 and the second score corresponding to the average storage space utilization is 6, and the sum of the first score and the second score is 14. Further, it can be determined that the size of the shard corresponding to the sum of the first score and the second score is 200 MB. It is assumed that the size of the target index is 3 GB, and at this time, it can be determined that the number of shards corresponding to the target index is 15.
[0149] In step 950, the target index is divided based on the number of shards to obtain a plurality of shards.
[0150] According to an embodiment of the present disclosure, in order to divide the target index into a plurality of shards, so as to subsequently allocate the shards of the target index to a plurality of computing storage nodes. After determining the number of shards, the target index can be evenly divided into a plurality of shards according to the number of shards and the size of the shard, and the plurality of shards can be allocated to each computing storage node, so as to achieve the balance of the dimension of the number of shards of a single index stored by the computing storage node when allocating the shards to the computing storage node.
[0151] The embodiments of steps 910 to 950 described above can determine the average storage capacity and the average storage space utilization of each computing storage node based on the storage capacity and the storage space utilization of each computing storage node, respectively. The average storage capacity of each computing storage node reflects the capability of the distributed system to store indexes, and the average storage space utilization of each computing storage node reflects the proportion of the storage space already used by the distributed system to the total storage space of the distributed system, so that the current state of the distributed system can be better understood through the average storage capacity and the average storage space utilization of each computing storage node. After that, the number of shards can be determined based on the index size of the target index, the average storage capacity and the average storage space utilization, and the target index can be evenly divided into a plurality of shards based on the number of shards, so as to achieve the balance of the dimension of the number of shards of a single index stored by the computing storage node when allocating the shards to the computing storage node.
[0152] Detailed description of step 330
[0153] Step 330, based on the first offset, the second offset and the third offset, migrating the shards on the plurality of computing storage nodes, so that the first offset on each computing storage node after migration is less than the first threshold, the second offset is less than the second threshold, and the third offset is less than the third threshold.
[0154] In one embodiment, referring to FIG. 11, step 330 comprises:
[0155] Step 1110, traversing the indexes in the distributed system;
[0156] Step 1120, migrating the shards on the plurality of computing storage nodes based on the first offset, the second offset and the third offset for the traversed index.
[0157] Steps 1110 to 1120 are described in detail as follows:
[0158] In step 1110, the indexes in the distributed system are traversed.
[0159] According to embodiments of the present disclosure, "traversing the indexes in the distributed system" means using a certain fixed algorithm to calculate each index in the distributed system in turn until all the calculations of the distributed system are completed.
[0160] In some embodiments, "traversing the indexes in the distributed system" can adopt a sequential traversal algorithm, i.e., calculating each index in turn according to the storage order of the index in the system. For example, if the indexes in the distributed system are stored in lexicographical order according to the index name, then each index is calculated in lexicographical order until all the indexes in the distributed system are calculated. A random traversal algorithm can also be adopted, i.e., randomly selecting an index in the distributed system for calculation until all the indexes are calculated. A hierarchical traversal algorithm can also be adopted, i.e., if the indexes in the distributed system have a hierarchical structure, the indexes in the first layer are traversed first, and then the indexes in the next layer are traversed in turn until all the calculations of the indexes are completed.
[0161] For example, assuming that the distributed system includes computing storage node 1, computing storage node 2 and computing storage node 3, and the distributed system stores a plurality of shards of index A, a plurality of shards of index B and a plurality of shards of index C. The process of traversing the indexes of the distributed system is as follows: first, for the plurality of shards of index A, computing storage node 1, computing storage node 2 and computing storage node 3 are calculated in turn. Then, for the plurality of shards of index B, computing storage node 1, computing storage node 2 and computing storage node 3 are calculated in turn. Finally, for the plurality of shards of index C, computing storage node 1, computing storage node 2 and computing storage node 3 are calculated in turn.
[0162] In step 1120, for the traversed index, the shards on the plurality of computing storage nodes are migrated based on the first offset, the second offset and the third offset.
[0163] According to an embodiment of the present disclosure, in the running live of the distributed system, the indexes stored by the respective computing storage nodes can be very numerous, the number of shards of these indexes varies, and the shards of the indexes stored by each computing storage node are mostly different, which can easily cause the computing storage nodes to be unbalanced. Based on this, for each index, the embodiments of the present disclosure can sequentially traverse the plurality of computing storage nodes in the distributed system, and migrate the shards on the computing storage nodes with unbalanced loads based on the first offset, the second offset and the third offset, to achieve load balancing. Specifically, for each index, the shards of the index stored by each computing storage node are not completely the same, and naturally, the first offset of each computing storage node is also not completely the same. Moreover, from the perspective of the plurality of indexes stored by the distributed system, each computing storage node also has a different first offset for each index. The embodiments of the present disclosure accurately achieve the balancing of the number of shards of a single index stored by the computing storage nodes, the balancing of the total number of shards stored by the computing storage nodes, and the balancing of the storage space utilization of the computing storage nodes, by sequentially traversing each computing storage node for each index traversed, and migrating the shards on the plurality of computing storage nodes based on the first offset, the second offset and the third offset.
[0164] For example, referring to FIG. 12, it is assumed that the distributed system includes computing storage node 1, computing storage node 2 and computing storage node 3, and the distributed system stores index A, index B, index C and index D. In the process of balancing the loads of the plurality of computing storage nodes in the distributed system, first, for index A, computing storage node 1, computing storage node 2 and computing storage node 3 are sequentially traversed, and the shards of index A on the plurality of computing storage nodes are migrated based on the first offset, the second offset and the third offset of each computing storage node. Then, for index B, computing storage node 1, computing storage node 2 and computing storage node 3 are sequentially traversed, and the shards of index B on the plurality of computing storage nodes are migrated based on the first offset, the second offset and the third offset of each computing storage node. After that, for index C, computing storage node 1, computing storage node 2 and computing storage node 3 are sequentially traversed, and the shards of index C on the plurality of computing storage nodes are migrated based on the first offset, the second offset and the third offset of each computing storage node. Finally, for index D, computing storage node 1, computing storage node 2 and computing storage node 3 are sequentially traversed, and the shards of index D on the plurality of computing storage nodes are migrated based on the first offset, the second offset and the third offset of each computing storage node.
[0165] The specific method of "migrating the shards on the plurality of computing storage nodes based on the first offset, the second offset and the third offset for the iterated index" will be described in detail below.
[0166] The embodiments of steps 1110 to 1120 achieve the balance of the dimension of the number of shards of a single index stored by the computing storage node, the balance of the dimension of the total number of shards stored by the computing storage node and the balance of the dimension of the storage space utilization of the computing storage node by sequentially iterating each computing storage node for each iterated index and migrating the shards on the plurality of computing storage nodes based on the first offset, the second offset and the third offset.
[0167] In an embodiment, referring to FIG. 13, step 1120 comprises:
[0168] Step 1310, first sorting the plurality of computing storage nodes based on the first offset, the second offset and the third offset for the iterated index.
[0169] Step 1320, iterating the plurality of computing storage nodes according to the first sorting to, for the iterated computing storage node, when the first offset is greater than or equal to the first threshold, migrating the shards on the iterated computing storage node to the computing storage node with the first offset less than the iterated computing storage node.
[0170] Step 1330, for the iterated computing storage node, when the second offset is greater than or equal to the second threshold, migrating the shards on the iterated computing storage node to the computing storage node with the second offset less than the iterated computing storage node.
[0171] Step 1340, for the iterated computing storage node, when the third offset is greater than or equal to the third threshold, migrating the shards on the iterated computing storage node to the computing storage node with the third offset less than the iterated computing storage node.
[0172] The steps 1310 to 1340 will be described in detail as follows:
[0173] In step 1310, the plurality of computing storage nodes are first sorted based on the first offset, the second offset and the third offset for the iterated index.
[0174] The first sorting refers to the order obtained by sorting the plurality of computing storage nodes based on the first offset, the second offset and the third offset for the iterated index, which determines the iteration order of the computing storage nodes when migrating the shards, so that the computing storage nodes with unbalanced load can prioritize the migration of the shards.
[0175] According to an embodiment of the present disclosure, for each traversed index, the plurality of computing storage nodes in the distributed system need to be traversed in turn, and the migration of the shards on the plurality of computing storage nodes is performed based on the first offset, the second offset and the third offset of each computing storage node. It is conceivable that when the plurality of computing storage nodes in the distributed system are traversed, the traversal order corresponding to the computing storage node determines whether the computing storage node can prioritize the migration of the shards. Therefore, in order to determine the traversal order corresponding to the computing storage node, so that the computing storage node with unbalanced load can prioritize the migration of the shards, an embodiment of the present disclosure needs to sort the plurality of computing storage nodes based on the first offset, the second offset and the third offset for each traversed index, and the first sorting refers to the traversal order corresponding to the plurality of computing storage nodes in the distributed system for each traversed index.
[0176] The specific method of "sorting the plurality of computing storage nodes based on the first offset, the second offset and the third offset for each traversed index" will be described in detail below.
[0177] In step 1320, the plurality of computing storage nodes are traversed according to the first sorting, so as to, for the traversed computing storage node, when the first offset is greater than or equal to the first threshold, migrate the shards on the traversed computing storage node to the computing storage node with a first offset smaller than that of the traversed computing storage node.
[0178] According to an embodiment of the present disclosure, in order to balance the dimensions of the number of shards of a single index stored by the computing storage node, the dimensions of the total number of shards stored by the computing storage node, and the dimensions of the storage space utilization rate of the computing storage node, an embodiment of the present disclosure sets the priority of balancing the dimensions of the number of shards of a single index stored by the computing storage node to the first. Because the shard size allocated to each computing storage node by the scheduling node in response to the index allocation request of the target index is similar, in this case, if the number of shards stored by each computing storage node is balanced, the total number of shards stored by each computing storage node and the storage space utilization rate of the computing storage node will also tend to be balanced.
[0179] It can be understood that, for the traversed index, if the first offset of the computing storage node is less than the first threshold, it indicates that the number of shards of the single index of the computing storage node is in a balanced state. For the traversed index, when the first offset is greater than or equal to the first threshold, it indicates that the number of shards of the single index of the computing storage node is in an unbalanced state. Therefore, if the first offset of a certain computing storage node is greater than or equal to the first threshold, the shards on the computing storage node need to be migrated to a computing storage node whose first offset is less than the computing storage node, until the first offset of the computing storage node in the unbalanced state is less than the first threshold. Further, when the shards on the traversed computing storage node are migrated to a computing storage node whose first offset is less than the traversed computing storage node, it also needs to ensure that, after the migration of the shards, the first offset of the computing storage node whose first offset is less than the traversed computing storage node is less than the first threshold.
[0180] For example, assuming that the first threshold is 1, for the traversed index A, if the first offset of the computing storage node 1 is 1.5, there is a computing storage node 2 whose first offset is 0.2. At this time, the shards of the index A of the computing storage node 1 can be migrated to the computing storage node 2 until, for the index A, the first offset of the computing storage node 1 is less than 1.
[0181] The specific method of “traversing the plurality of computing storage nodes according to the first sorting, to, for the traversed computing storage node, when the first offset is greater than or equal to the first threshold, migrating the shards on the traversed computing storage node to a computing storage node whose first offset is less than the traversed computing storage node” will be described in detail below.
[0182] In step 1330, for the traversed computing storage node, when the second offset is greater than or equal to the second threshold, the shards on the traversed computing storage node are migrated to a computing storage node whose second offset is less than the traversed computing storage node.
[0183] According to an embodiment of the present disclosure, the priority of balancing the dimension of the total number of shards stored by the computing storage node can be set to the second, inferior to the priority of balancing the dimension of the number of shards of the single index stored by the computing storage node. Because the number of shards and the shard size allocated to each computing storage node by the scheduling node in response to the index allocation request of the target index are similar, under the premise that the number of shards of the single index stored by the computing storage node is balanced, if the balancing of the total number of shards stored by the computing storage node is achieved, the storage space utilization rate of the computing storage node will also tend to be balanced.
[0184] It can be understood that, for the traversed index, if the second offset of the computing storage node is less than the second threshold, it indicates that the total number of shards stored by the computing storage node is in a balanced state. For the traversed index, when the second offset is greater than or equal to the second threshold, it indicates that the total number of shards stored by the computing storage node is in an unbalanced state. Therefore, if the second offset of a certain computing storage node is greater than or equal to the second threshold, the shards on the computing storage node need to be migrated to a computing storage node whose second offset is less than the computing storage node, until the second offset of the computing storage node in the unbalanced state is less than the second threshold. Further, when the shards on the traversed computing storage node are migrated to a computing storage node whose second offset is less than the traversed computing storage node, it is also necessary to ensure that after the shard migration, the second offset of the computing storage node whose second offset is less than the traversed computing storage node is less than the second threshold.
[0185] For example, assuming that the second threshold is 50, for the traversed index A, if the second offset of the computing storage node 1 is 100, there is a computing storage node 2 whose second offset is -50. At this time, the shards of index A of the computing storage node 1 can be migrated to the computing storage node 2 until the second offset of the computing storage node 1 is less than 50 for index A.
[0186] The specific method of "for the traversed computing storage node, when the second offset is greater than or equal to the second threshold, migrating the shards on the traversed computing storage node to a computing storage node whose second offset is less than the traversed computing storage node" will be described in detail below.
[0187] In step 1340, for the traversed computing storage node, when the third offset is greater than or equal to the third threshold, the shards on the traversed computing storage node are migrated to a computing storage node whose third offset is less than the traversed computing storage node.
[0188] According to the embodiments of the present disclosure, the priority of balancing the dimension of the storage space utilization of the computing storage node can be set at last. It can be understood that, for the index being traversed, if the third offset of the computing storage node is less than the third threshold, it indicates that the storage space utilization of the computing storage node is in a balanced state. For the index being traversed, when the third offset is greater than or equal to the third threshold, it indicates that the storage space utilization of the computing storage node is in an unbalanced state. Therefore, if the third offset of a certain computing storage node is greater than or equal to the third threshold, the shards on the computing storage node need to be migrated to the computing storage node whose third offset is less than the computing storage node, until the third offset of the computing storage node in the unbalanced state is less than the third threshold. Further, when the shards on the computing storage node being traversed are migrated to the computing storage node whose third offset is less than the computing storage node being traversed, it also needs to ensure that the third offset of the computing storage node whose third offset is less than the computing storage node being traversed is less than the third threshold after the migration of the shards.
[0189] For example, assuming that the third threshold is 30, for the index A being traversed, if the third offset of the computing storage node 1 is 75, and the third offset of the computing storage node 2 is -50. At this time, the shards of the index A of the computing storage node 1 can be migrated to the computing storage node 2 until the third offset of the computing storage node 1 is less than 30 for the index A.
[0190] The specific method of "for the computing storage node being traversed, when the third offset is greater than or equal to the third threshold, migrating the shards on the computing storage node being traversed to the computing storage node whose third offset is less than the computing storage node being traversed" will be described in detail below.
[0191] It should be noted that, for each index being traversed, the plurality of computing storage nodes in the distributed system need to be traversed in turn, and for each computing storage node being traversed, the three steps of step 1320 to step 1340 need to be executed.
[0192] The embodiments of steps 1310 to 1340 are to perform first sorting on the plurality of computing storage nodes based on the first offset, the second offset and the third offset for the traversed index, so that the computing storage nodes with load imbalance can have priority in migration of the shards. Then, the plurality of computing storage nodes are traversed according to the first sorting, for the traversed computing storage node, if the first offset of the computing storage node reaches the first threshold, the shards on the computing storage node are migrated to the computing storage node with the first offset smaller than the computing storage node, which precisely realizes the balance of the dimension of the number of shards of a single index stored by the computing storage node. For the traversed computing storage node, if the second offset of the computing storage node reaches the second threshold, the shards on the computing storage node are migrated to the computing storage node with the second offset smaller than the computing storage node, which precisely realizes the balance of the dimension of the total number of shards stored by the computing storage node. For the traversed computing storage node, if the third offset of the computing storage node reaches the third threshold, the shards on the computing storage node are migrated to the computing storage node with the third offset smaller than the computing storage node, which precisely realizes the balance of the dimension of the storage space utilization of the computing storage node.
[0193] In an embodiment, there are two ways to determine the first sorting for the plurality of computing storage nodes based on the first offset, the second offset and the third offset for the traversed index, and the first way to determine the first sorting is described here, referring to FIG. 14, step 1310 includes:
[0194] Step 1410, sorting the plurality of computing storage nodes in the order of the first offset from large to small;
[0195] Step 1420, for the computing storage nodes with the same first offset, sorting in the order of the second offset from large to small;
[0196] Step 1430, for the computing storage nodes with the same second offset, sorting in the order of the third offset from large to small to form the first sorting.
[0197] The steps 1410 to 1430 are described in detail as follows.
[0198] In step 1410, the plurality of computing storage nodes are sorted in the order of the first offset from large to small.
[0199] It can be understood that, since the embodiment of the present disclosure sets the priority of balancing the dimension of the number of shards stored by the computing storage node for a single index at first, the plurality of computing storage nodes can be sorted in the order of the first offset from large to small first. After the plurality of computing storage nodes are sorted based on the first offset, for the index being traversed, the computing storage node storing the largest number of shards for the index will be ranked first, and correspondingly, the computing storage node storing the smallest number of shards for the index will be ranked last. Through such sorting, it is convenient for subsequent migration of the shards on the computing storage node to the computing storage node with a smaller second offset when the computing storage node with a second offset greater than or equal to the second threshold is traversed.
[0200] For example, referring to FIG. 15, it is assumed that the distributed system includes computing storage node A, computing storage node B, computing storage node C, computing storage node D, computing storage node E, and computing storage node F. Among them, the first offset of computing storage node A is -0.9, the first offset of computing storage node B is -0.3, the first offset of computing storage node C is 0.3, the first offset of computing storage node D is 1.5, the first offset of computing storage node E is -0.9, and the first offset of computing storage node F is 0.3. After the plurality of computing storage nodes are sorted in the order of the first offset from large to small, the sorting order obtained is: computing storage node D > computing storage node C = computing storage node F > computing storage node B > computing storage node A = computing storage node E.
[0201] In step 1420, for the computing storage nodes with the same first offset, sorting is performed in the order of the second offset from large to small.
[0202] It can be understood that, since the embodiment of the present disclosure sets the priority of balancing the dimension of the total number of shards stored by the computing storage node at second, after the plurality of computing storage nodes are sorted in the order of the first offset from large to small, for the computing storage nodes with the same first offset, sorting can be performed in the order of the second offset from large to small. Further, after the computing storage nodes with the same first offset are sorted in the order of the second offset from large to small, for the computing storage nodes with the same first offset, the computing storage node storing the largest total number of shards will be ranked first, and correspondingly, the computing storage node storing the smallest total number of shards will be ranked last. Through such sorting, it is convenient for subsequent migration of the shards on the computing storage node to the computing storage node with a smaller second offset when the computing storage node with a second offset greater than or equal to the second threshold is traversed.
[0203] For example, with reference to FIG. 15, assume that the second offset of the computing storage node A is -31, the second offset of the computing storage node B is -2, the second offset of the computing storage node C is 33, the second offset of the computing storage node D is 60, the second offset of the computing storage node E is -31, and the first offset of the computing storage node F is 25. After the plurality of computing storage nodes are sorted in the order of the first offset from large to small, the sorting order is: the computing storage node D > the computing storage node C = the computing storage node F > the computing storage node B > the computing storage node A = the computing storage node E. Based on this, the computing storage nodes with the same first offset can be sorted in the order of the second offset from large to small to obtain the sorting order: the computing storage node D > the computing storage node C > the computing storage node F > the computing storage node B > the computing storage node A = the computing storage node E.
[0204] In step 1430, for the computing storage nodes with the same second offset, the computing storage nodes are sorted in the order of the third offset from large to small to form a first sorting.
[0205] It can be understood that, since the priority of the storage space utilization rate of the computing storage node is third in the embodiments of the present disclosure, after the computing storage nodes with the same first offset are sorted in the order of the second offset from large to small, for the computing storage nodes with the same second offset, the computing storage nodes can be sorted in the order of the third offset from large to small. Further, after the computing storage nodes with the same second offset are sorted in the order of the third offset from large to small, for the computing storage nodes with the same second offset, the computing storage node with the highest storage space utilization rate will be ranked first, and correspondingly, the computing storage node with the lowest storage space utilization rate will be ranked last. Through such sorting, it is convenient for subsequent migration of the shard on the computing storage node with the third offset greater than or equal to the third threshold to the computing storage node with the third offset less than the computing storage node.
[0206] For example, with reference to FIG. 15, assume that the third offset of the computing storage node A is -2%, the third offset of the computing storage node B is 0, the third offset of the computing storage node C is 1%, the third offset of the computing storage node D is 2%, the third offset of the computing storage node E is -4%, and the third offset of the computing storage node F is 1%. After the computing storage nodes with the same first offset are sorted in the order of the second offset from large to small, the sorting order is: the computing storage node D > the computing storage node C > the computing storage node F > the computing storage node B > the computing storage node A = the computing storage node E. Based on this, the computing storage nodes with the same second offset can be sorted in the order of the third offset from large to small
[0207] , to obtain the order of: the computing storage node D > the computing storage node C > the computing storage node F > the computing storage node B > the computing storage node A > the computing storage node E.
[0208] The embodiment of the above steps 1410 to 1430 sorts the plurality of computing storage nodes based on the order of the first offset from large to small, and the computing storage node storing the largest number of shards of the traversed index will be ranked first, and the computing storage node storing the smallest number of shards of the traversed index will be ranked last. Facilitate subsequent migration of shards on the computing storage node whose first offset is greater than or equal to the first threshold to the computing storage node whose first offset is smaller than the computing storage node. Further, for the computing storage nodes with equal first offset, sort based on the order of the second offset from large to small, the computing storage node storing the largest total number of shards will be ranked first, and the computing storage node storing the smallest total number of shards will be ranked last. Facilitate subsequent migration of shards on the computing storage node whose second offset is greater than or equal to the second threshold to the computing storage node whose second offset is smaller than the computing storage node. Moreover, for the computing storage nodes with equal second offset, sort based on the order of the third offset from large to small, the computing storage node with the highest storage space utilization will be ranked first, and the computing storage node with the lowest storage space utilization will be ranked last. Facilitate subsequent migration of shards on the computing storage node whose third offset is greater than or equal to the third threshold to the computing storage node whose third offset is smaller than the computing storage node.
[0209] In an embodiment, the second way of determining the first order is described here. Referring to FIG. 16, step 1310 includes:
[0210] Step 1610, obtaining a first weight of the first offset, a second weight of the second offset, and a third weight of the third offset;
[0211] Step 1620, weighting the first offset, the second offset, and the third offset based on the first weight, the second weight, and the third weight, wherein the first weight is greater than the second weight, and the second weight is greater than the third weight;
[0212] Step 1630, first sorting the plurality of computing storage nodes based on the order of the weighted sum from large to small.
[0213] The steps 1610 to 1630 are described in detail below.
[0214] In step 1610, a first weight of the first offset, a second weight of the second offset, and a third weight of the third offset are obtained.
[0215] According to an embodiment of the present disclosure, the first weight can be used to indicate the importance of the first offset, the more important the first offset is, the greater the first weight is. Similarly, the second weight can be used to indicate the importance of the second offset, the more important the second offset is, the greater the second weight is; the third weight can be used to indicate the importance of the third offset, the more important the third offset is, the greater the third weight is.
[0216] In the embodiments of the present disclosure, the value ranges of the first weight, the second weight and the third weight can be adjusted according to the performance and load condition of the actual system. Generally, the value range of the first weight can be [50, 100], the value range of the second weight can be [1, 10], and the value range of the third weight can be [0.1, 1]. When determining these weights, the load balancing effect and processing efficiency of the system under different weight combinations can be observed by simulating the system multiple times, and the optimal weight combination can be selected. The weight values can also be determined according to the experience of the system administrator combined with the historical running data of the system. Modified as: In the embodiments of the present disclosure, the value ranges of the first weight, the second weight and the third weight can be adjusted according to the performance and load condition of the actual system. Generally, the value range of the first weight can be [50, 100], the value range of the second weight can be [1, 10], and the value range of the third weight can be [0.1, 1]. When determining these weights, the specific method of simulating the test is as follows: first, different weight combinations are set in the simulation environment, for example, the first weight starts from 50 and increases by 10 each time, the second weight starts from 1 and increases by 1 each time, and the third weight starts from 0.1 and increases by 0.1 each time, generating a series of weight combinations. Then, for each weight combination, different load scenarios are simulated in the simulation environment, such as high concurrency requests, different index change frequencies, etc., and the system is run for a period of time, and the load balancing effect (such as the balancing degree of the first offset, the second offset and the third offset of each computing storage node) and the processing efficiency (such as the average response time of the request, the throughput, etc.) of the system are recorded. Finally, the recorded data under different weight combinations are compared, and the weight combination that makes the system have the best load balancing effect and the highest processing efficiency is selected as the final weight value. When determining the weight value combined with the historical running data of the system, the system administrator can analyze the load condition of the system, the performance of each computing storage node, etc. in different time periods in the historical data. For example, if the historical data shows that the imbalance of the number of shards of a single index stored by the computing storage node has a greater impact on the system performance in some time periods, the value of the first weight can be appropriately increased; if the imbalance of the total number of shards has a greater impact on the system performance, the value of the second weight is increased; if the imbalance of the storage space utilization has a greater impact on the system performance, the value of the third weight is increased.
[0217] In step 1620, the first offset, the second offset and the third offset are weighted and based on the first weight, the second weight and the third weight, wherein the first weight is greater than the second weight, and the second weight is greater than the third weight;
[0218] It can be understood that, since the embodiment of the present disclosure sets the priority of balancing the dimension of the number of shards of a single index stored by the computing storage node as the first, sets the priority of balancing the dimension of the total number of shards stored by the computing storage node as the second, and sets the priority of the storage space utilization of the computing storage node as the third. Correspondingly, the first weight should also be set to a value greater than the second weight to indicate the importance of the first offset, and the second weight should be set to a value greater than the third weight to indicate the importance of the second offset. Specifically, in actual operation conditions, in order to highlight the priority of balancing the dimension of the number of shards of a single index stored by the computing storage node, the first weight generally needs to be set to be much greater than the second weight.
[0219] According to the embodiment of the present disclosure, the first offset, the second offset and the third offset are weighted and based on the first weight, the second weight and the third weight, and the weighted sum of the computing storage node obtained by the weighted sum of the first offset, the second offset and the third offset comprehensively reflects the importance of the first offset, the importance of the second offset and the importance of the third offset, and can accurately reflect the balanced state of the computing storage node. Specifically, the larger the weighted sum of the computing storage node is, the more shards the computing storage node needs to migrate. Correspondingly, the smaller the weighted sum of the computing storage node is, the larger the space of the computing storage node that can accommodate the shards migrated by other computing storage nodes is.
[0220] For example, referring to FIG. 17, assuming that the first weight is 50, the second weight is 1, and the third weight is 0.5. If there is a computing storage node A in the distributed system, and the first offset, the second offset and the third offset of the computing storage node A are -0.9, -31 and -2% respectively, it can be determined that the weighted sum corresponding to the computing storage node A is -76.01. If there is a computing storage node B in the distributed system, and the first offset, the second offset and the third offset of the computing storage node B are -0.3, -2 and 0 respectively, it can be determined that the weighted sum corresponding to the computing storage node B is -17. It can be imagined that the weighted sums of the computing storage node A and the computing storage node B are both less than 0, which indicates that the computing storage node A and the computing storage node B can still receive shards migrated by other computing storage nodes.
[0221] In step 1630, the first sorting of the plurality of computing storage nodes is performed based on the order of the weighted sums from large to small.
[0222] According to an embodiment of the present disclosure, the plurality of computing storage nodes are first sorted based on the weighted sum and in descending order, which can make the computing storage node that needs to migrate out the most shards be arranged at the front, and the computing storage node that can accommodate the most shards migrated out by other computing storage nodes be arranged at the back. Through such sorting, it is convenient for subsequent migration of the shards stored by the computing storage node that needs to migrate shards to the computing storage node that can accommodate the shards migrated out by other computing storage nodes.
[0223] For example, referring to FIG. 17, it is assumed that the first weight is 50, the second weight is 1, and the third weight is 0.5. Through calculation, it is determined that the weighted sum corresponding to the computing storage node A is -76.01, the weighted sum corresponding to the computing storage node B is -17, the weighted sum corresponding to the computing storage node C is 48.005, the weighted sum corresponding to the computing storage node D is 125.01, the weighted sum corresponding to the computing storage node E is -17, and the weighted sum corresponding to the computing storage node F is 40.005. After the plurality of computing storage nodes are first sorted based on the weighted sum and in descending order, the sorting order can be: the computing storage node D > the computing storage node C > the computing storage node F > the computing storage node B > the computing storage node A > the computing storage node E.
[0224] The embodiments of the above steps 1610 to 1630 weight the first offset, the second offset, and the third offset based on the first weight, the second weight, and the third weight, and the weighted sum of the computing storage nodes obtained by the weighting comprehensively reflects the importance of the first offset, the importance of the second offset, and the importance of the third offset, and can accurately reflect the balanced state of the computing storage nodes. Moreover, the plurality of computing storage nodes can be first sorted based on the weighted sum and in descending order, which can make the computing storage node that needs to migrate out the most shards be arranged at the front, and the computing storage node that can accommodate the most shards migrated out by other computing storage nodes be arranged at the back. Such sorting manner is convenient for subsequent migration of the shards stored by the computing storage node that needs to migrate shards to the computing storage node that can accommodate the shards migrated out by other computing storage nodes.
[0225] In an embodiment, there are two implementation manners of “when the first offset is greater than or equal to the first threshold, migrating the shards on the computing storage node to the computing storage node whose first offset is smaller than that of the computing storage node”, and the first implementation manner is described here. Referring to FIG. 18, the step 1320 includes:
[0226] Step 1810, second sorting the computing storage nodes in the order of the first offset from small to large;
[0227] Step 1820, initialize the first target migration computing storage node as the first computing storage node in the second order;
[0228] Step 1830, select the first target shard on the traversed computing storage node;
[0229] Step 1840, migrate the first target shard from the traversed computing storage node to the first target migration computing storage node, and when the first offset is still greater than or equal to the first threshold after migration, update the first target migration computing storage node with the next computing storage node in the second order, and return to the step of migrating the first target shard from the traversed computing storage node to the first target migration computing storage node until the first offset is less than the first threshold after migration.
[0230] The first target migration computing storage node refers to the computing storage node that receives the shard migrated out by the traversed computing storage node when the first offset is greater than or equal to the first threshold, and is initialized as the first computing storage node in the second order and updated according to the situation during the migration process.
[0231] The first target shard refers to the shard that needs to be migrated out by the traversed computing storage node whose first offset reaches the first threshold, and is selected by a specific method so that its size matches the first offset, thereby improving the efficiency of shard migration.
[0232] The steps 1810 to 1840 are described in detail below.
[0233] In step 1810, the computing storage nodes are second-ordered according to the first offset from small to large.
[0234] According to an embodiment of the present disclosure, the second ordering refers to ascending ordering of the computing storage nodes based on the first offset, so that the one with the smallest first offset is ranked first and the one with the largest first offset is ranked last. The second ordering specifically refers to the order obtained after ascending ordering of the computing storage nodes based on the first offset, so that the computing storage node with the smallest first offset is ranked first and the one with the largest first offset is ranked last, which is used to determine the selection order of the target computing storage node that receives the shard migrated out by the traversed computing storage node when the first offset is greater than or equal to the first threshold. Wherein, the smallest first offset means that the computing storage node can accommodate the most shards migrated out by other computing storage nodes. The largest first offset means that the computing storage node needs to migrate out the most shards.
[0235] For example, referring to FIG. 19, it is assumed that the distributed system includes a computing storage node A, a computing storage node B, a computing storage node C, a computing storage node D, a computing storage node E, and a computing storage node F. The first offset of the computing storage node A is -0.9, the first offset of the computing storage node B is -0.3, the first offset of the computing storage node C is 0.3, the first offset of the computing storage node D is 1.5, the first offset of the computing storage node E is -0.8, and the first offset of the computing storage node F is 0.5. The computing storage nodes are second-ordered according to the first offset in ascending order, and the second order is: the computing storage node A, the computing storage node E, the computing storage node B, the computing storage node C, the computing storage node F, and the computing storage node D.
[0236] In step 1820, a first target migration computing storage node is initialized as the first computing storage node in the second order.
[0237] According to an embodiment of the present disclosure, the first target migration computing storage node refers to a computing storage node that receives the shards migrated out by the computing storage node whose first offset reaches the first threshold. It can be understood that the first computing storage node in the second order can accommodate the most shards migrated out by other computing storage nodes. The first target migration computing storage node is determined as the first computing storage node in the second order, so that the first target migration computing storage node can receive as many shards as possible. Further, when the first target migration computing storage node is determined, it is necessary to ensure that the first offset of the first target migration computing storage node is still less than the first threshold after the first target migration computing storage node receives the shards migrated out by the computing storage node whose first offset reaches the first threshold.
[0238] For example, referring to FIG. 19, it is assumed that the second order is: the computing storage node A, the computing storage node E, the computing storage node B, the computing storage node C, the computing storage node F, and the computing storage node D. Thus, the first target migration computing storage node can be initialized as the computing storage node A.
[0239] In step 1830, a first target shard is selected on the computing storage node whose first offset reaches the first threshold.
[0240] According to an embodiment of the present disclosure, the first target shard refers to a shard that needs to be migrated out of the computing storage node whose first offset reaches the first threshold. As shown in FIG. 20A, for the same index, the computing storage node can store multiple shards of the index, and different shards have different loads, and the different loads of the shards also affect the first offset of the computing storage node. The shard with a larger load can make the first offset of the computing storage node larger, and naturally, migrating the shard out of the computing storage node will also significantly reduce the first offset of the computing storage node. Based on this, when migrating the shard in the computing storage node whose first offset reaches the first threshold, the first target shard with a proper size needs to be selected first.
[0241] The specific method of "selecting the first target shard on the traversed computing storage node" will be described in detail below.
[0242] In step 1840, the first target shard is migrated from the traversed computing storage node to the first target migration computing storage node, and when the first offset is still greater than or equal to the first threshold after migration, the first target migration computing storage node is updated with the next computing storage node in the second order, and the step of migrating the first target shard from the traversed computing storage node to the first target migration computing storage node is returned until the first offset is less than the first threshold after migration.
[0243] According to an embodiment of the present disclosure, after the first target shard and the first target migration computing storage node are determined, the first target shard can be migrated from the traversed computing storage node to the first target migration computing storage node. For example, referring to FIG. 20A, assuming that for the traversed index A, the first offset of the traversed computing storage node D reaches the first threshold, and the first target migration computing storage node A and the first target shard of index A have been determined. Then, the shard of index A can be migrated from the computing storage node D to the computing storage node A. FIG. 20B is a schematic diagram of the computing storage node A and the computing storage node D after the shard migration is completed. It can be obtained that the first target shard is no longer stored in the computing storage node D, and the first target shard is stored in the computing storage node A.
[0244] Further, after the first target shard is migrated from the traversed computing storage node to the first target migration computing storage node, the first offset of the traversed computing storage node and the first target migration computing storage node will both change. At this time, when the first offset of the traversed computing storage node after migration is still greater than or equal to the first threshold, it indicates that the traversed computing storage node still needs to select the first target shard to migrate out. Meanwhile, to avoid the situation that the first offset of the same computing storage node reaches the first threshold due to continuously receiving shards, the first target migration computing storage node also needs to be updated together with the first target shard. Therefore, after each time the first target shard is migrated from the traversed computing storage node, the first target shard and the first target migration computing storage node need to be updated and selected. When the first target migration computing storage node is updated, the next computing storage node of the first target migration computing storage node before the second sorting relay is updated is generally determined as the first target migration computing storage node after the update. When the first target shard is updated, the size of the first target shard after the update is similar to the size of the first target shard before the update.
[0245] According to an embodiment of the present disclosure, after the first target shard and the first target migration computing storage node are updated, the step of migrating the first target shard from the traversed computing storage node to the first target migration computing storage node is returned to migrate the updated first target shard from the traversed computing storage node to the updated first target migration computing storage node until the first offset of the traversed computing storage node after migration is less than the first threshold. For a certain index, when the first offset of the traversed computing storage node is less than the first threshold, it indicates that the computing storage node has achieved the balance of the number of shards of the dimension of the index.
[0246] In an embodiment, when the first offset is greater than or equal to the first threshold, migrating the shard on the traversed computing storage node to the computing storage node whose first offset is less than the first offset of the traversed computing storage node also includes: when the first target migration computing storage node is the last computing storage node in the second sorting, and the first offset after migration is still greater than or equal to the first threshold, reselecting the first target shard from the shards that have not been selected on the traversed computing storage node, updating the first target migration computing storage node with the first computing storage node in the second sorting, and returning to the step of migrating the first target shard from the traversed computing storage node to the first target migration computing storage node.
[0247] It can be understood that, in the case that the first target migration computing storage node is the last computing storage node in the second order, if the first offset of the traversed computing storage node is still greater than or equal to the first threshold after the first target shard is migrated from the traversed computing storage node to the first target migration computing storage node, it indicates that the index shard quantity dimension balance of the computing storage node has not been achieved at this time. The most likely reason is that the size of the first target shard is too small. In the case that the size of the first target shard is too small, even if the traversed computing storage node performs multiple shard migration operations, the first offset of the traversed computing storage node is still greater than or equal to the first threshold. Therefore, at this time, a larger first target shard needs to be reselected on the traversed computing storage node, and the second order of each computing storage node is updated, and the first target migration computing storage node is updated with the first computing storage node in the updated second order.
[0248] According to an embodiment of the present disclosure, after the reselected first target shard is migrated from the traversed computing storage node to the first target migration computing storage node, if the first offset of the traversed computing storage node is still greater than or equal to the first threshold, the first target migration computing storage node needs to be updated with the next computing storage node of the current first target migration computing storage node in the updated second order. After that, the shard migration and the operation of updating the first target migration computing storage node and the first target shard are looped until the first offset of the traversed computing storage node is less than the first threshold.
[0249] It should be noted that, only in the case that the first target migration computing storage node is the last computing storage node in the second order, and the first offset of the traversed computing storage node is still greater than or equal to the first threshold after migration, the first target shard needs to be reselected.
[0250] For example, assuming that for the index A being traversed, the first offset of the traversed computing storage node D reaches the first threshold, and the second order is computing storage node A, computing storage node B, and computing storage node C. After determining the first target shard with a size of 10 MB, the first target shard is first migrated from the computing storage node D to the computing storage node A. When the first offset of the computing storage node D after the migration is still greater than or equal to the first threshold, the computing storage node B is used to update the first target migration computing storage node. Then, the first target shard is updated, and the first target shard is migrated from the computing storage node D to the computing storage node B. When the first offset of the computing storage node D after the migration is still greater than or equal to the first threshold, the computing storage node C is used to update the first target migration computing storage node. After that, the first target shard is updated, and the first target shard is migrated from the computing storage node D to the computing storage node C. When the first offset of the computing storage node D after the migration is still greater than or equal to the first threshold, a first target shard is reselected from the shards that have not been selected on the computing storage node D, and the reselected first target shard is 20 MB. Assuming that the updated second order is still computing storage node A, computing storage node B, and computing storage node C. At this time, the reselected first target shard can be migrated from the computing storage node D to the computing storage node A, and the operations of shard migration and updating the first target migration computing storage node and the first target shard are circularly performed until the first offset of the computing storage node D is less than the first threshold.
[0251] The embodiments of the above steps 1810 to 1840 can make the first target migration computing storage node receive as many shards as possible by initializing the first target migration computing storage node as the first computing storage node in the second order. Further, the embodiments of the present disclosure accurately achieve the balancing of the number of shards of a single index stored by the computing storage nodes in the dimension by selecting a suitable first target shard and migrating the first target shard from the traversed computing storage node to the first target migration computing storage node. Moreover, when the first offset after the migration is still greater than or equal to the first threshold, the embodiments of the present disclosure further use the next computing storage node of the first target migration computing storage node before the update in the second order as the updated first target migration computing storage node to perform shard migration, and circularly perform this step until the first offset after the migration is less than the first threshold. By updating the first target migration computing storage node, the present disclosure avoids the situation that the same computing storage node continuously receives shards and the first offset reaches the first threshold, and accurately balances the number of shards of a single index of the plurality of computing storage nodes.
[0252] In an embodiment, referring to FIG. 21, the step 1830 includes:
[0253] Step 2110, obtaining the shard size of each shard on the traversed computing storage node;
[0254] Step 2120, determining the average shard size based on the shard size of each shard;
[0255] Step 2130, determining the first multiple of the shard size of each shard relative to the average shard size;
[0256] Step 2140, selecting the shard whose first multiple matches the first offset as the first target shard.
[0257] The steps 2110 to 2140 will be described in detail below.
[0258] In step 2110, the shard size of each shard on the traversed computing storage node is obtained.
[0259] According to an embodiment of the present disclosure, for the computing storage node whose first offset reaches the first threshold, the shard in the computing storage node needs to be migrated out. For each index, the computing storage node stores a plurality of shards with different sizes. In order to accurately determine the shard to be migrated out, the shard size of each shard on the traversed computing storage node needs to be obtained first.
[0260] It can be understood that for each index in the distributed system, each computing storage node stores the shard size of the shard of the index. When the shard size of each shard on the traversed computing storage node needs to be obtained, the scheduling node can directly send an obtaining request to the traversed computing storage node to obtain the shard size of each shard on the computing storage node.
[0261] The obtaining request can adopt a specific message format, for example, containing the request type (identified as the shard size obtaining request), the index identification of the request, the identification of the scheduling node, and the like. After receiving the request, the computing storage node parses the request content, finds the shard size of each shard under the index according to the index identification in the request, encapsulates the shard size information according to the pre-agreed response format, for example, adopts the JSON format, contains the index identification and the shard size list of each shard, and then returns the response message to the scheduling node.
[0262] For example, referring to FIG. 22, assuming that for index A, the computing storage node D is traversed, then the shard size of each shard of index A on the computing storage node D can be obtained as 50MB, 53MB, 60MB and 55MB.
[0263] In step 2120, the average shard size is determined based on the shard size of each shard.
[0264] According to an embodiment of the present disclosure, the average shard size is an average of sizes of the respective shards.
[0265] For example, assuming that the traversal reaches the computing storage node D for the index A, the shard sizes of the respective shards of the index A on the computing storage node D are 50 MB, 53 MB, 60 MB, and 55 MB respectively. Through calculation, it can be determined that the average shard size of the index A stored by the computing storage node D is 54.5 MB.
[0266] In step 2130, a first multiple of the shard size of the respective shard relative to the average shard size is determined.
[0267] According to an embodiment of the present disclosure, the first multiple refers to a quotient of the shard size of the shard divided by the average shard.
[0268] For example, assuming that the traversal reaches the computing storage node D for the index A, the shard sizes of the respective shards of the index A on the computing storage node D are 50 MB, 53 MB, 60 MB, and 55 MB respectively, and the average shard size of the index A stored by the computing storage node D is 54.5 MB. Based on this, it can be determined that the first multiples of the shard sizes of the respective shards relative to the average shard size are 100 / 109, 106 / 109, 120 / 109, and 110 / 109 respectively.
[0269] In step 2140, a shard whose first multiple matches the first offset is selected as a first target shard.
[0270] According to an embodiment of the present disclosure, if a shard whose first multiple does not match the first offset is selected as the first target shard, the following situation can occur: the first offset is too large (i.e., a large number of shards need to be migrated out), but the first multiple is too small (i.e., the shard is too small), and after performing multiple shard migration steps, the first offset of the traversed computing storage node is still greater than or equal to the first threshold, reducing the efficiency of shard migration. Based on this, a shard whose first multiple matches the first offset can be selected as the first target shard to reduce the number of times of performing shard migration and improve the efficiency of shard migration, and also improve the speed of balancing the dimension of the number of shards of a single index of the computing storage node.
[0271] It can be understood that the first offset and the first multiple are in a proportional relationship. Based on this, a function of the first offset and the first multiple can be constructed in advance according to the running status of the computing storage node, and after the first offset is determined, the first offset is substituted into the function of the first offset and the first multiple to determine the first multiple that matches the first offset. Then, the corresponding shard can be selected based on the first multiple that matches the first offset, and the shard is taken as the first target shard.
[0272] According to an embodiment of the present disclosure, the first multiple matching the first offset can also be selected by looking up a table, and the corresponding shard can be selected based on the first multiple matching the first offset. A first multiple corresponding to the first offset can be obtained by looking up a pre-set first offset and first multiple correspondence table according to the first offset. Based on this, the shard with the first multiple matching the first offset can be quickly found.
[0273] For example, the first offset and the first multiple can be in a proportional relationship. Based on this, a function of the first offset and the first multiple can be constructed in advance according to the running status of the computing storage node, for example, a function f(x)=0.4x+0.8 (where x is the first offset). After the first offset is determined, the first offset is substituted into the function to determine the first multiple matching the first offset. Then, the corresponding shard can be selected based on the first multiple matching the first offset, and the shard is taken as the first target shard. The first multiple matching the first offset can also be selected by looking up a table, for example, the correspondence table of the first offset and the first multiple is as follows: when the first offset is in [0, 0.5), the corresponding first multiple is in the range of [0.8, 1); when the first offset is in [0.5, 1), the corresponding first multiple is in the range of [1, 1.2); when the first offset is in [1, 1.5), the corresponding first multiple is in the range of [1.2, 1.4), and so on. The first multiple corresponding to the first offset can be obtained by looking up the correspondence table according to the first offset, and the corresponding shard is selected as the first target shard.
[0274] The embodiments of steps 2110 to 2140 can determine the average shard size based on the shard sizes of the shards on the traversed computing storage node, and determine the first multiple of the shard size of each shard relative to the average shard size. By selecting the shard with the first multiple matching the first offset as the first target shard, the number of times of performing shard migration can be reduced, the efficiency of shard migration can be improved, and the speed of balancing the dimension of the number of shards of the single index of the computing storage node can also be improved.
[0275] In an embodiment, the first embodiment of “when the first offset is greater than or equal to the first threshold, migrating the shard on the traversed computing storage node to the computing storage node with the first offset smaller than the traversed computing storage node” is described here. Referring to FIG. 23, step 1320 includes:
[0276] Step 2310, obtaining the shard size of each shard on the traversed computing storage node;
[0277] Step 2320, determining the average shard size based on the shard size of each shard;
[0278] Step 2330, determining a second multiple of a size of a target shard in each shard relative to the average shard size;
[0279] Step 2340, calculating a first difference between the first offset of the traversed computing storage node and the first offset of each to-be-inspected computing storage node, the to-be-inspected computing storage node being a computing storage node with a first offset smaller than that of the traversed computing storage node;
[0280] Step 2350, matching the other computing storage node with the second multiple and the first difference as a target computing storage node, and migrating the target shard to the target computing storage node.
[0281] The steps 2310 to 2350 are described in detail as follows:
[0282] In step 2310, the sizes of the shards on the traversed computing storage node are obtained.
[0283] It can be understood that the method of obtaining the sizes of the shards on the traversed computing storage node has been explained in the embodiments of step 2110 above, and will not be repeated here.
[0284] In step 2320, the average shard size is determined based on the sizes of the shards.
[0285] It can be understood that the method of determining the average shard size based on the sizes of the shards has been explained in the embodiments of step 2120 above, and will not be repeated here.
[0286] In step 2330, a second multiple of a size of a target shard in each shard relative to the average shard size is determined.
[0287] According to embodiments of the present disclosure, the target shard refers to a shard that needs to be migrated out of the computing storage node whose first offset reaches the first threshold, wherein the target shard can be randomly selected from the shards of the index stored in the traversed computing storage node, or obtained by a predetermined determination method. The specific method of determining the target shard will be described in detail below. The second multiple refers to the quotient of the size of the target shard divided by the average shard size.
[0288] It can be understood that the method of determining the second multiple of the size of the target shard in each shard relative to the average shard size is similar to the method of step 2130 above, and will not be repeated here.
[0289] In step 2340, a first difference between the first offset of the traversed computing storage node and the first offset of each to-be-considered computing storage node is calculated, the to-be-considered computing storage node being the computing storage node whose first offset is less than the first offset of the traversed computing storage node.
[0290] According to the embodiment of the present disclosure, if there is a certain computing storage node whose first offset is less than the first offset of the traversed computing storage node, the computing storage node is defined as the to-be-considered computing storage node. The to-be-considered computing storage node refers to the computing storage node whose first offset is less than the first offset of the traversed computing storage node when the first offset is greater than or equal to the first threshold, and is used to calculate the difference between the first offset of the traversed computing storage node to determine the appropriate target computing storage node to receive the migrated shard. The first difference refers to the difference between the first offset of the traversed computing storage node and the first offset of the to-be-considered computing storage node. The reason for calculating the first difference between the first offset of the traversed computing storage node and the first offset of each to-be-considered computing storage node is that the difference between the number of shards stored by the traversed computing storage node and the number of shards stored by each to-be-considered computing storage node needs to be determined, and through the difference, the size of the shard that the to-be-considered computing storage node can receive from the traversed computing storage node can be more clearly known.
[0291] For example, referring to FIG. 24, it is assumed that the distributed system includes computing storage node A, computing storage node B, computing storage node C, computing storage node D, computing storage node E, and computing storage node F. If the current traversed computing storage node is computing storage node D, it can be determined that computing storage node A, computing storage node B, computing storage node C, computing storage node E, and computing storage node F are to-be-considered computing storage nodes. Moreover, the first difference between the first offset of computing storage node D and the first offset of computing storage node A is -0.9, the first difference between the first offset of computing storage node D and the first offset of computing storage node B is -0.3, the first difference between the first offset of computing storage node D and the first offset of computing storage node C is 0.3, the first difference between the first offset of computing storage node D and the first offset of computing storage node E is -0.9, and the first difference between the first offset of computing storage node D and the first offset of computing storage node F is 0.3.
[0292] In step 2350, the other computing storage node matched with the second multiple and the first difference is taken as the target computing storage node, and the target shard is migrated to the target computing storage node.
[0293] The target computing storage node refers to another computing storage node whose second multiple matches the first difference when the first offset is greater than or equal to the first threshold, and the node is used as a node receiving the target shard migration to improve the efficiency of the shard migration.
[0294] According to an embodiment of the present disclosure, the greater the second multiple, the greater the shard size of the target shard. The greater the first difference, the greater the size of the shard migrated by the traversed computing storage node that the computing storage node to be investigated can receive. By matching the computing storage node whose second multiple matches the first difference as the target computing storage node, the number of times of performing shard migration can be reduced, and the efficiency of shard migration can be improved.
[0295] Exemplarily, before matching the computing storage node whose second multiple matches the first difference as the target computing storage node, it is necessary to first determine the first difference matching the second multiple, and then find the appropriate computing storage node according to the first difference. Based on the second multiple, the matching first difference can be determined by using a table lookup method. According to the second multiple, a pre-set second multiple and first difference correspondence table is looked up to obtain the first difference corresponding to the second multiple. Moreover, based on the second multiple, the first difference can also be determined by using a formula substitution method. The second multiple is substituted into a pre-set second multiple and first difference formula to obtain the first difference corresponding to the second multiple.
[0296] For example, based on the second multiple, the matching first difference can be determined by using a table lookup method. For example, a pre-set second multiple and first difference correspondence table is as follows: when the second multiple is in [1, 1.2), the corresponding first difference range is [1, 2); when the second multiple is in [1.2, 1.4), the corresponding first difference range is [2, 3); when the second multiple is in [1.4, 1.6), the corresponding first difference range is [3, 4), and so on. According to the second multiple, the correspondence table is looked up to obtain the first difference corresponding to the second multiple. Moreover, based on the second multiple, the first difference can also be determined by using a formula substitution method, for example, a pre-set formula of the second multiple m and the first difference n is n = 2m-1. The second multiple is substituted into the formula to obtain the first difference corresponding to the second multiple.
[0297] For example, referring to FIG. 24, assuming that the current iteration is to the computing storage node D, the first difference between the first offset of the computing storage node D and the first offset of the computing storage node A is -0.9, the first difference between the first offset of the computing storage node D and the first offset of the computing storage node B is -0.3, the first difference between the first offset of the computing storage node D and the first offset of the computing storage node C is 0.3, the first difference between the first offset of the computing storage node D and the first offset of the computing storage node E is -0.9, and the first difference between the first offset of the computing storage node D and the first offset of the computing storage node F is 0.3. Assuming that the second multiple of the target shard of the computing storage node D relative to the average shard size is 1.2 for the index A, according to the second multiple and first difference correspondence table, the range of the first difference matching the second multiple is (2, 3]. Based on this, the computing storage node A or the computing storage node E can be used as the target computing storage node.
[0298] The embodiments of the above steps 2310 to 2350 calculate the average shard size based on the shard size of each shard, determine the second multiple of the shard size of the target shard relative to the average shard size, determine the difference between the number of shards stored in the computing storage node to which the iteration is performed and the number of shards stored in each to-be-considered computing storage node. Further, by calculating the first difference between the first offset of the computing storage node to which the iteration is performed and the first offset of each to-be-considered computing storage node, the computing storage node with the second multiple matching the first difference is used as the target computing storage node, so as to migrate the target shard to the target computing storage node, which can reduce the number of times of performing shard migration and improve the efficiency of shard migration.
[0299] In an embodiment, referring to FIG. 25, the target shard in step 2330 is determined from each shard in the following manner:
[0300] Step 2510, determining the storage capacity of the computing storage node to which the iteration is performed;
[0301] Step 2520, determining the storage space utilization of the computing storage node to which the iteration is performed;
[0302] Step 2530, obtaining the shard size of each shard;
[0303] Step 2540, determining the target shard from each shard based on the storage capacity, the storage space utilization, and the shard size of each shard.
[0304] The steps 2510 to 2540 are described in detail as follows:
[0305] In step 2510, the storage capacity of the computing storage node to which the iteration is performed is determined.
[0306] According to an embodiment of the present disclosure, the target shard that needs to be migrated out of the traversed compute storage node can be determined by a plurality of factors, one of which is the storage capacity of the traversed compute storage node. It can be conceived that the larger the storage capacity of the traversed compute storage node is, the more likely it is that the compute storage node stores a plurality of heavily loaded shards.
[0307] In step 2520, the storage space utilization of the traversed compute storage node is determined.
[0308] According to an embodiment of the present disclosure, after the storage capacity and the storage space utilization of the traversed compute storage node are determined, the remaining storage space of the traversed compute storage node can be determined. The remaining storage space of the compute storage node determines the ability of the compute storage node to receive shards in subsequent operating conditions, and the shard size of the target shard that needs to be migrated out of the compute storage node.
[0309] For example, it is assumed that the storage capacity of the traversed compute storage node 1 is determined to be 900 MB. If the storage space utilization of the current compute storage node 1 is 80%, it means that the remaining storage space of the compute storage node 1 is 180 MB. If the storage space utilization of the current compute storage node 1 is 50%, it means that the remaining storage space of the compute storage node 1 is 450 MB.
[0310] In step 2530, the shard size of each shard is obtained.
[0311] According to an embodiment of the present disclosure, because the size of the remaining storage space of the compute storage node determines the size of the target shard to be migrated out, in order to accurately select the target shard from each shard stored in the traversed compute storage node, the shard size of each shard also needs to be obtained.
[0312] For example, it is assumed that for index A, the traversed compute storage node 1 stores shard 1, shard 2 and shard 3. By obtaining, it can be obtained that the shard size of shard 1 is 10 MB, the shard size of shard 2 is 15 MB, and the shard size of shard 3 is 13 MB.
[0313] In step 2540, the target shard is determined in each shard based on the storage capacity, the storage space utilization and the shard size of each shard.
[0314] The target shard is determined in each shard based on the storage capacity, the storage space utilization and the shard size of each shard. Specifically, the residual storage space of the computing storage node is calculated according to the storage capacity and the storage space utilization, i.e., residual storage space = storage capacity x (1-storage space utilization). If the residual storage space is small, a shard with a larger shard size is selected as the target shard, and each shard can be arranged in descending order of shard size, and the shard at the front is selected; if the residual storage space is large, a shard with a smaller shard size is selected as the target shard, and each shard can be arranged in ascending order of shard size, and the shard at the front is selected. For example, if the residual storage space is calculated to be 100 MB, and the shard sizes of each shard are 20 MB, 30 MB, 50 MB and 80 MB, since the residual storage space is small, the shard with a size of 80 MB is selected as the target shard; if the residual storage space is 500 MB, the shard with a size of 20 MB is selected as the target shard.
[0315] According to an embodiment of the present disclosure, the residual storage space of the traversed computing storage node can be determined based on the storage capacity and the storage space utilization of the traversed computing storage node. It is conceivable that if the residual storage space of the computing storage node is small, a target shard with a larger shard size can be selected to be migrated from the traversed computing storage node. If the residual storage space of the computing storage node is large, a target shard with a smaller shard size can be selected to be migrated from the traversed computing storage node.
[0316] For example, it is assumed that the storage capacity of the traversed computing storage node 1 is determined to be 500 MB, and the computing storage node 1 stores shard 1, shard 2, shard 3 and shard 4 for index A. By obtaining, it is found that the shard size of shard 1 is 50 MB, the shard size of shard 2 is 45 MB, the shard size of shard 3 is 47 MB, and the shard size of shard 4 is 52 MB. If the storage space utilization of the current computing storage node 1 is 80%, it indicates that the residual storage space of the computing storage node 1 is 100 MB, and shard 4 can be selected as the target shard to be migrated from the computing storage node 1. If the storage space utilization of the current computing storage node 1 is 50%, it indicates that the residual storage space of the computing storage node 1 is 250 MB, and shard 2 can be selected as the target shard to be migrated from the computing storage node 1.
[0317] The embodiments of steps 2510 to 2540 can determine the remaining storage space of the traversed computing storage node based on the storage capacity and the storage space utilization of the traversed computing storage node. Further, the size of the target shard to be migrated out is determined by the size of the remaining storage space of the computing storage node. If the remaining storage space of the computing storage node is small, a target shard with a larger shard size can be selected to be migrated out from the traversed computing storage node. If the remaining storage space of the computing storage node is large, a target shard with a smaller shard size can be selected to be migrated out from the traversed computing storage node. In this way, the target shard to be migrated out from the traversed computing storage node can be accurately determined, the number of shard migration operations is reduced, and the efficiency of shard migration is improved.
[0318] In an embodiment, referring to FIG. 26, step 1330 includes:
[0319] Step 2610, sorting the computing storage nodes in the second order from small to large according to the second offset;
[0320] Step 2620, initializing the second target migration computing storage node as the first computing storage node in the third order;
[0321] Step 2630, selecting a second target shard on the traversed computing storage node;
[0322] Step 2640, migrating the second target shard from the traversed computing storage node to the second target migration computing storage node, and when the second offset is still greater than or equal to the second threshold after migration, updating the second target migration computing storage node with the next migration computing storage node in the third order, and returning to the step of migrating the second target shard from the traversed computing storage node to the second target migration computing storage node until the second offset is less than the second threshold after migration.
[0323] The second target migration computing storage node refers to the computing storage node that receives the shard migrated out by the traversed computing storage node when the second offset is greater than or equal to the second threshold, and is initialized as the first computing storage node in the third order and updated according to the situation during the migration process.
[0324] The second target shard refers to the shard that needs to be migrated out from the computing storage node whose second offset reaches the second threshold, and the shard with an appropriate size is selected to reduce the second offset of the computing storage node, so as to balance the dimensions of the total number of shards.
[0325] The steps 2610 to 2640 are described in detail as follows:
[0326] In step 2610, the computing storage nodes are sorted in a third order according to the second offset in ascending order.
[0327] According to an embodiment of the present disclosure, the third sorting refers to sorting the computing storage nodes in ascending order based on the second offset, so that the computing storage node with the smallest second offset is ranked first and the computing storage node with the largest second offset is ranked last. The third sorting specifically refers to the order obtained after sorting the computing storage nodes in ascending order based on the second offset, so that the computing storage node with the smallest second offset is ranked first and the computing storage node with the largest second offset is ranked last, which is used to determine the selection order of the target computing storage node receiving the migrated shards of the computing storage node traversed when the second offset is greater than or equal to the second threshold. Wherein, the smallest second offset means that the computing storage node currently stores the smallest number of shards, which can accommodate the most shards migrated by other computing storage nodes. The largest second offset means that the computing storage node currently stores the largest number of shards, which needs to migrate the most shards.
[0328] For example, referring to FIG. 27, it is assumed that the distributed system includes computing storage node A, computing storage node B, computing storage node C, computing storage node D, computing storage node E, and computing storage node F. The second offset of computing storage node A is -31, the second offset of computing storage node B is -2, the second offset of computing storage node C is 33, the second offset of computing storage node D is 60, the second offset of computing storage node E is -28, and the second offset of computing storage node F is 25. The computing storage nodes are sorted in a third order according to the second offset in ascending order, and the third sorting can be obtained as: computing storage node A, computing storage node E, computing storage node B, computing storage node F, computing storage node C, and computing storage node D.
[0329] In step 2620, the second target migration computing storage node is initialized as the first computing storage node in the third sorting.
[0330] According to an embodiment of the present disclosure, the second target migration computing storage node refers to the computing storage node receiving the shards migrated by the computing storage node whose second offset reaches the second threshold. It can be understood that the first computing storage node in the third sorting can accommodate the most shards migrated by other computing storage nodes, and determining the second target migration computing storage node as the first computing storage node in the third sorting can make the second target migration computing storage node receive as many shards as possible. Further, when determining the second target migration computing storage node, it is necessary to ensure that the first offset of the second target migration computing storage node is less than the first threshold and the second offset is still less than the second threshold after receiving the shards migrated by the computing storage node traversed.
[0331] For example, referring to FIG. 27, it is assumed that the third ranking is: computing storage node A, computing storage node E, computing storage node B, computing storage node F, computing storage node C, and computing storage node D, and thus the second target migration computing storage node can be initialized as computing storage node A.
[0332] In step 2630, a second target shard is selected on the computing storage node that is traversed.
[0333] According to an embodiment of the present disclosure, the second target shard refers to a shard that needs to be migrated out of the computing storage node whose second offset reaches the second threshold. As shown in FIG. 28A, the computing storage node stores multiple shards of different indexes, the sizes of the multiple shards of different indexes are not the same, and the sizes of the multiple shards of the same index are also not completely the same. The computing storage node storing a shard with a larger load can cause the second offset of the computing storage node to be large, and naturally, migrating the shard out of the computing storage node will also significantly reduce the second offset of the computing storage node. Based on this, when migrating the shard in the computing storage node whose second offset reaches the second threshold, a second target shard with a proper size needs to be selected first.
[0334] In step 2640, the second target shard is migrated from the computing storage node that is traversed to the second target migration computing storage node, and when the second offset is still greater than or equal to the second threshold after the migration, the second target migration computing storage node is updated with the next migration computing storage node in the third ranking, and the step of migrating the second target shard from the computing storage node that is traversed to the second target migration computing storage node is returned until the second offset is less than the second threshold after the migration.
[0335] According to an embodiment of the present disclosure, after the second target shard and the second target migration computing storage node are determined, the second target shard can be migrated from the computing storage node that is traversed to the second target migration computing storage node. For example, referring to FIG. 28A, it is assumed that for the index B that is traversed, the second offset of the computing storage node D that is traversed reaches the second threshold, and the second target migration computing storage node is determined as computing storage node A and the second target shard is determined as a shard of index B. Then, the shard of index B can be migrated from the computing storage node D to the computing storage node A. FIG. 28B is a schematic diagram of the computing storage node A and the computing storage node D after the shard migration is completed, and it can be obtained that the second target shard is no longer stored in the computing storage node D and the second target shard is stored in the computing storage node A.
[0336] Further, after the second target shard is migrated from the traversed computing storage node to the second target migration computing storage node, the second offset of the traversed computing storage node and the second target migration computing storage node will both change. At this time, when the second offset of the traversed computing storage node after migration is still greater than or equal to the second threshold, it indicates that the traversed computing storage node still needs to select a second target shard to migrate out. Meanwhile, to avoid the situation that the same computing storage node continuously receives shards and the second offset reaches the second threshold, the second target migration computing storage node also needs to be updated together with the second target shard. Therefore, after each time the second target shard is migrated from the traversed computing storage node, the second target shard and the second target migration computing storage node need to be updated and selected. When the second target migration computing storage node is updated, the next computing storage node of the second target migration computing storage node before the third sorting relay is updated is generally determined as the second target migration computing storage node after the update. When the second target shard is updated, the size of the second target shard after the update is similar to the size of the second target shard before the update.
[0337] According to an embodiment of the present disclosure, after the second target shard and the second target migration computing storage node are updated, the step of migrating the second target shard from the traversed computing storage node to the second target migration computing storage node is returned to migrate the second target shard after the update from the traversed computing storage node to the second target migration computing storage node until the second offset of the traversed computing storage node after migration is less than the second threshold. When the second offset of the traversed computing storage node is less than the second threshold, it indicates that the computing storage node has achieved balance in the dimension of the total number of shards.
[0338] In an embodiment, when the second offset is greater than or equal to the second threshold, migrating the shard on the traversed computing storage node to the computing storage node whose second offset is less than the second offset of the traversed computing storage node also includes: if the second target migration computing storage node is the last migration computing storage node in the third sorting, and the second offset after migration is still greater than or equal to the second threshold, reselecting the second target shard from the shards that have not been selected on the traversed computing storage node, updating the second target migration computing storage node with the first computing storage node in the third sorting, and returning to the step of migrating the second target shard from the traversed computing storage node to the second target migration computing storage node.
[0339] It can be understood that in the case that the second target migration computing storage node is the last computing storage node in the third ranking, if the second offset of the traversed computing storage node is still greater than or equal to the second threshold after the second target shard is migrated from the traversed computing storage node to the second target migration computing storage node, it indicates that the computing storage node has not yet achieved the balance of the dimension of the total number of shards at this time. The most likely reason is that the size of the second target shard is too small. In the case that the size of the second target shard is too small, even if the traversed computing storage node performs multiple migration operations of shards, the second offset of the traversed computing storage node is still greater than or equal to the second threshold. Therefore, at this time, a larger second target shard needs to be reselected on the traversed computing storage node, and the third ranking of each computing storage node is updated, and the first computing storage node in the updated third ranking is used to update the second target migration computing storage node.
[0340] According to an embodiment of the present disclosure, after the reselected second target shard is migrated from the traversed computing storage node to the second target migration computing storage node, if the second offset of the traversed computing storage node is still greater than or equal to the second threshold, the second target migration computing storage node needs to be updated with the next computing storage node of the current second target migration computing storage node in the updated third ranking. After that, the operations of shard migration and updating the second target migration computing storage node and the second target shard are looped until the second offset of the traversed computing storage node is less than the second threshold.
[0341] It should be noted that only in the case that the second target migration computing storage node is the last computing storage node in the third ranking, and the second offset of the traversed computing storage node is still greater than or equal to the second threshold after migration, the second target shard needs to be reselected.
[0342] For example, assuming that for the index B being traversed, the second offset of the traversed computing storage node D reaches the second threshold, and the third ranking is computing storage node A, computing storage node B, and computing storage node C. After determining the second target shard with a size of 15 MB, the second target shard is first migrated from the computing storage node D to the computing storage node A. When the second offset of the computing storage node D after the migration is still greater than or equal to the second threshold, the computing storage node B is used to update the second target migration computing storage node. Then, the second target shard is updated, and the second target shard is migrated from the computing storage node D to the computing storage node B. When the second offset of the computing storage node D after the migration is still greater than or equal to the second threshold, the computing storage node C is used to update the second target migration computing storage node. After that, the second target shard is updated, and the second target shard is migrated from the computing storage node D to the computing storage node C. When the second offset of the computing storage node D after the migration is still greater than or equal to the second threshold, the second target shard is reselected from the shards that have not been selected on the computing storage node D, and the reselected second target shard is 20 MB. Assuming that the updated third ranking is still computing storage node A, computing storage node B, and computing storage node C. At this time, the reselected second target shard can be migrated from the computing storage node D to the computing storage node A, and the operations of shard migration and updating the second target migration computing storage node and the second target shard are cyclically performed until the second offset of the computing storage node D is less than the second threshold.
[0343] The embodiments of the above steps 2610 to 2640 can enable the second target migration computing storage node to receive as many shards as possible by initializing the second target migration computing storage node as the first computing storage node in the third ranking. Further, the total number of shards of the computing storage nodes is accurately balanced by selecting a suitable second target shard and migrating the second target shard from the traversed computing storage node to the second target migration computing storage node. Moreover, when the second offset after the migration is still greater than or equal to the second threshold, the embodiments of the present disclosure further use the next computing storage node of the second target migration computing storage node before the update in the third ranking as the updated second target migration computing storage node to perform shard migration, and this step is cyclically performed until the second offset after the migration is less than the second threshold. By updating the second target migration computing storage node, the present disclosure avoids the situation that the same computing storage node continuously receives shards and the second offset reaches the second threshold, and accurately balances the total number of shards of the plurality of computing storage nodes.
[0344] In an embodiment, referring to FIG. 29, step 1340 includes:
[0345] Step 2910, performing fourth sorting on the computing storage nodes in the order from small to large according to the third offset;
[0346] Step 2920, initializing the third target migration computing storage node as the first computing storage node in the fourth sorting;
[0347] Step 2930, selecting the third target shard on the computing storage node being traversed;
[0348] Step 2940, migrating the third target shard from the computing storage node being traversed to the third target migration computing storage node, and when the third offset is still greater than or equal to the third threshold after the migration, updating the third target migration computing storage node with the next migration computing storage node in the fourth sorting, and returning to the step of migrating the third target shard from the computing storage node being traversed to the third target migration computing storage node until the third offset is less than the third threshold.
[0349] The third target migration computing storage node refers to the computing storage node receiving the shard migrated out by the computing storage node being traversed when the third offset is greater than or equal to the third threshold, and is initialized as the first computing storage node in the fourth sorting and updated according to the situation during the migration.
[0350] The third target shard refers to the shard that needs to be migrated out by the computing storage node being traversed when the third offset reaches the third threshold, and is selected by an appropriate size to reduce the third offset of the computing storage node, so as to realize the balance of the dimension of storage space utilization.
[0351] The steps 2910 to 2940 are described in detail below.
[0352] In step 2910, the computing storage nodes are sorted in the order from small to large according to the third offset.
[0353] According to an embodiment of the present disclosure, the fourth sorting refers to sorting the computing storage nodes in ascending order based on the third offset, so that the one with the smallest third offset is ranked first and the one with the largest third offset is ranked last. The fourth sorting specifically refers to the order obtained after sorting the computing storage nodes in ascending order based on the third offset, so that the computing storage node with the smallest third offset is ranked first and the computing storage node with the largest third offset is ranked last, which is used to determine the selection order of the target computing storage node receiving the shard migrated out by the computing storage node being traversed when the third offset is greater than or equal to the third threshold. The smallest third offset means that the current storage space utilization of the computing storage node is the smallest, and it can accommodate the most shards migrated out by other computing storage nodes. The largest third offset means that the current storage space utilization of the computing storage node is the largest, and it needs to migrate out the most shards.
[0354] For example, referring to FIG. 30, it is assumed that the distributed system includes a computing storage node A, a computing storage node B, a computing storage node C, a computing storage node D, a computing storage node E, and a computing storage node F. The third offset of the computing storage node A is -2%, the third offset of the computing storage node B is 0, the third offset of the computing storage node C is 1%, the third offset of the computing storage node D is 3%, the third offset of the computing storage node E is -4%, and the third offset of the computing storage node F is 2%. The computing storage nodes are sorted according to the third offset in ascending order, and the fourth sorting is: the computing storage node E, the computing storage node A, the computing storage node B, the computing storage node C, the computing storage node F, and the computing storage node D.
[0355] In step 2920, a third target migration computing storage node is initialized as the first computing storage node in the fourth sorting.
[0356] According to an embodiment of the present disclosure, the third target migration computing storage node refers to a computing storage node that receives the shards migrated out by the computing storage node whose third offset reaches the third threshold. It can be understood that the first computing storage node in the fourth sorting can accommodate the most shards migrated out by other computing storage nodes. The third target migration computing storage node is determined as the first computing storage node in the fourth sorting, so that the third target migration computing storage node can receive as many shards as possible. Further, when the third target migration computing storage node is determined, it is necessary to ensure that, after the third target migration computing storage node receives the shards migrated out by the computing storage node that is traversed, the first offset is less than the first threshold, the second offset is less than the second threshold, and the third offset is still less than the third threshold.
[0357] For example, referring to FIG. 30, it is assumed that the fourth sorting is: the computing storage node E, the computing storage node A, the computing storage node B, the computing storage node C, the computing storage node F, and the computing storage node D. Thus, the third target migration computing storage node can be initialized as the computing storage node E.
[0358] In step 2930, a third target shard is selected on the computing storage node that is traversed.
[0359] According to an embodiment of the present disclosure, the third target shard refers to a shard that the third offset of the traversed-to computing storage node reaches a third threshold value needs to be migrated out. As shown in FIG. 31A, the computing storage node stores a plurality of shards of different indexes, the sizes of the plurality of shards of different indexes are not the same, and the sizes of the plurality of shards of the same index are also not completely the same. The shard with a larger load is likely to make the third offset of the computing storage node larger, and naturally, migrating the shard out of the computing storage node will also significantly reduce the third offset of the computing storage node. Based on this, when migrating the shard in the computing storage node whose traversed-to third offset reaches the third threshold value, the third target shard with a proper size needs to be selected first.
[0360] In step 2940, the third target shard is migrated from the traversed-to computing storage node to the third target migration computing storage node, and when the third offset after migration is still greater than or equal to the third threshold value, the third target migration computing storage node is updated with the next migration computing storage node in the fourth order, and the step of migrating the third target shard from the traversed-to computing storage node to the third target migration computing storage node is returned until the third offset after migration is less than the third threshold value.
[0361] According to an embodiment of the present disclosure, after the third target shard and the third target migration computing storage node are determined, the third target shard can be migrated from the traversed-to computing storage node to the third target migration computing storage node. For example, referring to FIG. 31A, assuming that for the traversed-to index C, the third offset of the traversed-to computing storage node D reaches the third threshold value, and the third target migration computing storage node is determined to be the computing storage node E and the third target shard is determined to be a shard of the index C. Then, the shard of the index C can be migrated from the computing storage node D to the computing storage node E. FIG. 31B is a schematic diagram of the computing storage node E and the computing storage node D after the shard migration is completed. It can be obtained that the third target shard is no longer stored in the computing storage node D, and the third target shard is stored in the computing storage node E.
[0362] Further, after the third target shard is migrated from the traversed computing storage node to the third target migration computing storage node, the third offset of the traversed computing storage node and the third target migration computing storage node will both change. At this time, when the third offset of the traversed computing storage node after migration is still greater than or equal to the third threshold, it indicates that the traversed computing storage node still needs to select a third target shard to migrate out. Meanwhile, to avoid the situation that the third offset of the same computing storage node reaches the third threshold due to continuous reception of shards, the third target migration computing storage node also needs to be updated together with the third target shard. Therefore, after each time the third target shard is migrated from the traversed computing storage node, the third target shard and the third target migration computing storage node need to be updated and selected. When the third target migration computing storage node is updated, the next computing storage node of the third target migration computing storage node before the fourth sorting relay is updated is generally determined as the third target migration computing storage node after the update. When the third target shard is updated, the size of the third target shard after the update is similar to the size of the third target shard before the update.
[0363] According to an embodiment of the present disclosure, after the third target shard and the third target migration computing storage node are updated, the step of migrating the third target shard from the traversed computing storage node to the third target migration computing storage node is returned to migrate the updated third target shard from the traversed computing storage node to the updated third target migration computing storage node until the third offset of the traversed computing storage node after migration is less than the third threshold. When the third offset of the traversed computing storage node is less than the third threshold, it indicates that the computing storage node has achieved balance in the dimension of storage space utilization.
[0364] In an embodiment, when the third offset is greater than or equal to the third threshold, migrating the shard on the traversed computing storage node to the computing storage node whose third offset is less than the third offset of the traversed computing storage node also includes: if the third target migration computing storage node is the last migration computing storage node in the fourth sorting, and the third offset after migration is still greater than or equal to the third threshold, reselecting the third target shard from the shards that have not been selected on the traversed computing storage node, updating the third target migration computing storage node with the first computing storage node in the fourth sorting, and returning to the step of migrating the third target shard from the traversed computing storage node to the third target migration computing storage node.
[0365] It can be understood that in the case that the third target migration computing storage node is the last computing storage node in the fourth ranking, if the third offset of the traversed computing storage node is still greater than or equal to the third threshold after the third target shard is migrated from the traversed computing storage node to the third target migration computing storage node, it indicates that the storage space utilization of the computing storage node has not been balanced in the dimension. The most likely reason is that the size of the third target shard is too small. In the case that the size of the third target shard is too small, even if the traversed computing storage node performs multiple migration operations of the shard, the third offset of the traversed computing storage node is still greater than or equal to the third threshold. Therefore, at this time, a larger third target shard needs to be selected on the traversed computing storage node, and the fourth ranking of each computing storage node is updated, and the first computing storage node in the updated fourth ranking is used to update the third target migration computing storage node.
[0366] According to an embodiment of the present disclosure, after the reselected third target shard is migrated from the traversed computing storage node to the third target migration computing storage node, if the third offset of the traversed computing storage node is still greater than or equal to the third threshold, the third target migration computing storage node needs to be updated with the next computing storage node of the current third target migration computing storage node in the updated fourth ranking. After that, the operations of shard migration and updating the third target migration computing storage node and the third target shard are performed in a loop until the third offset of the traversed computing storage node is less than the third threshold.
[0367] It should be noted that only in the case that the third target migration computing storage node is the last computing storage node in the fourth ranking, and the third offset of the traversed computing storage node is still greater than or equal to the third threshold after migration, the third target shard needs to be reselected.
[0368] For example, assuming that the third offset of the traversed computing storage node is up to the third threshold for the index C being traversed, and the fourth ranking is computing storage node A, computing storage node B, and computing storage node C. After determining the third target shard with a size of 50 MB, the third target shard is first migrated from the computing storage node D to the computing storage node A. When the third offset of the computing storage node D after the migration is still greater than or equal to the third threshold, the computing storage node B is used to update the third target migration computing storage node. Then, the third target shard is updated and migrated from the computing storage node D to the computing storage node B. When the third offset of the computing storage node D after the migration is still greater than or equal to the third threshold, the computing storage node C is used to update the third target migration computing storage node. After that, the third target shard is updated and migrated from the computing storage node D to the computing storage node C. When the third offset of the computing storage node D after the migration is still greater than or equal to the third threshold, the third target shard is reselected from the shards that have not been selected on the computing storage node D, and the reselected third target shard is 60 MB. Assuming that the updated fourth ranking is still computing storage node A, computing storage node B, and computing storage node C. At this time, the reselected third target shard can be migrated from the computing storage node D to the computing storage node A, and the operations of shard migration and updating the third target migration computing storage node and the third target shard are performed in a loop until the third offset of the computing storage node D is less than the third threshold.
[0369] The embodiments of the above steps 2910 to 2940 can make the third target migration computing storage node receive as many shards as possible by initializing the third target migration computing storage node as the first computing storage node in the fourth ranking. Further, the storage space utilization of the computing storage nodes is accurately balanced by selecting a suitable third target shard and migrating the third target shard from the traversed computing storage node to the third target migration computing storage node. Moreover, when the third offset after the migration is still greater than or equal to the third threshold, the embodiments of the present disclosure further use the next computing storage node of the third target migration computing storage node before the update in the fourth ranking as the updated third target migration computing storage node to perform shard migration, and this step is performed in a loop until the third offset after the migration is less than the third threshold. By updating the third target migration computing storage node, the present disclosure avoids the situation that the same computing storage node continuously receives shards and the third offset reaches the third threshold, and accurately balances the storage space utilization of the plurality of computing storage nodes.
[0370] Implementation details of the distributed system load balancing method of the embodiments of the present disclosure
[0371] Referring to FIG. 32, the implementation details of the distributed system load balancing method of the embodiments of the present disclosure are described in detail.
[0372] In step 3210, in response to the index change request, the index change is performed on the plurality of computing storage nodes.
[0373] In an embodiment, the index change request is an index allocation request for a target index; and in response to the index change request, the index change is performed on the plurality of computing storage nodes, including: dividing the target index into a plurality of shards; and allocating the plurality of shards on the plurality of computing storage nodes, such that for the target index, a first offset on each computing storage node is less than a first threshold.
[0374] In an embodiment, dividing the target index into a plurality of shards includes: obtaining a storage capacity and a storage space utilization of each computing storage node; calculating an average storage capacity of each computing storage node based on the storage capacity of each computing storage node; calculating an average storage space utilization of each computing storage node based on the storage space utilization of each computing storage node; determining a number of shards based on an index size of the target index, the average storage capacity, and the average storage space utilization; and splitting the target index based on the number of shards to obtain the plurality of shards.
[0375] In step 3220, a first offset of each computing storage node after the index change is determined, the first offset being an offset of a number of shards of a single index stored by the computing storage node relative to an average number of shards of the single index stored by each computing storage node; a second offset of each computing storage node after the index change is determined, the second offset being an offset of a total number of shards stored by the computing storage node relative to an average total number of shards stored by each computing storage node; and a third offset of each computing storage node after the index change is determined, the third offset being an offset of a storage space utilization of the computing storage node relative to an average storage space utilization of each computing storage node.
[0376] In step 3231, indexes in the distributed system are traversed.
[0377] In step 3232, for the traversed indexes, the plurality of computing storage nodes are first sorted based on the first offset, the second offset, and the third offset.
[0378] In an embodiment, the first sorting of the plurality of computing storage nodes based on the first offset, the second offset and the third offset comprises: sorting the plurality of computing storage nodes based on the first offset in descending order; for the computing storage nodes with the same first offset, sorting the computing storage nodes based on the second offset in descending order; for the computing storage nodes with the same second offset, sorting the computing storage nodes based on the third offset in descending order, to form the first sorting.
[0379] In an embodiment, the first sorting of the plurality of computing storage nodes based on the first offset, the second offset and the third offset comprises: obtaining a first weight of the first offset, a second weight of the second offset and a third weight of the third offset; weighting and the first offset, the second offset and the third offset based on the first weight, the second weight and the third weight, wherein the first weight is greater than the second weight, and the second weight is greater than the third weight; and sorting the plurality of computing storage nodes based on the weighted sum in descending order, to form the first sorting.
[0380] In step 3233, the plurality of computing storage nodes are traversed according to the first sorting, so that for the traversed computing storage node, when the first offset is greater than or equal to the first threshold, the shard on the traversed computing storage node is migrated to the computing storage node with the first offset smaller than the traversed computing storage node.
[0381] In an embodiment, when the first offset is greater than or equal to the first threshold, the shard on the traversed computing storage node is migrated to the computing storage node with the first offset smaller than the traversed computing storage node, comprising: second sorting the computing storage nodes in ascending order of the first offset; initializing the first target migration computing storage node as the first computing storage node in the second sorting; selecting the first target shard on the traversed computing storage node; migrating the first target shard from the traversed computing storage node to the first target migration computing storage node; when the first offset is still greater than or equal to the first threshold after migration, updating the first target migration computing storage node with the next computing storage node in the second sorting, and returning to the step of migrating the first target shard from the traversed computing storage node to the first target migration computing storage node, until the first offset is smaller than the first threshold after migration.
[0382] In an embodiment, the first target shard is selected on the traversed computing storage node, comprising: obtaining the shard size of each shard on the traversed computing storage node; determining the average shard size based on the shard size of each shard; determining the first multiple of the shard size of each shard relative to the average shard size; selecting the shard with the first multiple matching the first offset as the first target shard.
[0383] In an embodiment, when the first offset is greater than or equal to the first threshold, migrating the shard on the traversed compute storage node to a compute storage node whose first offset is less than the first offset of the traversed compute storage node further comprises: when the first target migration compute storage node is the last migration compute storage node in the second order, and the first offset is still greater than or equal to the first threshold after migration, reselecting a first target shard from shards on the traversed compute storage node that have not been selected, and updating the first target migration compute storage node with the first compute storage node in the second order, and returning to the step of migrating the first target shard from the traversed compute storage node to the first target migration compute storage node.
[0384] In an embodiment, when the first offset is greater than or equal to the first threshold, migrating the shard on the traversed compute storage node to a compute storage node whose first offset is less than the first offset of the traversed compute storage node comprises: obtaining shard sizes of each shard on the traversed compute storage node; determining an average shard size based on the shard sizes of each shard; determining a second multiple of the shard size of a target shard in each shard relative to the average shard size; calculating a first difference between the first offset of the traversed compute storage node and the first offset of each to-be-considered compute storage node, the to-be-considered compute storage node being a compute storage node whose first offset is less than the first offset of the traversed compute storage node; matching other compute storage nodes whose second multiple and first difference match as target compute storage nodes, and migrating the target shard to the target compute storage node.
[0385] In an embodiment, the target shard is determined from each shard by: determining a storage capacity of the traversed compute storage node; determining a storage space utilization of the traversed compute storage node; obtaining shard sizes of each shard; and determining the target shard from each shard based on the storage capacity, the storage space utilization, and the shard sizes of each shard.
[0386] In step 3234, for the traversed compute storage node, when the second offset is greater than or equal to the second threshold, migrating the shard on the traversed compute storage node to a compute storage node whose second offset is less than the second offset of the traversed compute storage node.
[0387] In an embodiment, when the second offset is greater than or equal to the second threshold, migrating the shard on the traversed compute storage node to a compute storage node whose second offset is smaller than the traversed compute storage node comprises: sorting the compute storage nodes in a third order according to the second offset from small to large; initializing the second target migration compute storage node as the first compute storage node in the third order; selecting the second target shard on the traversed compute storage node; migrating the second target shard from the traversed compute storage node to the second target migration compute storage node; when the second offset is still greater than or equal to the second threshold after the migration, updating the second target migration compute storage node with the next migration compute storage node in the third order, and returning to the step of migrating the second target shard from the traversed compute storage node to the second target migration compute storage node until the second offset is smaller than the second threshold after the migration.
[0388] In an embodiment, when the second offset is greater than or equal to the second threshold, migrating the shard on the traversed compute storage node to a compute storage node whose second offset is smaller than the traversed compute storage node further comprises: if the second target migration compute storage node is the last migration compute storage node in the third order and the second offset is still greater than or equal to the second threshold after the migration, reselecting the second target shard from the shards that have not been selected on the traversed compute storage node, updating the second target migration compute storage node with the first compute storage node in the third order, and returning to the step of migrating the second target shard from the traversed compute storage node to the second target migration compute storage node.
[0389] In step 3235, for the traversed compute storage node, when the third offset is greater than or equal to the third threshold, migrating the shard on the traversed compute storage node to a compute storage node whose third offset is smaller than the traversed compute storage node.
[0390] In an embodiment, when the third offset is greater than or equal to the third threshold, migrating the shard on the traversed compute storage node to a compute storage node whose third offset is smaller than the traversed compute storage node comprises: sorting the compute storage nodes in a fourth order according to the third offset from small to large; initializing the third target migration compute storage node as the first compute storage node in the fourth order; selecting the third target shard on the traversed compute storage node; migrating the third target shard from the traversed compute storage node to the third target migration compute storage node; when the third offset is still greater than or equal to the third threshold after the migration, updating the third target migration compute storage node with the next migration compute storage node in the fourth order, and returning to the step of migrating the third target shard from the traversed compute storage node to the third target migration compute storage node until the third offset is smaller than the third threshold after the migration.
[0391] In an embodiment, when the third offset is greater than or equal to the third threshold, migrating the shard on the traversed computing storage node to a computing storage node with a third offset smaller than the computing storage node of the traversed computing storage node further comprises: if the third target migration computing storage node is the last migration computing storage node in the fourth order, and the third offset is still greater than or equal to the third threshold after migration, reselecting a third target shard from the shards that have not been selected on the traversed computing storage node, updating the third target migration computing storage node with the first computing storage node in the fourth order, and returning to the step of migrating the third target shard from the traversed computing storage node to the third target migration computing storage node.
[0392] It can be understood that, although each step in each of the above flowcharts is displayed in sequence according to the arrow representation, these steps are not necessarily executed in the order represented by the arrow. Unless otherwise specified in the embodiments, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least part of the steps in the above flowcharts can include multiple steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily sequential, but can be executed in rotation or alternation with at least part of other steps or steps or stages in other steps.
[0393] It should be noted that, in each specific embodiment of the present application, when it is necessary to perform relevant processing according to object attribute information or attribute information set and other data related to object characteristics, the permission or consent of the object will be obtained first, and the collection, use and processing of these data will comply with relevant laws, regulations and standards. In addition, when the object attribute information needs to be obtained in the embodiments of the present application, the separate permission or separate consent of the object will be obtained through a pop-up window or by jumping to a confirmation page, and after obtaining the separate permission or separate consent of the object, the necessary object-related data for enabling the embodiments of the present application to operate normally will be obtained.
[0394] Device and equipment of the embodiments of the present disclosure
[0395] FIG. 33 is a structural schematic diagram of a distributed system load balancing device 3300 provided by an embodiment of the present disclosure. The distributed system load balancing device 3300 is applied to a scheduling node in a distributed system, the distributed system including the scheduling node and a plurality of computing storage nodes, an index stored in the distributed system being divided into shards, the shards being stored in the plurality of computing storage nodes, the index being a multi-field data body to be calculated and stored, and the distributed system load balancing device 3300 including:
[0396] The response unit 3310 is configured to respond to the index change request to perform index change on the plurality of computing storage nodes;
[0397] The first determination unit 3320 is configured to determine a first offset of each computing storage node after the index change, the first offset being an offset of a number of shards of a single index stored by the computing storage node relative to an average number of shards of the single index stored by each computing storage node; determine a second offset of each computing storage node after the index change, the second offset being an offset of a total number of shards stored by the computing storage node relative to an average total number of shards stored by each computing storage node; and determine a third offset of each computing storage node after the index change, the third offset being an offset of a storage space utilization of the computing storage node relative to an average storage space utilization of each computing storage node.
[0398] The migration unit 3330 is configured to perform migration of shards on the plurality of computing storage nodes based on the first offset, the second offset, and the third offset, so that the first offset, the second offset, and the third offset of each computing storage node after the migration are less than a first threshold, a second threshold, and a third threshold, respectively.
[0399] Optionally, the index change request is an index allocation request for a target index.
[0400] The response unit 3310 is specifically configured to:
[0401] divide the target index into a plurality of shards;
[0402] allocate the plurality of shards on the plurality of computing storage nodes, so that for the target index, the first offset of each computing storage node is less than a first threshold.
[0403] Optionally, the response unit 3310 is specifically configured to:
[0404] obtain a storage capacity and a storage space utilization of each computing storage node;
[0405] calculate an average storage capacity of each computing storage node based on the storage capacity of each computing storage node;
[0406] calculate an average storage space utilization of each computing storage node based on the storage space utilization of each computing storage node;
[0407] determine a number of shards based on an index size of the target index, the average storage capacity, and the average storage space utilization;
[0408] divide the target index based on the number of shards to obtain the plurality of shards.
[0409] Optionally, the migration unit 3330 is specifically configured to:
[0410] traversing indexes in the distributed system;
[0411] migrating, for the traversed index, shards on the plurality of compute storage nodes based on the first offset, the second offset, and the third offset.
[0412] Optionally, the migrating unit 3330 is specifically configured to:
[0413] performing a first sorting on the plurality of compute storage nodes based on the first offset, the second offset, and the third offset for the traversed index;
[0414] traversing the plurality of compute storage nodes according to the first sorting, to, for a traversed compute storage node, migrate shards on the traversed compute storage node to a compute storage node with a smaller first offset than the traversed compute storage node when the first offset is greater than or equal to a first threshold;
[0415] to, for a traversed compute storage node, migrate shards on the traversed compute storage node to a compute storage node with a smaller second offset than the traversed compute storage node when the second offset is greater than or equal to a second threshold;
[0416] to, for a traversed compute storage node, migrate shards on the traversed compute storage node to a compute storage node with a smaller third offset than the traversed compute storage node when the third offset is greater than or equal to a third threshold.
[0417] Optionally, the migrating unit 3330 is specifically configured to:
[0418] performing a sorting on the plurality of compute storage nodes based on the first offset from large to small;
[0419] for compute storage nodes with equal first offsets, performing a sorting based on the second offset from large to small;
[0420] for compute storage nodes with equal second offsets, performing a sorting based on the third offset from large to small, to form the first sorting.
[0421] Optionally, the migrating unit 3330 is specifically configured to:
[0422] obtaining a first weight of the first offset, a second weight of the second offset, and a third weight of the third offset;
[0423] performing a weighted sum on the first offset, the second offset, and the third offset based on the first weight, the second weight, and the third weight, wherein the first weight is greater than the second weight, and the second weight is greater than the third weight;
[0424] The plurality of computing storage nodes are first sorted based on a weighted sum and in descending order.
[0425] Optionally, the migration unit 3330 is specifically configured to:
[0426] The computing storage nodes are second sorted in ascending order of the first offset;
[0427] The first target migration computing storage node is initialized as the first computing storage node in the second sorting;
[0428] The first target shard is selected on the traversed computing storage node;
[0429] The first target shard is migrated from the traversed computing storage node to the first target migration computing storage node, and when the first offset is still greater than or equal to the first threshold value after migration, the next computing storage node in the second sorting is used to update the first target migration computing storage node, and the step of migrating the first target shard from the traversed computing storage node to the first target migration computing storage node is returned, until the first offset is less than the first threshold value after migration.
[0430] Optionally, the migration unit 3330 is specifically configured to:
[0431] The shard sizes of each shard on the traversed computing storage node are obtained;
[0432] Based on the shard sizes of each shard, an average shard size is determined;
[0433] A first multiple of the shard size of each shard relative to the average shard size is determined;
[0434] The shard whose first multiple matches the first offset is selected as the first target shard.
[0435] Optionally, the migration unit 3330 is specifically configured to:
[0436] When the first target migration computing storage node is the last computing storage node in the second sorting, and the first offset is still greater than or equal to the first threshold value after migration, the first target shard is reselected from the shards that have not been selected on the traversed computing storage node, and the first computing storage node in the second sorting is used to update the first target migration computing storage node, and the step of migrating the first target shard from the traversed computing storage node to the first target migration computing storage node is returned.
[0437] Optionally, the migration unit 3330 is specifically configured to:
[0438] The shard sizes of each shard on the traversed computing storage node are obtained;
[0439] determine an average shard size based on the shard sizes of the shards;
[0440] determine a second multiple of the shard size of a target shard in the shards relative to the average shard size;
[0441] calculate a first difference between the first offset of the traversed computing storage node and the first offset of each to-be-considered computing storage node, the to-be-considered computing storage node being a computing storage node with a first offset smaller than the first offset of the traversed computing storage node;
[0442] match the other computing storage node with the second multiple and the first difference as a target computing storage node, and migrate the target shard to the target computing storage node.
[0443] Optionally, the migration unit 3330 is specifically configured to:
[0444] determine a storage capacity of the traversed computing storage node;
[0445] determine a storage space utilization of the traversed computing storage node;
[0446] obtain the shard size of each shard;
[0447] determine a target shard in the shards based on the storage capacity, the storage space utilization, and the shard size of each shard.
[0448] Optionally, the migration unit 3330 is specifically configured to:
[0449] perform a third sorting on the computing storage nodes in the order of the second offset from small to large;
[0450] initialize a second target migration computing storage node as the first computing storage node in the third sorting;
[0451] select a second target shard on the traversed computing storage node;
[0452] migrate the second target shard from the traversed computing storage node to the second target migration computing storage node, when the second offset is still greater than or equal to the second threshold value after the migration, update the second target migration computing storage node with a next migration computing storage node in the third sorting, and return to the step of migrating the second target shard from the traversed computing storage node to the second target migration computing storage node, until the second offset is smaller than the second threshold value after the migration.
[0453] Optionally, the migration unit 3330 is specifically configured to:
[0454] If the second target migration computing storage node is the last computing storage node in the third ranking, and the second offset is still greater than or equal to the second threshold value after migration, the second target shard is reselected from the shards that have not been selected on the traversed computing storage node, the second target migration computing storage node is updated with the first computing storage node in the third ranking, and the step of migrating the second target shard from the traversed computing storage node to the second target migration computing storage node is returned to.
[0455] Optionally, the migration unit 3330 is specifically configured to:
[0456] The computing storage nodes are ranked in a fourth ranking according to the third offset in ascending order;
[0457] The third target migration computing storage node is initialized as the first computing storage node in the fourth ranking;
[0458] The third target shard is selected on the traversed computing storage node;
[0459] The third target shard is migrated from the traversed computing storage node to the third target migration computing storage node, and when the third offset is still greater than or equal to the third threshold value after migration, the third target migration computing storage node is updated with the next migration computing storage node in the fourth ranking, the step of migrating the third target shard from the traversed computing storage node to the third target migration computing storage node is returned, and this is repeated until the third offset is less than the third threshold value after migration.
[0460] Optionally, the migration unit 3330 is specifically configured to:
[0461] If the third target migration computing storage node is the last computing storage node in the fourth ranking, and the third offset is still greater than or equal to the third threshold value after migration, the third target shard is reselected from the shards that have not been selected on the traversed computing storage node, the third target migration computing storage node is updated with the first computing storage node in the fourth ranking, and the step of migrating the third target shard from the traversed computing storage node to the third target migration computing storage node is returned to.
[0462] Referring to FIG. 34, FIG. 34 is a structural block diagram of part of a terminal implementing the distributed system load balancing method of the embodiments of the present disclosure, which includes Radio Frequency (RF) circuit 3410, memory 3415, input unit 3430, display unit 3440, sensor 3450, audio circuit 3460, wireless fidelity (WiFi) module 3470, processor 3480, and power supply 3490, etc. Those skilled in the art can understand that the structure of the terminal shown in FIG. 34 does not constitute a limitation on the mobile phone or computer, and can include more or fewer components than those shown, or combine certain components, or different component arrangements.
[0463] The RF circuit 3410 can be used for receiving and sending signals in the process of receiving or calling, especially receiving the downlink information of the base station and processing by the processor 3480; in addition, the uplink data is sent to the base station.
[0464] The memory 3415 can be used to store software programs and modules, and the processor 3480 executes various functions of the content terminal and data processing by running the software programs and modules stored in the memory 3415.
[0465] The input unit 3430 can be used to receive input digital or character information, and generate key signal input related to the setting and function control of the content terminal. Specifically, the input unit 3430 can include a touch panel 3431 and other input devices 3432.
[0466] The display unit 3440 can be used to display input information or provided information and various menus of the content terminal. The display unit 3440 can include a display panel 3441.
[0467] The audio circuit 3460, speaker 3461, and microphone 3462 can provide an audio interface.
[0468] In the present embodiment, the processor 3480 included in the terminal can execute the distributed system load balancing method of the previous embodiments.
[0469] The terminal of the embodiments of the present disclosure includes but is not limited to mobile phones, computers, smart voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. The embodiments of the present disclosure can be applied to various scenarios, including but not limited to distributed applications, distributed retrieval analysis engines, etc.
[0470] FIG. 35 is a structural block diagram of a part of a server implementing the distributed system load balancing method according to an embodiment of the present disclosure. The server can vary greatly due to configuration or performance, and can include one or more central processing units (CPUs) 3522 (e.g., one or more processors) and a memory 3532, one or more storage media 3530 (e.g., one or more mass storage devices) storing applications 3542 or data 3544. The memory 3532 and the storage media 3530 can be volatile or non-volatile storage. The programs stored in the storage media 3530 can include one or more modules (not shown in the figure), each of which can include a series of instructions for operating on the server. Further, the central processing unit 3522 can be configured to communicate with the storage media 3530 to execute the series of instructions in the storage media 3530 on the server.
[0471] The server can also include one or more power supplies 3526, one or more wired or wireless network interfaces 3550, one or more input / output interfaces 3558, and / or one or more operating systems 3541, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0472] The central processing unit 3522 in the server can be configured to execute the distributed system load balancing method according to an embodiment of the present disclosure.
[0473] The present disclosure also provides a computer-readable storage medium for storing program code for executing the distributed system load balancing method according to each of the above embodiments.
[0474] The present disclosure also provides a computer program product including a computer program. A processor of a computer device reads the computer program and executes it, so that the computer device executes the distributed system load balancing method according to the above embodiments.
[0475] In summary, the present disclosure provides a distributed system load balancing method, apparatus, electronic device, computer-readable storage medium, and computer program product. In a distributed system, a scheduling node plays a key coordination role. When the scheduling node receives an index change request, it means that the index data in the system needs to be adjusted, which can be an operation such as adding an index, deleting an index, or migrating a shard. At this time, the scheduling node will execute index changes on multiple computing storage nodes. After the index changes, the number of shards stored by each computing storage node will change, which can break the original load balancing state.
[0476] In order to reduce the situation that the efficiency of processing requests is reduced due to the centralized storage of large shards, the scheduling node determines the first offset, the second offset and the third offset of each computing storage node. The first offset reflects the difference between the number of shards of a single index stored by the computing storage node and the average number of shards of the single index stored by each computing storage node; the second offset reflects the deviation between the total number of shards stored by the computing storage node and the average total number of shards stored by each computing storage node; and the third offset reflects the deviation between the storage space utilization of the computing storage node and the average storage space utilization of each computing storage node. Through the three offsets, the scheduling node can comprehensively and accurately understand the difference between each computing storage node and the overall state of the system.
[0477] Based on these offsets, the scheduling node performs shard migration, so that after the migration, the first offset of each computing storage node is less than the first threshold, the second offset is less than the second threshold, and the third offset is less than the third threshold. From a technical point of view, in the dimension of the number of shards of a single index, when the first offset is less than the first threshold, the centralized storage of a large number of shards of a certain index by some computing storage nodes is avoided, so that the load of each computing storage node in processing requests related to the index is more balanced, the processing delay caused by excessive processing pressure of a certain node is reduced, and the efficiency of processing requests is improved. In the dimension of the total number of shards, the second offset less than the second threshold ensures the overall load balancing of each computing storage node, avoids some nodes becoming a system bottleneck due to storing too many shards, and improves the overall processing capacity of the system. In the dimension of storage space utilization, the third offset less than the third threshold makes the storage space of each computing storage node be reasonably utilized, avoids the situation that the storage space of some nodes is excessively used while there is a large amount of idle space in other nodes, and improves the resource utilization of the system. In summary, this load balancing method avoids the centralized storage of large shards, improves the efficiency of each computing storage node in processing requests, avoids the situation that the efficiency of some nodes is reduced due to storing too many shards, and improves the running efficiency of the distributed system.
[0478] Further, when the index change request is an index allocation request for the target index, the scheduling node divides the target index into multiple shards and allocates the multiple shards on multiple computing storage nodes, so that for the target index, the first offset on each computing storage node is less than the first threshold. In a distributed system, the allocation of the target index is a key operation, and if the allocation is unreasonable, some computing storage nodes may bear too much load. Through this allocation method, the scheduling node can ensure that the load of each computing storage node in processing the target index is relatively balanced. From a technical point of view, this allows each computing storage node to complete the processing of the target index-related computing and storage tasks at a similar speed and efficiency, avoiding the situation where the load of a certain node is too heavy, which affects the processing performance of the entire system for the target index, ensuring the balance of the dimension of the number of shards of a single index stored by the computing storage node, achieving load balancing of the distributed system, and improving the response speed and processing capacity of the system.
[0479] In dividing the target index into multiple shards, the scheduling node obtains the storage capacity and storage space utilization of each computing storage node, calculates the average storage capacity and average storage space utilization of each computing storage node, determines the number of shards based on the index size of the target index, the average storage capacity and the average storage space utilization, and finally divides the target index based on the number of shards to obtain multiple shards. Obtaining the storage capacity and storage space utilization of each computing storage node allows the scheduling node to understand the actual storage capacity and usage of each node. Calculating the average storage capacity and average storage space utilization provides a reference basis for determining a reasonable number of shards. The number of shards determined based on this information can better adapt to the actual situation of each computing storage node, so that the shards of the target index can be more evenly distributed on each node. From a technical point of view, this approach can better understand the current state of the distributed system, and when allocating shards to computing storage nodes, it achieves the balance of the dimension of the number of shards of a single index stored by the computing storage node, improves the resource utilization and data processing efficiency of the system, and avoids the problem of excessive storage pressure on some nodes or idle resources on some nodes due to unreasonable shard allocation.
[0480] When the migration of the shards on the plurality of computing storage nodes is performed based on the first offset, the second offset and the third offset, the scheduling node traverses the indexes in the distributed system, and for the traversed indexes, the shards on the plurality of computing storage nodes are migrated based on the three offsets. In the distributed system, there are a large number of indexes, and the indexes are distributed on different computing storage nodes. The shard conditions of each index are also different. By traversing the indexes, the scheduling node can comprehensively check the distribution of each index on each computing storage node. Based on the three offsets, the shards are migrated, and the actual load of each computing storage node can be accurately adjusted. From a technical point of view, this way accurately realizes the balance of the computing storage nodes in three dimensions of the number of shards of a single index, the total number of shards and the storage space utilization. At the level of a single index, the distribution of the shards of each index on each computing storage node is more reasonable, and the processing efficiency of a single index is improved. At the level of the total number of shards, the overall load of each computing storage node is more balanced, and the performance degradation of some nodes due to too many shards is avoided. At the level of storage space utilization, the storage space usage of each computing storage node is optimized, and the resource utilization of the system is improved.
[0481] For the traversed indexes, after the plurality of computing storage nodes are first sorted based on the first offset, the second offset and the third offset, the scheduling node traverses the plurality of computing storage nodes according to the first sorting. When the first offset of a computing storage node is greater than or equal to the first threshold, the shards on the node are migrated to the computing storage node with a smaller first offset. The purpose of the first sorting is to determine the priority and order of the shard migration, so that the computing storage nodes with unbalanced load can be adjusted first. When the first offset is greater than or equal to the first threshold, it means that there is a large deviation in the number of shards of a single index on the node, which may affect the processing efficiency of the index. Migrating the shards on the node to the computing storage node with a smaller first offset can quickly adjust the distribution of the index on each computing storage node, and realize the balance of the number of shards of a single index stored by the computing storage node in the dimension. From a technical point of view, this way can timely find and solve the problem of unbalanced distribution of shards of a single index, improve the processing performance of the system for a single index, and reduce the impact on the entire system caused by the processing delay of a single index.
[0482] In the first sorting of the plurality of computing and storage nodes, one way is to sort the plurality of computing and storage nodes in descending order based on the first offset, for the computing and storage nodes with equal first offset, sort in descending order based on the second offset, for the computing and storage nodes with equal second offset, sort in descending order based on the third offset, to form the first sorting. This sorting method fully considers the importance and priority of the three offsets. First, sort according to the first offset, which can preferentially process nodes with large number of single index shards, because this has the most direct impact on the processing efficiency of single index. For nodes with equal first offset, sort according to the second offset to further adjust the balance of the total number of shards. For nodes with equal second offset, sort according to the third offset to optimize storage space utilization. From a technical point of view, this sorting method facilitates subsequent migration of shards to appropriate computing and storage nodes when different offsets reach a threshold, improving the efficiency of shard migration. It allows the scheduling node to make more targeted load balancing adjustments, making the system more balanced in multiple dimensions, improving the overall performance and stability of the system.
[0483] Another way to first sort the plurality of computing and storage nodes is to obtain a first weight of the first offset, a second weight of the second offset, and a third weight of the third offset, weight the three offsets based on these weights, where the first weight is greater than the second weight, and the second weight is greater than the third weight, and then sort the plurality of computing and storage nodes in descending order based on the weighted sum. This method considers the impact of the three offsets on system load balancing more flexibly by setting different weights. The first weight is greater than the second weight and the third weight, highlighting the importance of the number of shards of a single index in load balancing, as it directly affects the processing efficiency of a single index. By weighting, the information of the three offsets can be considered comprehensively to obtain an index that better reflects the overall load of the computing and storage nodes. Sorting based on the weighted sum allows the computing and storage node that needs to migrate the most shards to be placed at the front, and the computing and storage node that can accommodate the most shards migrated from other computing and storage nodes to be placed at the back. From a technical point of view, this sorting method facilitates subsequent migration of shards stored by computing and storage nodes that need to migrate shards to appropriate nodes, improving the accuracy and efficiency of shard migration and enabling more effective load balancing of the system.
[0484] When the first offset is greater than or equal to the first threshold, the scheduling node sorts the computing storage nodes in the order of the first offset from small to large, initializes the first target migration computing storage node as the first computing storage node in the second sorting, selects the first target shard on the computing storage node, and migrates the first target shard from the computing storage node to the first target migration computing storage node. When the first offset is still greater than or equal to the first threshold after migration, the first target migration computing storage node is updated with the next computing storage node in the second sorting until the first offset is less than the first threshold. The purpose of the second sorting is to determine the priority of the computing storage node receiving shards, and the nodes with small first offsets are arranged in front, so that these nodes can receive shards in priority, thereby better balancing the number of individual index shards of each computing storage node. Selecting a suitable first target shard for migration can more effectively reduce the first offset of the computing storage node being traversed. By constantly updating the first target migration computing storage node, the situation that the same computing storage node continuously receives shards and the first offset reaches the first threshold is avoided. From a technical point of view, this way precisely realizes the balancing of the number of shards of individual indexes stored by the computing storage node in the dimension, improves the processing efficiency of the system for individual indexes, and reduces the processing delay caused by the uneven distribution of individual index shards.
[0485] When selecting the first target shard on the computing storage node being traversed, the scheduling node obtains the shard size of each shard on the node, determines the average shard size based on the shard sizes, determines the first multiple of the shard size of each shard relative to the average shard size, and selects the shard with the first multiple matching the first offset as the first target shard. Obtaining the shard size of each shard enables the scheduling node to understand the actual load of each shard. Determining the average shard size and the first multiple provides a quantitative basis for selecting a suitable shard. Selecting the shard with the first multiple matching the first offset as the first target shard can ensure that the size of the migrated shard is adapted to the offset that needs to be adjusted. From a technical point of view, this selection method can reduce the number of times of performing shard migration, improve the efficiency of shard migration, and also improve the speed of balancing the number of shards of individual indexes of the computing storage node in the dimension. Because a suitable size of shard is selected for migration, the purpose of reducing the first offset can be achieved more quickly, unnecessary migration operations are reduced, and the processing efficiency of the system is improved.
[0486] When the first target migration computing storage node is the last computing storage node in the second order, and the first offset is still greater than or equal to the first threshold after migration, the scheduling node reselects the first target shard from the shards that have not been selected on the traversed computing storage node, and updates the first target migration computing storage node with the first computing storage node in the second order, and continues the shard migration until the first offset after migration is less than the first threshold. This situation indicates that the previously selected first target shard may be too small to effectively reduce the first offset of the traversed computing storage node. By reselecting the first target shard and updating the first target migration computing storage node, the number of single index shards of the node can continue to be adjusted. From a technical point of view, this processing method ensures that the number of single index shards stored by the computing storage node is balanced in various situations, improves the fault tolerance and stability of the system, and avoids the problem of load balancing adjustment failure caused by improper shard selection.
[0487] When the first offset is greater than or equal to the first threshold, another way to migrate the shard on the traversed computing storage node to the computing storage node whose first offset is less than the first offset is for the scheduling node to obtain the shard size of each shard on the traversed computing storage node, determine the average shard size based on these shard sizes, determine the second multiple of the shard size of the target shard in each shard relative to the average shard size, calculate the first difference between the first offset of the traversed computing storage node and the first offset of each to-be-considered computing storage node, match the other computing storage nodes with the second multiple and the first difference as target computing storage nodes, and migrate the target shard to the target computing storage node. Obtaining the shard size, determining the average shard size and the second multiple can quantitatively analyze the load of each shard. Calculating the first difference can understand the difference between the traversed computing storage node and other nodes in the number of single index shards. Matching the second multiple with the first difference can select the most suitable computing storage node to receive the target shard. From a technical point of view, this method can reduce the number of times of performing shard migration and improve the efficiency of shard migration. Because of accurate matching, the target shard can be migrated to the most suitable node at one time, avoiding multiple migrations and adjustments, and improving the processing efficiency and load balancing effect of the system.
[0488] The target shard is determined in the following manner. The scheduling node determines the storage capacity and storage space utilization of the computing storage node traversed to, obtains the shard size of each shard, and determines the target shard among the shards based on the storage capacity, the storage space utilization, and the shard size of each shard. If the remaining storage space of the computing storage node is small, a target shard with a larger shard size is selected to be migrated from the computing storage node traversed to; if the remaining storage space of the computing storage node is large, a target shard with a smaller shard size is selected to be migrated from the computing storage node traversed to. Determining the storage capacity and the storage space utilization can understand the actual storage situation of the computing storage node. Selecting a suitable target shard according to the size of the remaining storage space can better balance the storage space usage of each computing storage node. From a technical point of view, this determination manner can accurately determine the target shard that needs to be migrated from the computing storage node traversed to, reduce the number of times of performing shard migration, and improve the efficiency of shard migration. It can avoid the problems of storage space waste or node load imbalance caused by the inappropriate size of the migrated shard, and improve the resource utilization and stability of the system.
[0489] When the second offset is greater than or equal to the second threshold, the scheduling node sorts the computing storage nodes in the third order according to the second offset from small to large, initializes the second target migration computing storage node as the first computing storage node in the third order, selects the second target shard on the computing storage node traversed to, and migrates the second target shard from the computing storage node traversed to to the second target migration computing storage node. When the second offset after migration is still greater than or equal to the second threshold, the second target migration computing storage node is updated with the next migration computing storage node in the third order until the second offset after migration is less than the second threshold. The purpose of the third sorting is to determine the priority of the computing storage node receiving shards, and the nodes with smaller second offsets are arranged in front, so that these nodes can preferentially receive shards, thereby better balancing the total number of shards of each computing storage node. Selecting a suitable second target shard for migration can more effectively reduce the second offset of the computing storage node traversed to. By constantly updating the second target migration computing storage node, the situation that the second offset of the same computing storage node reaches the second threshold due to continuously receiving shards is avoided. From a technical point of view, this manner precisely balances the dimension of the total number of shards of the computing storage node, improves the overall processing capacity of the system, and avoids the problem that some nodes become the bottleneck of the system due to bearing too many shards.
[0490] If the second target migration computing storage node is the last migration computing storage node in the third ranking, and the second offset is still greater than or equal to the second threshold value after migration, the scheduling node reselects the second target shard from the shards that have not been selected on the computing storage node that has been traversed, and updates the second target migration computing storage node with the first computing storage node in the third ranking, and continues shard migration until the second offset is less than the second threshold value after migration. This situation indicates that the previously selected second target shard may be too small to effectively reduce the second offset of the computing storage node that has been traversed. By reselecting the second target shard and updating the second target migration computing storage node, the total number of shards of the node can continue to be adjusted. From a technical point of view, this processing method ensures that the dimension of the total number of shards of the computing storage node is balanced in various situations, improves the fault tolerance and stability of the system, and avoids the problem of failure of load balancing adjustment due to improper shard selection.
[0491] When the third offset is greater than or equal to the third threshold value, the scheduling node ranks the computing storage nodes according to the third offset from small to large, initializes the third target migration computing storage node as the first computing storage node in the fourth ranking, selects the third target shard on the computing storage node that has been traversed, and migrates the third target shard from the computing storage node that has been traversed to the third target migration computing storage node. When the third offset is still greater than or equal to the third threshold value after migration, the third target migration computing storage node is updated with the next migration computing storage node in the fourth ranking until the third offset is less than the third threshold value after migration. The purpose of the fourth ranking is to determine the priority of the computing storage node that receives shards, and the nodes with smaller third offsets are ranked first, so that these nodes can preferentially receive shards, thereby better balancing the storage space utilization of each computing storage node. Selecting a suitable third target shard for migration can more effectively reduce the third offset of the computing storage node that has been traversed. By constantly updating the third target migration computing storage node, the situation where the same computing storage node continuously receives shards and the third offset reaches the third threshold value is avoided. From a technical point of view, this method precisely balances the dimension of the storage space utilization of the computing storage node, improves the resource utilization of the system, and avoids the problem of affecting system performance due to excessive use of storage space by some nodes.
[0492] If the third target migration computing storage node is the last migration computing storage node in the fourth ranking, and the third offset is still greater than or equal to the third threshold value after migration, the scheduling node reselects the third target shard from the shards that have not been selected on the computing storage node that has been traversed, and updates the third target migration computing storage node with the first computing storage node in the fourth ranking, and continues the shard migration until the third offset after migration is less than the third threshold value. This situation indicates that the previously selected third target shard can be too small to effectively reduce the third offset of the computing storage node that has been traversed. By reselecting the third target shard and updating the third target migration computing storage node, the storage space utilization of the node can continue to be adjusted. From a technical point of view, this processing manner ensures that the storage space utilization of the computing storage node is balanced in various situations, improves the fault tolerance and stability of the system, and avoids the problem of unbalanced storage space use caused by improper shard selection.
[0493] The terms "first", "second", "third", "fourth" and the like in the description of the present disclosure and the above drawings, if any, are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "contain" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device containing a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0494] It should be understood that in the present disclosure, "at least one" refers to one or more, and "multiple" refers to two or more. "And / or" is used to describe the relationship between the associated contents, which means that there can be three relationships, for example, "A and / or B" can represent three cases: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally represents an "or" relationship between the associated contents. "At least one of the following" or similar expressions means any combination of these items, including any combination of single or multiple items. For example, at least one of a, b or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0495] It should be understood that, in the description of the embodiments of the present disclosure, the meaning of multiple (or multiple items) is two or more, greater than, less than, more than, and the like are not included in the number, above, below, and the like are included in the number.
[0496] In several embodiments provided by the present disclosure, it should be understood that the disclosed system, device and method can be implemented by other manners. For example, the device embodiments described above are only schematic, and the division of units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. The coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interfaces, devices or units, and can be electrical, mechanical or other forms.
[0497] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e. can be located in one place or can be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
[0498] In addition, the functional units in each embodiment of the present disclosure can be integrated in one processing unit, or each unit can be physically present alone, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0499] If the integrated unit is realized in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present disclosure essentially or say the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a plurality of instructions to make a computer device (which can be a personal computer, a server 130, or a network device, etc.) execute all or part of the steps of the embodiments of the present disclosure. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM for short), a random access memory (Random Access Memory, RAM for short), a magnetic disk or an optical disk, and various media that can store program codes.
[0500] Any combination of the technical features in the above embodiments can be made, and for the sake of brevity, not all possible combinations are described above, however, as long as the combination of the technical features does not exist in contradiction, it shall be considered within the scope of the present disclosure.
[0501] The above embodiments only express several implementation manners of the present application, and the description is relatively specific and detailed, but it shall not be understood as a limitation on the patent scope of the present application. It shall be pointed out that, for ordinary skilled persons in the art, several modifications and improvements can be made without departing from the concept of the present application, and these shall be within the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the appended claims.
Claims
1. A method for load balancing of a distributed system, applied to a scheduling node in the distributed system, the distributed system comprising the scheduling node and a plurality of computing storage nodes, an index stored in the distributed system being divided into shards, the shards being stored in the plurality of computing storage nodes, the index being a multi-field data body to be computed and stored, the method comprising: in response to an index change request, performing an index change on the plurality of computing storage nodes; determining a first offset of each of the computing storage nodes after the index change, the first offset being an offset of a number of shards of a single index stored by the computing storage node relative to an average number of shards of the single index stored by each of the computing storage nodes; determining a second offset of each of the computing storage nodes after the index change, the second offset being an offset of a total number of shards stored by the computing storage node relative to an average total number of shards stored by each of the computing storage nodes; determining a third offset of each of the computing storage nodes after the index change, the third offset being an offset of a storage space utilization of the computing storage node relative to an average storage space utilization of each of the computing storage nodes; and based on the first offset, the second offset and the third offset, performing migration of the shards on the plurality of computing storage nodes such that the first offset of each of the computing storage nodes after the migration is less than a first threshold, the second offset is less than a second threshold, and the third offset is less than a third threshold. 2.The method of claim 1, wherein the index change request is an index allocation request for a target index; and the performing an index change on the plurality of computing storage nodes in response to the index change request comprises: dividing the target index into a plurality of shards; and allocating the plurality of shards on the plurality of computing storage nodes such that for the target index, the first offset of each of the computing storage nodes is less than the first threshold. 3.The method of claim 2, wherein the dividing the target index into a plurality of shards comprises: obtaining the storage capacity and the storage space utilization of each of the computing storage nodes; calculating an average storage capacity of each of the computing storage nodes based on the storage capacity of each of the computing storage nodes; calculating an average storage space utilization of each of the computing storage nodes based on the storage space utilization of each of the computing storage nodes; determining a number of shards based on an index size of the target index, the average storage capacity and the average storage space utilization; and dividing the target index based on the number of shards to obtain the plurality of shards. 4.The method of any one of claims 1 to 3, wherein the performing migration of the shards on the plurality of computing storage nodes based on the first offset, the second offset and the third offset comprises: traversing the index in the distributed system; and migrating the shards on the plurality of compute storage nodes based on the first offset, the second offset and the third offset for the iterated index. 5.The distributed system load balancing method of claim 4, wherein the migrating the shards on the plurality of compute storage nodes based on the first offset, the second offset and the third offset for the iterated index comprises: first sorting the plurality of compute storage nodes based on the first offset, the second offset and the third offset for the iterated index; iterating through the plurality of compute storage nodes according to the first sorting to, for the iterated compute storage node, migrate shards on the iterated compute storage node to the compute storage node with the first offset less than the iterated compute storage node when the first offset is greater than or equal to the first threshold. 6.The distributed system load balancing method of claim 5, wherein the migrating the shards on the plurality of compute storage nodes based on the first offset, the second offset and the third offset for the iterated index further comprises: to, for the iterated compute storage node, migrate shards on the iterated compute storage node to the compute storage node with the second offset less than the iterated compute storage node when the second offset is greater than or equal to the second threshold. 7.The distributed system load balancing method of claim 5 or 6, wherein the migrating the shards on the plurality of compute storage nodes based on the first offset, the second offset and the third offset for the iterated index further comprises: to, for the iterated compute storage node, migrate shards on the iterated compute storage node to the compute storage node with the third offset less than the iterated compute storage node when the third offset is greater than or equal to the third threshold. 8.The distributed system load balancing method of any of claims 5 to 7, wherein the first sorting the plurality of compute storage nodes based on the first offset, the second offset and the third offset comprises: sorting the plurality of compute storage nodes based on the first offset in descending order; for the compute storage nodes with the same first offset, sorting in descending order based on the second offset; for the compute storage nodes with the same second offset, sorting in descending order based on the third offset to form the first sorting. 9.The distributed system load balancing method of any of claims 5 to 7, wherein the first sorting the plurality of compute storage nodes based on the first offset, the second offset and the third offset comprises: obtaining a first weight of the first offset, a second weight of the second offset and a third weight of the third offset; and sorting the plurality of compute storage nodes based on the first weight, the second weight and the third weight. weighting and the third weight, wherein the first weight is greater than the second weight, and the second weight is greater than the third weight; performing a first sorting on the plurality of computing storage nodes based on the weighting and the order from large to small. 10.The distributed system load balancing method of any one of claims 5 to 9, wherein the migrating the shard on the traversed computing storage node to the computing storage node whose first offset is smaller than the first offset of the traversed computing storage node when the first offset is greater than or equal to the first threshold comprises: performing a second sorting on the computing storage nodes according to the first offset in ascending order; initializing a first target migration computing storage node as the first computing storage node in the second sorting; selecting a first target shard on the traversed computing storage node; migrating the first target shard from the traversed computing storage node to the first target migration computing storage node, and when the first offset after the migration is still greater than or equal to the first threshold, updating the first target migration computing storage node with the next computing storage node in the second sorting and returning to the step of migrating the first target shard from the traversed computing storage node to the first target migration computing storage node until the first offset after the migration is smaller than the first threshold. 11.The distributed system load balancing method of claim 10, wherein the selecting a first target shard on the traversed computing storage node comprises: obtaining shard sizes of shards on the traversed computing storage node; determining an average shard size based on the shard sizes of the shards; determining first multiples of the shard sizes of the shards relative to the average shard size; selecting the shard whose first multiple matches the first offset as the first target shard. 12.The distributed system load balancing method of claim 10 or 11, wherein the migrating the shard on the traversed computing storage node to the computing storage node whose first offset is smaller than the first offset of the traversed computing storage node when the first offset is greater than or equal to the first threshold further comprises: when the first target migration computing storage node is the last computing storage node in the second sorting and the first offset after the migration is still greater than or equal to the first threshold, reselecting the first target shard from shards on the traversed computing storage node that have not been selected, updating the first target migration computing storage node with the first computing storage node in the second sorting, and returning to the step of migrating the first target shard from the traversed computing storage node to the first target migration computing storage node. 13.The method of claim 5 to 9, wherein the migrating the shard on the traversed computing storage node to the computing storage node with the first offset smaller than the traversed computing storage node when the first offset is greater than or equal to the first threshold comprises: obtaining shard sizes of each shard on the traversed computing storage node; determining an average shard size based on the shard sizes of each shard; determining a second multiple of the shard size of a target shard in each shard relative to the average shard size; calculating a first difference between the first offset of the traversed computing storage node and the first offset of each candidate computing storage node with the first offset smaller than the traversed computing storage node; and migrating the target shard to a target computing storage node with the second multiple matching the first difference. 14.The method of claim 13, wherein the target shard is determined from each shard by: determining a storage capacity of the traversed computing storage node; determining a storage space utilization of the traversed computing storage node; obtaining shard sizes of each shard; and determining the target shard from each shard based on the storage capacity, the storage space utilization, and the shard sizes of each shard. 15.A distributed system load balancing apparatus applied to a scheduling node in a distributed system, the distributed system comprising the scheduling node and a plurality of computing storage nodes, wherein an index stored in the distributed system is divided into shards and stored in the plurality of computing storage nodes, the index being a multi-field data body to be computed and stored, the distributed system load balancing apparatus comprising: a response unit configured to perform an index change on the plurality of computing storage nodes in response to an index change request; a first determination unit configured to determine a first offset of each computing storage node after the index change, the first offset being an offset of a number of shards of a single index stored in the computing storage node relative to an average number of shards of the single index stored in each computing storage node; a second determination unit configured to determine a second offset of each computing storage node after the index change, the second offset being an offset of a total number of shards stored in the computing storage node relative to an average total number of shards stored in each computing storage node; and a third determination unit configured to determine a third offset of each computing storage node after the index change, the third offset being an offset of a storage space utilization of the computing storage node relative to an average storage space utilization of each computing storage node. a migration unit configured to migrate the shards on the plurality of compute storage nodes based on the first offset, the second offset and the third offset, such that after the migration, the first offset on each of the compute storage nodes is less than a first threshold, the second offset is less than a second threshold, and the third offset is less than a third threshold.
16. An electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the load balancing method of the distributed system according to any one of claims 1 to 14.
17. A computer readable storage medium, wherein the storage medium stores a computer program, and the computer program is executed by a processor to implement the load balancing method of the distributed system according to any one of claims 1 to 14.
18. A computer program product, comprising a computer program, wherein the computer program is read and executed by a processor of a computer device, so that the computer device executes the load balancing method of the distributed system according to any one of claims 1 to 14.
Citation Information
Patent Citations
Distributed database system and self-adaption method thereof
CN106844399A
Load balancing method and device, electronic equipment and computer readable medium
CN112181605A
Data balancing method and device, query system and storage medium
CN113177050A
Load balancing method and device for distributed database, electronic equipment and medium
CN114647701A
Data fragment adjustment method, device and equipment and readable storage medium
CN116955087A