Load balancing method, device and server
By obtaining the read and write pressure of each storage server in a distributed table system and migrating the replica, the problem of unbalanced read and write pressure in the system is solved, and load balancing and performance improvement is achieved.
Patent Information
- Application Number
- CN202010620901.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-30
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2040-06-30
AI Technical Summary
In a distributed table system, the read and write pressure of different shards in the same storage server is uneven, which causes some servers to bear too much read and write pressure, resulting in the problem of load imbalance.
The metadata server obtains the read and write pressure of each storage server, determines the source storage server and the target storage server, and migrates the replica to be migrated to the target storage server to balance the read and write pressure.
The load balancing of distributed table systems is realized, reducing the excessive read and write pressure of a single storage server and improving system performance.
Smart Images

Figure CN113867928B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of distributed storage technology, and in particular to a load balancing method, device and server. Background Art
[0002] A distributed table system is a semi-structured data storage system that is widely used to store trillions of data. The system can be viewed as a distributed cluster, which can include metadata servers for scheduling various tasks in the system and storage servers for storing data. In order to ensure data security and tolerate bad disks and server downtime, distributed table systems generally store data in the form of multiple copies. To this end, at the storage logic level, the storage units of data in a distributed table system are "tables", "shards" and "replicas" from large to small: a distributed table system can store multiple tables, a table includes multiple shards, and each shard consists of multiple replicas.
[0003] In the related art, for multiple copies belonging to the same shard, one of the copies is usually designated as the master copy and the other copies are designated as slave copies, so as to maintain the consistency of the copies based on the master-slave relationship of the copies, and the read requests and write requests for data only fall on the master copy. In addition, in order to improve the performance of the cluster, for any shard, a storage server in the cluster only stores one copy of the shard. On this basis, in order to reduce the situation where a single storage server bears too much read and write pressure and to improve the performance of the cluster, the cluster can be load balanced. Specifically, the read and write pressure of all storage servers in the cluster can be close as the goal of load balancing, and the master and slave roles of the master and slave copies can be exchanged based on the same number of master copies in each storage server.
[0004] However, in specific applications, the read and write pressures of the primary replicas belonging to different shards are not the same. At this time, if the load balancing is still based on the same number of primary replicas in each storage server, it is likely that multiple primary replicas with relatively large read and write pressures will be concentrated in the same storage server, resulting in excessive storage read and write pressure and unbalanced load. Summary of the invention
[0005] The purpose of the embodiment of the present invention is to provide a load balancing method, device and server to achieve the load balancing effect of a distributed table system. The specific technical solution is as follows:
[0006] In a first aspect, an embodiment of the present invention provides a load balancing method, which is applied to a distributed table system, wherein the distributed table system includes a metadata server and a plurality of storage servers for storing data, and the method is executed by the metadata server, including:
[0007] Obtaining the read and write pressure of each replica in each storage server in the distributed table system;
[0008] Based on the read and write pressure of each replica in each storage server, determine a source storage server and a target storage server from the multiple storage servers, wherein the source storage server includes the replica to be migrated;
[0009] Migrate the replica to be migrated to the target storage server.
[0010] In a second aspect, an embodiment of the present invention provides a load balancing method, which is applied to a distributed table system, wherein the distributed table system includes a metadata server and a plurality of storage servers for storing data, and the method is executed by the storage servers, including:
[0011] Receiving read request information and / or write request information of each replica;
[0012] The read / write pressure of each replica is determined according to the received read request information and / or write request information of each replica.
[0013] In a third aspect, an embodiment of the present invention provides a load balancing device, which is applied to a distributed table system, wherein the distributed table system includes a metadata server and a plurality of storage servers for storing data, and the device is included in the metadata server, including:
[0014] A read / write pressure acquisition module, used to acquire the read / write pressure of each replica in each storage server in the distributed table system;
[0015] A server determination module, configured to determine a source storage server and a target storage server from the plurality of storage servers based on the read and write pressure of each replica in each storage server, wherein the source storage server includes the replica to be migrated;
[0016] A target storage server determination module, configured to determine a target storage server that can be migrated in the distributed table system when there is a copy to be migrated in any of the storage servers;
[0017] A load balancing module is used to migrate the replica to be migrated to the target storage server.
[0018] In a fourth aspect, an embodiment of the present invention provides a server, the server comprising:
[0019] A processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the bus; the memory is used to store computer programs; the processor is used to execute the programs stored in the memory to implement the steps of the load balancing method provided in the first aspect or the second aspect above.
[0020] In a fifth aspect, an embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of the load balancing method provided in the first aspect or the second aspect are implemented.
[0021] In the solution provided by the present invention, the metadata server of the distributed table system obtains the read and write pressure of each replica in each storage server in the distributed table system; based on the read and write pressure of each replica in each storage server, the source storage server and the target storage server are determined from multiple storage servers, and the source storage server includes the replica to be migrated; and then the replica to be migrated is migrated to the target storage server. Thus, by migrating the replica to be migrated to the target storage server, the read and write pressure of the source storage server can be transferred to the target storage server, thereby achieving the balance of the read and write pressure between the source storage server and the target storage server in which the replica to be migrated exists in the entire distributed table system. It can be seen that this solution can reduce the problem of multiple master replicas with relatively large read and write pressures concentrated in the same storage server, resulting in excessive read and write pressure and unbalanced load on the storage server, thereby achieving load balancing of the distributed table system. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.
[0023] Figure 1 A flow chart of a load balancing method provided by an embodiment of the present invention;
[0024] Figure 2 A flow chart of a load balancing method provided by another embodiment of the present invention;
[0025] Figure 3 A schematic diagram of the structure of a load balancing device according to an embodiment of the present invention;
[0026] Figure 4 A schematic diagram of the structure of a load balancing device according to another embodiment of the present invention;
[0027] Figure 5 The figure is a schematic diagram of the structure of a server according to an embodiment of the present invention. DETAILED DESCRIPTION
[0028] In order to enable those skilled in the art to better understand the technical solutions in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0029] The following first introduces a load balancing method according to an embodiment of the present invention.
[0030] The load balancing method provided in the embodiment of the present invention can be applied to a distributed table system, wherein the distributed table system includes a metadata server and multiple storage servers for storing data, and the method is executed by the metadata server. The metadata server can specifically include a desktop computer, a portable computer, an Internet TV, a smart mobile terminal, a wearable smart terminal, and a server, etc., which are not limited here. Any electronic device that can implement the embodiment of the present invention can be used as the metadata server of the present invention and belongs to the protection scope of the embodiment of the present invention.
[0031] like Figure 1 As shown, the process of the load balancing method according to an embodiment of the present invention may include the following steps:
[0032] S101, obtaining the read and write pressure of each replica in each storage server in the distributed table system.
[0033] Among them, the read-write pressure of any replica is the processing pressure borne by the storage server to which the replica belongs for reading and writing the replica; the read-write pressure of any storage server is the total read-write pressure of all replicas in the storage server. In specific applications, the read-write pressure of any replica can be multiple. Exemplarily, the read-write pressure of any replica can be the number of read requests and the number of write requests for the replica; or, the read-write pressure of any replica can be the processing resources of the storage server occupied when responding to read requests and write requests for the replica.
[0034] Furthermore, there may be multiple specific ways for the metadata server to obtain the read / write pressure of each replica in each storage server in the distributed table system, which are described below in the form of optional embodiments.
[0035] In an optional implementation, the above-mentioned obtaining of the read / write pressure of each replica in each storage server in the distributed table system may include the following steps:
[0036] Periodically obtain the read and write pressure of each replica in each storage server in the distributed table system.
[0037] In a specific application, the metadata server periodically obtains the read and write pressure of each replica in each storage server in the distributed table system, which can be multiple. Exemplarily, the metadata server can passively receive the read and write pressure of each replica in the storage server actively sent to the metadata server according to a preset period. Or, exemplary, the metadata server can actively request the read and write pressure of each replica in the storage server from each storage server according to a preset period.
[0038] In order to obtain the read and write pressure of each replica in any storage server, an embodiment of the present invention further provides a load balancing method, which is applied to a distributed table system. The distributed table system includes a metadata server and multiple storage servers for storing data. The method is executed by the storage server and includes the following steps:
[0039] Receiving read request information and / or write request information of each replica;
[0040] The read / write pressure of each replica is determined according to the received read request information and / or write request information of each replica.
[0041] Exemplarily, the read-write pressure is the number of read requests and the number of write requests for the replicas. The read-write pressure of each replica is determined based on the read request information and / or write request information received for each replica. This may include: for each replica, the storage server may add 1 to the read-write pressure of the replica in the read-write pressure record when receiving the read request and / or write request of the replica, so as to obtain the read-write pressure of the replica.
[0042] S102, based on the read and write pressure of each replica in each storage server, determine a source storage server and a target storage server from multiple storage servers, the source storage server including the replica to be migrated.
[0043] In an optional implementation, the above step S102 may specifically include the following steps:
[0044] For any storage server, based on the obtained read and write pressure of each replica in the storage server, determine whether there is a replica to be migrated in the storage server;
[0045] When there is a replica to be migrated in any storage server, the storage server with the replica to be migrated is used as the source storage server, and a target storage server that can be migrated is determined in the distributed table system.
[0046] In a specific application, for any storage server, based on the obtained read-write pressure of each copy in the storage server, there may be multiple ways to determine whether there is a copy to be migrated in the storage server. Exemplarily, it can be determined that there is a copy to be migrated in the storage server whose read-write pressure of each copy in the storage server is greater than a preset pressure threshold; or, multiple storage servers can be sorted in descending order according to the size of the read-write pressure of each copy in the storage server, and it can be determined that there is a copy to be migrated in the storage server ranked in the first specified number of digits; or, it can be determined that the difference between the sum of the read-write pressure of each copy in the storage server and the average read-write pressure of each storage server in the distributed table system is greater than or equal to the read-write pressure threshold. There is a copy to be migrated in the storage server. Among them, the acquisition of the average read-write pressure of each storage server in the distributed table system includes: for each storage server, calculating the sum of the read-write pressure of each copy in the storage server to obtain the read-write pressure of the storage server; calculating the mean of the obtained read-write pressure of the storage server to obtain the average read-write pressure of each storage server. In order to facilitate understanding and reasonable layout, the third situation is described in detail in the form of an optional embodiment. Any method that can determine whether there are copies to be migrated in any storage server based on the obtained read and write pressure of each copy in the storage server can be used in the present invention, and this embodiment does not limit this.
[0047] Moreover, for any storage server, there are multiple ways to determine the replica to be migrated from the replicas of the storage server. Exemplarily, the replicas with a read-write pressure greater than a preset read-write pressure threshold can be selected from the replicas of the storage server as the replica to be migrated; or, the replicas in the storage server can be sorted in descending order according to the size of the read-write pressure, and the replicas ranked in the front specified number of places can be selected as the replica to be migrated; or, the replicas that meet the preset read-write pressure conditions can be selected from the replicas of the storage server as the replica to be migrated. Among them, the preset read-write pressure conditions include: the read-write pressure is not zero, and the difference between the read-write pressure of the storage server and the read-write pressure is greater than or equal to the above-mentioned average read-write pressure. In order to facilitate understanding and reasonable layout, the third case will be described in detail in the form of an optional embodiment. Any method that can determine the replica to be migrated from the replicas of the storage server for any storage server can be used in the present invention, and this embodiment does not limit this.
[0048] The target storage server that can be migrated is a storage server that can be migrated to the replica to be migrated. And, when there is a replica to be migrated in any storage server, the target storage server that can be migrated is determined in the distributed table system, and there can be multiple types. The method for determining the target storage server is described in detail in the form of an optional embodiment.
[0049] S103, migrating the replica to be migrated to the target storage server.
[0050] Corresponding to different methods of determining the target storage server, there are different methods of migrating the copy to be migrated to the target storage server. The method of migrating the copy to be migrated to the target storage server will be described in detail in the form of an optional implementation example.
[0051] In the solution provided by the present invention, the metadata server of the distributed table system obtains the read and write pressure of each replica in each storage server in the distributed table system; based on the read and write pressure of each replica in each storage server, the source storage server and the target storage server are determined from multiple storage servers, and the source storage server includes the replica to be migrated; and then the replica to be migrated is migrated to the target storage server. Thus, by migrating the replica to be migrated to the target storage server, the read and write pressure of the source storage server can be transferred to the target storage server, thereby achieving the balance of the read and write pressure between the source storage server and the target storage server in which the replica to be migrated exists in the entire distributed table system. It can be seen that this solution can reduce the problem of multiple master replicas with relatively large read and write pressures concentrated in the same storage server, resulting in excessive read and write pressure and unbalanced load on the storage server, thereby achieving load balancing of the distributed table system.
[0052] In an optional implementation manner, for any storage server, judging whether there is a replica to be migrated in the storage server based on the obtained read and write pressure of each replica in the storage server may specifically include the following steps:
[0053] For each storage server, calculate the sum of the read and write pressure of each replica in the storage server to obtain the read and write pressure of the storage server;
[0054] Calculate the average of the read and write pressures of the storage servers to obtain the average read and write pressures of the multiple storage servers;
[0055] For each storage server, if the difference between the read / write pressure of the storage server and the average read / write pressure is greater than or equal to a preset read / write pressure threshold, it is determined that there is a replica to be migrated in the storage server.
[0056] In specific applications, the preset read-write pressure threshold can be set based on historical experience. For example, when the read-write pressure is the number of read requests and the number of write requests, the preset read-write pressure threshold can be 3000-5000. If the difference between the read-write pressure of the storage server and the average read-write pressure is greater than or equal to the preset read-write pressure threshold, it indicates that the storage server has a relatively large read-write pressure among multiple storage servers, and it is likely that there are multiple master copies with relatively large read-write pressures. Therefore, it can be determined as a source storage server.
[0057] In addition, when judging whether the difference between the read-write pressure of the storage server and the average read-write pressure is greater than or equal to the preset read-write pressure threshold for multiple storage servers, the multiple storage servers can be sorted in descending order according to the read-write pressure, and the judgment is made for the sorted multiple storage servers to improve the efficiency of determining the source storage server. Exemplarily, according to the read-write pressure server_rw_qps of each storage server, the multiple storage servers are sorted in descending order, and then the above judgment is made for the sorted multiple storage servers. If any storage server satisfies: the read-write pressure server_rw_qps of the storage server - the average read-write pressure avg_rw_qps>=the preset read-write pressure threshold threshold_rw_qps; it can be determined that there is a replica to be migrated in the storage server.
[0058] In an optional implementation, after the storage server having the replica to be migrated is used as the source storage server, the load balancing method provided by the embodiment of the present invention may further include the following steps:
[0059] For each replica of the source storage server, when the read-write pressure of the replica is not zero, and the difference between the read-write pressure of the source storage server and the read-write pressure of the replica is greater than or equal to the average read-write pressure, the replica is determined as a replica to be migrated.
[0060] In order to ensure that when migrating the copy to be migrated, no new copy will be transferred into the source storage server, so as to reduce the process of repeatedly transferring the copy in, out, and in the source storage server, and improve the efficiency of load balancing, for any copy in the source storage server, if the read-write pressure of the copy is not zero, and the difference between the read-write pressure of the source storage server and the read-write pressure of the copy is greater than or equal to the average read-write pressure, the copy can be determined as a copy that can be migrated. Thus, when the copy to be migrated is transferred out from the source storage server, it can be ensured that the read-write pressure of the source storage server is greater than or equal to the average read-write pressure, and no new copy to be migrated will be transferred into the source storage server. In addition, the number of copies to be migrated can be one or more.
[0061] Among them, when the number of copies to be migrated in any source storage server is one, the risk of instability of the distributed table system caused by the transfer of multiple copies to be migrated to the same source storage server can be reduced. Specifically, when determining the copies to be migrated, the copies in the source storage server can be sorted in descending order according to the read and write pressure of the copies, and a copy to be migrated can be selected for the sorted multiple copies to improve the efficiency of determining the copies to be migrated. Exemplarily, the storage server with the copies to be migrated is used as the source storage server, which can be recorded as the source storage server Src. If the copies in a certain source storage server are sorted in descending order, a copy queue is obtained: copy t1, copy t2 and copy t3; wherein copy t1 satisfies: the read and write pressure of the source storage server server_rw_qps(Src)-the read and write pressure of copy t1 tablet_rw_qps>=average read and write pressure avg_rw_qps; the copy t1 can be determined as the copy to be migrated. Since descending sorting can ensure that the read and write pressure of copy t1 is not zero, and the copy to be migrated can be determined once, the efficiency of determining the copy to be migrated can be improved. Furthermore, the read / write pressure is not zero, so that the problem of invalid read / write pressure transfer caused by transferring the read / write pressure to a replica with zero read / write pressure can be avoided.
[0062] In an optional implementation, the above-mentioned determining a target storage server that can be migrated in the distributed table system may specifically include the following steps:
[0063] When there is a replica to be migrated in any storage server, determine whether the storage servers where other replicas of the shard to which the replica to be migrated belongs are located meet the preset pressure transfer conditions; wherein the preset pressure transfer conditions include: the sum of the read and write pressure of the storage server and the read and write pressure of the replica to be migrated is less than or equal to the average read and write pressure, and the storage server has not performed replica migration in the current replica migration phase;
[0064] If the preset pressure transfer conditions are met, the storage server where other copies of the shard to which the copy to be migrated belongs are located is determined as the target storage server;
[0065] Accordingly, in an optional implementation manner, the above-mentioned migrating the replica to be migrated to the target storage server may specifically include the following steps:
[0066] The master role of the replica to be migrated is exchanged with the slave role of the specified replica in the target storage server; wherein the specified replica is a replica belonging to the same shard as the replica to be migrated.
[0067] In specific applications, since the reading and writing of the replica usually falls on the master replica, the migration of the replica to be migrated to the target storage server can be done by exchanging the master replica role of the replica to be migrated with the slave replica role of the replica in the target storage server that belongs to the same shard as the replica to be migrated. In this way, the replica to be migrated becomes a slave replica, and a certain replica of the shard to which the replica to be migrated belongs becomes a master replica, thereby adjusting the read and write pressure. Based on this, when there is a replica to be migrated in any storage server, it can be determined whether the storage server where other replicas of the shard to which the replica to be migrated belongs meet the preset pressure transfer conditions, so as to determine the storage server where the slave replica that can be converted into the master replica is located.
[0068] Specifically, if the sum of the server read-write pressure of the storage server and the read-write pressure of the replica to be migrated is less than or equal to the average read-write pressure, it indicates that when the storage server transfers to the replica to be migrated, the read-write pressure of the storage server will not be greater than the average read-write pressure, causing the read-write pressure of the storage server to be too high. In addition, the storage server has not performed replica migration in the current replica migration phase, which can ensure that the storage server will only migrate the replica to be migrated once at most, and can ensure the controllability of the entire load balancing process, and ensure that the entire distributed table system reaches a load-balanced state. Exemplarily, for the storage server where other replicas of the shard T to which the replica R to be migrated belong are located, if the storage server satisfies: the read-write pressure of the storage server server_rw_qps + the read-write pressure of the replica to be migrated tablet_rw_qs <= average read-write pressure avg_rw_qps, and the storage server has not performed replica migration in the current replica migration phase, the storage server can be determined as the target storage server Dst.
[0069] In addition, when judging whether the storage server where other copies of the shard to which the copy to be migrated belongs are located meets the preset pressure transfer conditions, the judgment can be made in order of the read and write pressure of the storage servers where other copies of the shard to which the copy to be migrated belongs are located from small to large, so as to improve the efficiency of determining the target storage server.
[0070] like Figure 2 As shown, a flow chart of a load balancing method according to another embodiment of the present invention may include the following steps:
[0071] S201, obtaining the read and write pressure of each replica in each storage server in the distributed table system.
[0072] The above S201 and the above present invention Figure 1 S101 of the embodiment is the same step and will not be described in detail here. Figure 1 Description of embodiments.
[0073] S202: For each storage server, calculate the sum of the read and write pressures of the replicas in the storage server to obtain the read and write pressure of the storage server.
[0074] S203, calculating the average of the obtained read and write pressures of the storage servers to obtain the average read and write pressures of the multiple storage servers.
[0075] S204: For each storage server, if the difference between the read / write pressure of the storage server and the average read / write pressure is greater than or equal to a preset read / write pressure threshold, it is determined that there is a replica to be migrated in the storage server.
[0076] S205: Use the storage server where the replica to be migrated exists as the source storage server.
[0077] S206, for each replica of the source storage server, when the read / write pressure of the replica is not zero, and the difference between the read / write pressure of the source storage server and the read / write pressure of the replica is greater than or equal to the average read / write pressure, the replica is determined as a replica to be migrated.
[0078] The above steps S202 to S206 are consistent with the present invention. Figure 1 In the optional embodiment, the steps for determining the source storage server and the replica to be migrated are the same and will not be repeated here. For details, see the above-mentioned present invention Figure 1 Description of alternative embodiments.
[0079] S207, when there is a copy to be migrated in any storage server, determine whether the storage server where other copies of the shard to which the copy to be migrated belongs are located meets the preset pressure transfer condition; if the storage server meets the preset pressure transfer condition, execute steps S208 to S209; if the storage servers where other copies of the shard to which the copy to be migrated belongs are located do not meet the preset pressure transfer condition, execute steps S210 to S212;
[0080] Among them, the preset pressure transfer conditions include: the sum of the server read and write pressure of the storage server and the read and write pressure of the copy to be migrated is less than or equal to the average read and write pressure, and in the traversal of adjusting the read and write pressure, no pressure transfer task corresponding to the storage server is created.
[0081] S208: Determine the storage server where other copies of the shard to which the copy to be migrated belongs are located as the target storage server.
[0082] S209, exchanging the master copy role of the copy to be migrated with the slave copy role of the designated copy in the target storage server.
[0083] The designated replica is a replica that belongs to the same shard as the replica to be migrated.
[0084] S210, for a storage server other than a source storage server in a distributed table system, determining whether the storage server meets a preset copy transfer condition.
[0085] The preset replica transfer conditions include: the storage server does not store a replica of the shard to which the replica to be migrated belongs, the sum of the read-write pressure of the storage server and the read-write pressure of the replica to be migrated is less than or equal to the average read-write pressure, and the storage server does not perform replica migration in the current replica migration phase;
[0086] S211: If the storage server meets a preset copy transfer condition, the storage server is determined as a target storage server.
[0087] S212, migrating the replica to be migrated from the source storage server to the target storage server for storage.
[0088] In specific applications, since the read and write pressure of the storage server comes from the replica stored in the storage server, the replica to be migrated can be transferred from the source storage server where the replica to be migrated is located to the target storage server for storage. In this way, the read and write pressure borne by the source storage server is transferred to the target storage server to adjust the read and write pressure. To this end, for the storage servers other than the source storage server of the distributed table system, it is possible to determine whether the storage server meets the preset replica transfer conditions to determine the target storage server.
[0089] Furthermore, in order to ensure the performance of the distributed table system, there can be only one replica belonging to the same shard in the same storage server. Therefore, the preset replica transfer condition needs to include: the storage server does not store a replica of the shard to which the replica to be migrated belongs, which is equivalent to not meeting the preset pressure transfer condition in step S207. Furthermore, if the sum of the server read-write pressure of the storage server and the read-write pressure of the replica to be migrated is less than or equal to the average read-write pressure, it indicates that when the storage server transfers the read-write pressure, the read-write pressure of the storage server will not be greater than the average read-write pressure, causing the storage server to bear too much read-write pressure. Furthermore, the storage server does not perform replica migration in the current replica migration phase, which can ensure that the storage server will only perform one pressure transfer task at most, thereby ensuring the controllability of the entire load balancing process, and further enabling the distributed table system to reach a load-balanced state when the traversal is completed. Exemplarily, for a storage server other than a source storage server in a distributed table system, if the storage server satisfies: the read and write pressure of the storage server server_rw_qps + the read and write pressure of the replica to be migrated tablet_rw_qs <= the average read and write pressure avg_rw_qps, and is in the created pressure transfer task, and the storage server has not performed replica migration in the current replica migration phase, the storage server can be determined as the target storage server Dst.
[0090] In addition, when judging whether a storage server other than the source storage server of the distributed table system meets the preset copy transfer conditions, the judgment can be made in order of the read and write pressure of the storage servers other than the source storage server of the distributed table system from small to large, so as to improve the efficiency of determining the target storage server.
[0091] Corresponding to the above method embodiment, an embodiment of the present invention further provides a load balancing device.
[0092] like Figure 3 As shown, a load balancing device according to an embodiment of the present invention is applied to a distributed table system, wherein the distributed table system includes a metadata server and a plurality of storage servers for storing data, and the device is included in the metadata server, including:
[0093] The read / write pressure acquisition module 301 is used to acquire the read / write pressure of each replica in each storage server in the distributed table system;
[0094] A server determination module 302, configured to determine a source storage server and a target storage server from the plurality of storage servers based on the read and write pressure of each replica in each storage server, wherein the source storage server includes the replica to be migrated;
[0095] The load balancing module 303 is used to migrate the replica to be migrated to the target storage server.
[0096] In the solution provided by the present invention, the metadata server of the distributed table system obtains the read and write pressure of each replica in each storage server in the distributed table system; based on the read and write pressure of each replica in each storage server, the source storage server and the target storage server are determined from multiple storage servers, and the source storage server includes the replica to be migrated; and then the replica to be migrated is migrated to the target storage server. Thus, by migrating the replica to be migrated to the target storage server, the read and write pressure of the source storage server can be transferred to the target storage server, thereby achieving the balance of the read and write pressure between the source storage server and the target storage server in which the replica to be migrated exists in the entire distributed table system. It can be seen that this solution can reduce the problem of multiple master replicas with relatively large read and write pressures concentrated in the same storage server, resulting in excessive read and write pressure and unbalanced load on the storage server, thereby achieving load balancing of the distributed table system.
[0097] Optionally, the server determination module 302 includes:
[0098] A migration judgment submodule is used to judge, for any storage server, whether there is a replica to be migrated in the storage server based on the obtained read and write pressure of each replica in the storage server;
[0099] The target storage server determination submodule is used to, when there is a copy to be migrated in any of the storage servers, use the storage server with the copy to be migrated as the source storage server, and determine a migratable target storage server in the distributed table system.
[0100] Optionally, the migration judgment submodule is specifically used to:
[0101] For each storage server, calculate the sum of the read and write pressure of each replica in the storage server to obtain the read and write pressure of the storage server;
[0102] Calculate the average of the read and write pressures of the storage servers to obtain the average read and write pressures of the multiple storage servers;
[0103] For each storage server, if the difference between the read / write pressure of the storage server and the average read / write pressure is greater than or equal to a preset read / write pressure threshold, it is determined that there is a replica to be migrated in the storage server.
[0104] Optionally, the device further includes: a replica to be migrated determining module, configured to:
[0105] After the target storage server determines that the sub-module will use the storage server where the copy to be migrated exists as the source storage server, for each copy of the source storage server, when the read-write pressure of the copy is not zero, and the difference between the read-write pressure of the source storage server and the read-write pressure of the copy is greater than or equal to the average read-write pressure, the copy is determined as the copy to be migrated.
[0106] Optionally, the target storage server determines a submodule, specifically for:
[0107] When there is a replica to be migrated in any of the storage servers, determine whether the storage servers where other replicas of the shard to which the replica to be migrated belongs are located meet the preset pressure transfer conditions; wherein the preset pressure transfer conditions include: the sum of the read and write pressure of the storage server and the read and write pressure of the replica to be migrated is less than or equal to the average read and write pressure, and the storage server has not performed replica migration in the current replica migration phase;
[0108] If the preset pressure transfer condition is met, the storage server where other copies of the shard to which the copy to be migrated belongs are located is determined as the target storage server.
[0109] Optionally, the load balancing module 303 is specifically used to:
[0110] The master copy role of the copy to be migrated is exchanged with the slave copy role of the designated copy in the target storage server;
[0111] The designated replica is a replica that belongs to the same shard as the replica to be migrated.
[0112] Optionally, the target storage server determines a submodule, specifically for:
[0113] After determining whether the storage servers where other copies of the shard to which the copy to be migrated belongs are located meet the preset pressure transfer condition, if the storage servers where other copies of the shard to which the copy to be migrated belongs are located do not meet the preset pressure transfer condition, for the storage servers in the distributed table system other than the source storage server, determine whether the storage servers meet the preset copy transfer condition;
[0114] If the preset replica transfer-in condition is met, the storage server is determined as the target storage server; wherein the preset replica transfer-in condition includes: the storage server does not store a replica of the shard to which the replica to be migrated belongs, the sum of the read-write pressure of the storage server and the read-write pressure of the replica to be migrated is less than or equal to the average read-write pressure, and the storage server does not perform replica migration in the current replica migration phase;
[0115] The load balancing module 303 is specifically used for:
[0116] The replica to be migrated is migrated from the source storage server to the target storage server for storage.
[0117] Optionally, the read / write pressure acquisition module 301 is specifically used for:
[0118] The read and write pressure of each replica in each storage server in the distributed table system is periodically obtained.
[0119] like Figure 4 As shown, a load balancing device according to an embodiment of the present invention is applied to a distributed table system, wherein the distributed table system includes a metadata server and a plurality of storage servers for storing data, and the device is included in the storage server, including:
[0120] A request information receiving module 401 is used to receive read request information and / or write request information of each replica;
[0121] The read / write pressure determination module 402 is used to determine the read / write pressure of each replica according to the received read request information and / or write request information of each replica.
[0122] In the solution provided by the present invention, the metadata server of the distributed table system obtains the read and write pressure of each replica in each storage server in the distributed table system; based on the read and write pressure of each replica in each storage server, the source storage server and the target storage server are determined from multiple storage servers, and the source storage server includes the replica to be migrated; and then the replica to be migrated is migrated to the target storage server. Thus, by migrating the replica to be migrated to the target storage server, the read and write pressure of the source storage server can be transferred to the target storage server, thereby achieving the balance of the read and write pressure between the source storage server and the target storage server in which the replica to be migrated exists in the entire distributed table system. It can be seen that this solution can reduce the problem of multiple master replicas with relatively large read and write pressures concentrated in the same storage server, resulting in excessive read and write pressure and unbalanced load on the storage server, thereby achieving load balancing of the distributed table system.
[0123] Corresponding to the above embodiment, the embodiment of the present invention further provides a server, such as Figure 5 As shown, the server may include:
[0124] Processor 501, communication interface 502, memory 503 and communication bus 504, wherein the processor 501, communication interface 502, memory 503 communicate with each other via the communication bus 504;
[0125] Memory 503, used for storing computer programs;
[0126] The processor 501 is used to implement the steps of any load balancing method in the above embodiments when executing the computer program stored in the above memory 503.
[0127] In a specific application, the present invention Figure 5 The server in the embodiment may be a metadata server in a distributed table system, or a storage server in a distributed table system.
[0128] In the solution provided by the present invention, the metadata server of the distributed table system obtains the read and write pressure of each replica in each storage server in the distributed table system; based on the read and write pressure of each replica in each storage server, the source storage server and the target storage server are determined from multiple storage servers, and the source storage server includes the replica to be migrated; and then the replica to be migrated is migrated to the target storage server. Thus, by migrating the replica to be migrated to the target storage server, the read and write pressure of the source storage server can be transferred to the target storage server, thereby achieving the balance of the read and write pressure between the source storage server and the target storage server in which the replica to be migrated exists in the entire distributed table system. It can be seen that this solution can reduce the problem of multiple master replicas with relatively large read and write pressures concentrated in the same storage server, resulting in excessive read and write pressure and unbalanced load on the storage server, thereby achieving load balancing of the distributed table system.
[0129] The memory may include RAM (Random Access Memory) or NVM (Non-Volatile Memory), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the processor.
[0130] The above-mentioned processor can be a general-purpose processor, including a CPU (Central Processing Unit), NP (Network Processor), etc.; it can also be a DSP (Digital Signal Processor), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0131] A computer-readable storage medium provided in an embodiment of the present invention is included in a metadata server. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the steps of any load balancing method in the above embodiments are implemented.
[0132] In the solution provided by the present invention, the metadata server of the distributed table system obtains the read and write pressure of each replica in each storage server in the distributed table system; based on the read and write pressure of each replica in each storage server, the source storage server and the target storage server are determined from multiple storage servers, and the source storage server includes the replica to be migrated; and then the replica to be migrated is migrated to the target storage server. Thus, by migrating the replica to be migrated to the target storage server, the read and write pressure of the source storage server can be transferred to the target storage server, thereby achieving the balance of the read and write pressure between the source storage server and the target storage server in which the replica to be migrated exists in the entire distributed table system. It can be seen that this solution can reduce the problem of multiple master replicas with relatively large read and write pressures concentrated in the same storage server, resulting in excessive read and write pressure and unbalanced load on the storage server, thereby achieving load balancing of the distributed table system.
[0133] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is executed on a computer, the computer executes the load balancing method described in any one of the above embodiments.
[0134] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer, server or data center to another website, computer, server or data center via wired (e.g., coaxial cable, optical fiber, DSL (Digital Subscriber Line) or wireless (e.g., infrared, radio, microwave, etc.) means. The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated therein. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD (Digital Versatile Disc)), or a semiconductor medium (e.g., an SSD (Solid State Disk)), etc.
[0135] In this article, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0136] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and server embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0137] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A load balancing method, characterized in that: Applied to a distributed table system, the distributed table system includes a metadata server and a plurality of storage servers for storing data, the method is executed by the metadata server, and includes: Obtaining the read and write pressure of each replica in each storage server in the distributed table system; the read and write pressure of any replica is the processing resources of the storage server occupied in response to read requests and write requests for the replica; Based on the read and write pressure of each replica in each storage server, determine a source storage server and a target storage server from the multiple storage servers, wherein the source storage server includes the replica to be migrated; For each storage server, calculate the sum of the read and write pressure of each replica in the storage server to obtain the read and write pressure of the storage server; Calculate the average of the read and write pressures of the storage servers to obtain the average read and write pressures of the multiple storage servers; For each replica of the source storage server, when the read / write pressure of the replica is not zero, and the difference between the read / write pressure of the source storage server and the read / write pressure of the replica is greater than or equal to the average read / write pressure, the replica is determined as a replica to be migrated; Migrate the replica to be migrated to the target storage server.
2. The method according to claim 1, characterized in that: The determining of a source storage server and a target storage server from the plurality of storage servers based on the read / write pressure of each replica in each storage server includes: For any storage server, based on the obtained read and write pressure of each replica in the storage server, determine whether there is a replica to be migrated in the storage server; When there is a replica to be migrated in any of the storage servers, the storage server with the replica to be migrated is used as a source storage server, and a migratable target storage server is determined in the distributed table system.
3. The method according to claim 2, characterized in that The step of determining, for any storage server, whether there is a replica to be migrated in the storage server based on the obtained read / write pressure of each replica in the storage server includes: For each storage server, if the difference between the read / write pressure of the storage server and the average read / write pressure is greater than or equal to a preset read / write pressure threshold, it is determined that there is a replica to be migrated in the storage server.
4. The method according to claim 3, characterized in that Determining a migratable target storage server in the distributed table system includes: Determine whether the storage server where other copies of the shard to which the copy to be migrated belongs are located meets the preset pressure transfer condition; wherein the preset pressure transfer condition includes: the sum of the read and write pressure of the storage server and the read and write pressure of the copy to be migrated is less than or equal to the average read and write pressure, and the storage server has not performed copy migration in the current copy migration phase; If the preset pressure transfer condition is met, the storage server where other copies of the shard to which the copy to be migrated belongs are located is determined as the target storage server.
5. The method according to claim 4, characterized in that The step of migrating the replica to be migrated to the target storage server includes: The master copy role of the copy to be migrated is exchanged with the slave copy role of the designated copy in the target storage server; The designated replica is a replica that belongs to the same shard as the replica to be migrated.
6. The method according to claim 4, characterized in that After determining whether the storage server where other copies of the shard to which the copy to be migrated belongs are located meets the preset pressure transfer condition, the method further includes: If the storage servers where other copies of the shard to which the copy to be migrated belongs are located do not meet the preset pressure transfer condition, for the storage servers in the distributed table system other than the source storage server, determine whether the storage servers meet the preset copy transfer condition; If the preset replica transfer-in condition is met, the storage server is determined as the target storage server; wherein the preset replica transfer-in condition includes: the storage server does not store a replica of the shard to which the replica to be migrated belongs, the sum of the read-write pressure of the storage server and the read-write pressure of the replica to be migrated is less than or equal to the average read-write pressure, and the storage server does not perform replica migration in the current replica migration phase; The step of migrating the replica to be migrated to the target storage server includes: The replica to be migrated is migrated from the source storage server to the target storage server for storage.
7. The method according to any one of claims 1 to 6, characterized in that: The obtaining of the read / write pressure of each replica in each storage server in the distributed table system includes: The read and write pressure of each replica in each storage server in the distributed table system is periodically obtained.
8. A load balancing method, characterized in that: Applied to a distributed table system, the distributed table system includes a metadata server and a plurality of storage servers for storing data, the method is executed by the storage servers, and includes: Receiving read request information and / or write request information of each replica; Determine the read / write pressure of each replica based on the received read request information and / or write request information of each replica; the read / write pressure of any replica is the processing resources of the storage server occupied in response to the read request and write request for the replica; So that the metadata server performs the following steps: Based on the read and write pressure of each replica in each storage server, determine a source storage server and a target storage server from the multiple storage servers, wherein the source storage server includes the replica to be migrated; For each storage server, calculate the sum of the read and write pressure of each replica in the storage server to obtain the read and write pressure of the storage server; Calculate the average of the read and write pressures of the storage servers to obtain the average read and write pressures of the multiple storage servers; For each replica of the source storage server, when the read / write pressure of the replica is not zero, and the difference between the read / write pressure of the source storage server and the read / write pressure of the replica is greater than or equal to the average read / write pressure, the replica is determined as a replica to be migrated; Migrate the replica to be migrated to the target storage server.
9. A load balancing device, characterized in that: Applied to a distributed table system, the distributed table system includes a metadata server and a plurality of storage servers for storing data, the device is included in the metadata server, and includes: A read / write pressure acquisition module is used to acquire the read / write pressure of each replica in each storage server in the distributed table system; the read / write pressure of any replica is the processing resources of the storage server occupied in response to read requests and write requests for the replica; A server determination module, configured to determine a source storage server and a target storage server from the plurality of storage servers based on the read and write pressure of each replica in each storage server, wherein the source storage server includes the replica to be migrated; The server determination module is further used to: for each storage server, calculate the sum of the read and write pressures of each replica in the storage server to obtain the read and write pressure of the storage server; and calculate the average of the obtained read and write pressures of the storage servers to obtain the average read and write pressures of the multiple storage servers; The replica to be migrated determination module is used to: for each replica of the source storage server, when the read-write pressure of the replica is not zero, and the difference between the read-write pressure of the source storage server and the read-write pressure of the replica is greater than or equal to the average read-write pressure, determine the replica as a replica to be migrated; The load balancing module is used to migrate the replica to be migrated to the target storage server.
10. The device according to claim 9, characterized in that The server determination module includes: A migration judgment submodule is used to judge, for any storage server, whether there is a replica to be migrated in the storage server based on the obtained read and write pressure of each replica in the storage server; The target storage server determination submodule is used to, when there is a copy to be migrated in any of the storage servers, use the storage server with the copy to be migrated as the source storage server, and determine a migratable target storage server in the distributed table system.
11. The device according to claim 10, characterized in that The migration judgment submodule is specifically used for: For each storage server, if the difference between the read / write pressure of the storage server and the average read / write pressure is greater than or equal to a preset read / write pressure threshold, it is determined that there is a replica to be migrated in the storage server.
12. A load balancing device, characterized in that: Applied to a distributed table system, the distributed table system includes a metadata server and a plurality of storage servers for storing data, the device is included in the storage server, and includes: A request information receiving module, used to receive read request information and / or write request information of each replica; A read / write pressure determination module is used to determine the read / write pressure of each replica according to the received read request information and / or write request information of each replica; the read / write pressure of any replica is the processing resources of the storage server occupied in response to the read request and write request for the replica; So that the metadata server performs the following steps: Based on the read and write pressure of each replica in each storage server, determine a source storage server and a target storage server from the multiple storage servers, wherein the source storage server includes the replica to be migrated; For each storage server, calculate the sum of the read and write pressure of each replica in the storage server to obtain the read and write pressure of the storage server; Calculate the average of the read and write pressures of the storage servers to obtain the average read and write pressures of the multiple storage servers; For each replica of the source storage server, when the read / write pressure of the replica is not zero, and the difference between the read / write pressure of the source storage server and the read / write pressure of the replica is greater than or equal to the average read / write pressure, the replica is determined as a replica to be migrated; Migrate the replica to be migrated to the target storage server.
13. A server, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the bus; the memory is used to store computer programs; the processor is used to execute the programs stored in the memory to implement the method steps described in any one of claims 1-8.
14. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method steps according to any one of claims 1 to 8 are implemented.