CN113867928A - Load balancing method and device and server - Google Patents
Load balancing method and device and server Download PDFInfo
- Publication number
- CN113867928A CN113867928A CN202010620901.6A CN202010620901A CN113867928A CN 113867928 A CN113867928 A CN 113867928A CN 202010620901 A CN202010620901 A CN 202010620901A CN 113867928 A CN113867928 A CN 113867928A
- Authority
- CN
- China
- Prior art keywords
- copy
- storage server
- read
- migrated
- server
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 55
- 238000012546 transfer Methods 0.000 claims description 37
- 230000005012 migration Effects 0.000 claims description 25
- 238000013508 migration Methods 0.000 claims description 25
- 239000012634 fragment Substances 0.000 claims description 16
- 238000004590 computer program Methods 0.000 claims description 14
- 238000004891 communication Methods 0.000 claims description 12
- 230000008569 process Effects 0.000 description 7
- 230000009471 action Effects 0.000 description 3
- 238000010586 diagram Methods 0.000 description 3
- 238000012545 processing Methods 0.000 description 3
- 238000013500 data storage Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5083—Techniques for rebalancing the load in a distributed system
- G06F9/5088—Techniques for rebalancing the load in a distributed system involving task migration
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiment of the invention provides a load balancing method, a load balancing device and a server. The method is executed by the metadata server, and reading and writing pressure of each copy in each storage server in the distributed table system is obtained; determining a source storage server and a target storage server from the plurality of storage servers based on the read-write pressure of each copy in each storage server, wherein the source storage server comprises a copy to be migrated; and migrating the copy to be migrated to the target storage server. The scheme can realize the load balance of the distributed table system.
Description
Technical Field
The present invention relates to the field of distributed storage technologies, and in particular, to a load balancing method, apparatus, and server.
Background
The distributed table system is a semi-structured data storage system widely used for storing trillion-level data, can be regarded as a distributed cluster, and specifically can comprise a metadata server for scheduling various tasks of the system and a storage server for storing data. In order to ensure data security and tolerate a bad disk and a server crash, a distributed table system generally stores data in the form of multiple copies. For this reason, on the storage logic level, the storage units of data in the distributed table system are "table", "slice" and "copy" from large to small: a distributed table system can store a plurality of tables, and one table comprises a plurality of fragments, and each fragment consists of a plurality of copies.
In the related art, for multiple copies belonging to the same segment, one copy is generally designated as a master copy, and the other copies are designated as slave copies, so that consistency of the copies is maintained based on master-slave relationship of the copies, and read requests and write requests for data only fall on the master copy. Moreover, in order to improve the performance of the cluster, for any shard, one storage server in the cluster only stores one copy of the shard. On the basis, in order to reduce the situation that a single storage server bears excessive reading and writing pressure so as to improve the cluster performance, the load balancing can be carried out on the cluster. Specifically, the read-write pressure of all the storage servers in the cluster can be approximated as a target of load balancing, and the master copy and the slave copy are exchanged in master-slave roles on the basis that the number of the master copies in each storage server is the same.
However, in a specific application, the read and write pressures of the master copies belonging to different slices are not the same. At this time, if load balancing is still performed based on the same number of master copies in each storage server, it is likely that a plurality of master copies with relatively large read-write pressures are concentrated in the same storage server, which results in the problem of excessive storage read-write pressures and unbalanced load.
Disclosure of Invention
The embodiment of the invention aims to provide a load balancing method, a load balancing device and a load balancing server so as to achieve the effect of load balancing of a distributed table system. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a load balancing method applied to a distributed table system, where the distributed table system includes a metadata server and multiple storage servers for storing data, and the method is performed by the metadata server and includes:
acquiring the read-write pressure of each copy in each storage server in the distributed table system;
determining a source storage server and a target storage server from the plurality of storage servers based on the read-write pressure of each copy in each storage server, wherein the source storage server comprises a copy to be migrated;
and migrating the copy to be migrated to the target storage server.
In a second aspect, an embodiment of the present invention provides a load balancing method applied to a distributed table system, where the distributed table system includes a metadata server and a plurality of storage servers for storing data, and the method is performed by the storage servers, and includes:
receiving reading request information and/or writing request information of each copy;
and determining the read-write pressure of each copy according to the received read request information and/or write request information of each copy.
In a third aspect, an embodiment of the present invention provides a load balancing apparatus, which is applied to a distributed table system, where the distributed table system includes a metadata server and a plurality of storage servers for storing data, and the apparatus is included in the metadata server, and includes:
the reading and writing pressure acquisition module is used for acquiring the reading and writing pressure of each copy in each storage server in the distributed table system;
a server determining module, configured to determine a source storage server and a target storage server from the multiple storage servers based on read-write pressure of each copy in each storage server, where the source storage server includes a copy to be migrated;
a target storage server determining module, configured to determine, when a copy to be migrated exists in any one of the storage servers, a migratable target storage server in the distributed table system;
and the load balancing module is used for migrating the copy to be migrated to the target storage server. .
In a fourth aspect, an embodiment of the present invention provides a server, where the server includes:
the system comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the bus; a memory for storing a computer program; and a processor, configured to execute the program stored in the memory, and implement the steps of the load balancing method provided in the first aspect or the second aspect.
In a fifth aspect, an embodiment of the present invention provides a computer-readable storage medium, where a computer program is stored in the storage medium, and when the computer program is executed by a processor, the computer program implements the steps of the load balancing method provided in the first aspect or the second aspect.
In the scheme provided by the invention, a metadata server of the distributed table system acquires the read-write pressure of each copy in each storage server in the distributed table system; determining a source storage server and a target storage server from a plurality of storage servers based on the read-write pressure of each copy in each storage server, wherein the source storage server comprises the copy to be migrated; and then the copy to be migrated is migrated to the target storage server. Therefore, by migrating the to-be-migrated copy to the target storage server, the read-write pressure of the source storage server can be transferred to the target storage server, so that the balance of the read-write pressure between the source storage server and the target storage server with the to-be-migrated copy in the whole distributed table system is realized. Therefore, the problems of overlarge read-write pressure and unbalanced load of the storage server caused by the fact that a plurality of master copies with relatively large read-write pressure are concentrated in the same storage server can be solved, and load balance of a distributed table system is achieved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
Fig. 1 is a schematic flowchart of a load balancing method according to an embodiment of the present invention;
fig. 2 is a schematic flow chart of a load balancing method according to another embodiment of the present invention;
fig. 3 is a schematic structural diagram of a load balancing apparatus according to an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of a load balancing apparatus according to another embodiment of the present invention;
fig. 5 is a schematic structural diagram of a server according to an embodiment of the present invention.
Detailed Description
In order to make those skilled in the art better understand the technical solution of the present invention, the technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
First, a method for load balancing according to an embodiment of the present invention will be described.
The load balancing method provided by the embodiment of the invention can be applied to a distributed table system, the distributed table system comprises a metadata server and a plurality of storage servers for storing data, and the method is executed by the metadata server. The metadata server may specifically include a desktop computer, a portable computer, an internet television, an intelligent mobile terminal, a wearable intelligent terminal, a server, and the like, which are not limited herein, and any electronic device that can implement the embodiment of the present invention may be used as the metadata server of the present invention, and belongs to the protection scope of the embodiment of the present invention.
As shown in fig. 1, a flow of a method for load balancing according to an embodiment of the present invention may include the following steps:
s101, acquiring the reading and writing pressure of each copy in each storage server in the distributed table system.
The reading and writing pressure of any copy is the processing pressure borne by the storage server to which the copy belongs for the reading and writing of the copy; the read-write pressure of any storage server is the total read-write pressure of all the copies in the storage server. The read and write pressures of any copy may be varied in a particular application. For example, the read-write pressure of any copy may be the number of read requests and the number of write requests for that copy; alternatively, the read-write pressure of any copy may be that processing resources of the storage server are occupied when the read request and the write request to the copy are responded.
In addition, the specific way of the metadata server acquiring the read-write pressure of each copy in each storage server in the distributed table system may be various, and the following description is provided in the form of an alternative embodiment.
In an optional implementation manner, the obtaining of the read-write pressure of each copy in each storage server in the distributed table system may include the following steps:
and periodically acquiring the read-write pressure of each copy in each storage server in the distributed table system.
In a specific application, the metadata server periodically obtains the read-write pressure of each copy in each storage server in the distributed table system, and the read-write pressure may be multiple. For example, the metadata server may passively receive the read-write pressure of each copy in the storage server, which is actively sent to the metadata server by the storage server according to a preset period. Or, for example, the metadata server may actively request, at a preset period, each storage server for the read-write pressure of each copy in the storage server.
In order to obtain read-write pressure of each copy in any storage server, an embodiment of the present invention further provides a load balancing method, which is applied to a distributed table system, where 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 and includes the following steps:
receiving reading request information and/or writing request information of each copy;
and determining the read-write pressure of each copy according to the received read request information and/or write request information of each copy.
For example, the read-write pressure is the number of read requests and the number of write requests for the copies, and determining the read-write pressure of each copy according to the received read request information and/or write request information of each copy may include: for each copy, the storage server may add 1 to the read-write pressure of the copy in the read-write pressure record when receiving a read request and/or a write request of the copy, to obtain the read-write pressure of the copy.
S102, determining a source storage server and a target storage server from a plurality of storage servers based on the read-write pressure of each copy in each storage server, wherein the source storage server comprises the copy to be migrated.
In an optional implementation manner, the step S102 may specifically include the following steps:
for any storage server, judging whether the storage server has a copy to be migrated or not based on the obtained read-write pressure of each copy in the storage server;
when a copy to be migrated exists in any storage server, the storage server with the copy to be migrated is used as a source storage server, and a migratable target storage server is determined in the distributed table system.
In a specific application, for any storage server, there may be multiple ways of determining whether there is a copy to be migrated in the storage server based on the obtained read-write pressure of each copy in the storage server. For example, it may be determined that a copy to be migrated exists in a storage server in which the read-write pressure of each copy in the storage server is greater than a preset pressure threshold; or, the plurality of storage servers can be sorted in a descending order according to the magnitude of the read-write pressure of each copy in the storage server, and the storage servers with the previously specified number of bits are judged to have the copy to be migrated; or, it may be determined that the copy to be migrated exists in the storage server where the sum of the read-write pressures of the copies in the storage server and the difference between the average read-write pressures of the storage servers in the distributed table system are greater than or equal to the read-write pressure threshold. The acquisition of the average read-write pressure of each storage server in the distributed table system comprises the following steps: calculating the sum of the read-write pressure of each copy in each storage server aiming at each storage server to obtain the read-write pressure of the storage server; and calculating the average value of the obtained read-write pressure of the storage servers to obtain the average read-write pressure of each storage server. For ease of understanding and reasonable layout, the third case is described in detail below in the form of an alternative embodiment. Any method that can determine whether a copy to be migrated exists in any storage server based on the obtained read-write pressure of each copy in the storage server can be used in the present invention, which is not limited in this embodiment.
Moreover, for any storage server, the manner of determining the copy to be migrated from each copy of the storage server may be various. For example, a copy with a read-write pressure greater than a preset read-write pressure threshold may be selected from the copies of the storage server as a copy to be migrated; or, the copies in the storage server may be sorted in descending order according to the magnitude of the read-write pressure, and the copies with the number of bits specified in the front are selected as the copies to be migrated; or, a copy meeting a preset read-write pressure condition may be selected from the copies of the storage server as a copy to be migrated. Wherein, the preset reading and writing pressure conditions comprise: 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 average read-write pressure. For ease of understanding and reasonable layout, the third case is described in detail below in the form of an alternative embodiment. Any method that can determine the copy to be migrated from each copy of any storage server can be used in the present invention, and this embodiment does not limit this.
The migratable target storage server is a storage server capable of migrating the copy to be migrated. Moreover, when a copy to be migrated exists in any storage server, multiple types of storage servers can be determined in the distributed table system. The determination manner of the target storage server is described in detail in the following with an alternative embodiment.
S103, migrating the copy to be migrated to the target storage server.
Different ways of migrating the copy to be migrated to the target storage server exist corresponding to different determined ways of the target storage server, and then, in the form of an optional embodiment, a way of migrating the copy to be migrated to the target storage server is described in detail.
In the scheme provided by the invention, a metadata server of the distributed table system acquires the read-write pressure of each copy in each storage server in the distributed table system; determining a source storage server and a target storage server from a plurality of storage servers based on the read-write pressure of each copy in each storage server, wherein the source storage server comprises the copy to be migrated; and then the copy to be migrated is migrated to the target storage server. Therefore, by migrating the to-be-migrated copy to the target storage server, the read-write pressure of the source storage server can be transferred to the target storage server, so that the balance of the read-write pressure between the source storage server and the target storage server with the to-be-migrated copy in the whole distributed table system is realized. Therefore, the problems of overlarge read-write pressure and unbalanced load of the storage server caused by the fact that a plurality of master copies with relatively large read-write pressure are concentrated in the same storage server can be solved, and load balance of a distributed table system is achieved.
In an optional implementation manner, the above determining, for any storage server, whether there is a copy to be migrated in the storage server based on the obtained read-write pressure of each copy in the storage server may specifically include the following steps:
calculating the sum of the read-write pressure of each copy in each storage server aiming at each storage server to obtain the read-write pressure of the storage server;
calculating the average value of the obtained read-write pressures of the storage servers to obtain the average read-write pressure of the plurality of storage servers;
and for each storage server, if the difference value 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 value, judging that the copy to be migrated exists in the storage server.
In a specific application, the preset read-write pressure threshold value can be set according to 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 may be 3000 and 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 is a relatively large read-write pressure of a plurality of storage servers, and a plurality of relatively large master copies of the relatively large read-write pressure are likely to be concentrated, so that the storage server can be determined as a source storage server.
In addition, when the difference between the read-write pressure of the storage server and the average read-write pressure is judged to be greater than or equal to the preset read-write pressure threshold value or not for the plurality of storage servers, the plurality of storage servers can be sorted in a descending order according to the read-write pressure, and the plurality of storage servers after sorting can be judged, so that the determining efficiency of the source storage server can be improved. Illustratively, according to the read-write pressure server _ rw _ qps of each storage server, the storage servers are sorted in a descending order, and then the sorted storage servers are judged, if any storage server meets the following conditions: the read-write pressure server _ rw _ qps-average read-write pressure avg _ rw _ qps > of the storage server is the preset read-write pressure threshold value threshold _ rw _ qps; it may be determined that there is a copy to be migrated in the storage server.
In an optional implementation manner, after the storage server having the copy to be migrated is used as the source storage server, the load balancing method provided in the embodiment of the present invention may further include the following steps:
and 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, determining the copy as the copy to be migrated.
In order to ensure that a new copy cannot be transferred into a source storage server when the copy to be transferred is transferred, so as to reduce the processes of repeatedly transferring, transferring and transferring the copy into and out of the source storage server and improve the efficiency of load balancing, for the copy in any 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 the copy capable of being transferred. Therefore, when the copy to be migrated is transferred out of the source storage server, the read-write pressure of the source storage server can be ensured to be greater than or equal to the average read-write pressure, and the source storage server cannot be transferred into a new copy to be migrated. And, the number of copies to be migrated may be one or more.
When the number of the to-be-migrated copies in any source storage server is one, the unstable risk of the distributed table system caused by the transfer of a plurality of to-be-migrated copies to the same source storage server can be reduced. Specifically, when determining the to-be-migrated copy, the copies in the source storage server may be sorted in a descending order according to the read-write pressure of the copies, and one to-be-migrated copy is selected for the sorted multiple copies, so as to improve the determination efficiency of the to-be-migrated copy. For example, a storage server with a copy to be migrated is taken as a source storage server and may be recorded as a source storage server Src, and if the copies in a certain source storage server are sorted in a descending order, a copy queue is obtained: copy t1, copy t2, and copy t 3; wherein, the copy t1 satisfies: read-write pressure server _ rw _ qps (src) of the source storage server-read-write pressure tablet _ rw _ qps > of replica t 1-average read-write pressure avg _ rw _ qps; the copy t1 may be determined to be a copy to be migrated. Due to the fact that the descending sorting can guarantee that the reading and writing pressure of the copy t1 is not zero, and the copy to be migrated can be determined by judging once, the determining efficiency of the copy to be migrated can be improved. And the reading and writing pressure is not zero, so that the problem of invalid reading and writing pressure transfer caused by reading and writing pressure transfer of a copy with zero reading and writing pressure can be avoided.
In an optional implementation manner, the determining a migratable target storage server in the distributed table system may specifically include the following steps:
when a copy to be migrated exists in any storage server, judging whether the storage servers of other copies of the segment to which the copy to be migrated belongs meet a preset pressure transfer condition or not; wherein the preset pressure transfer conditions include: the sum of the read-write pressure of the storage server and the read-write pressure of the copy to be migrated is less than or equal to the average read-write pressure, and the storage server does not perform copy migration in the current copy migration stage;
if the preset pressure transfer condition is met, determining the storage server where other copies of the fragment to which the copy to be migrated belongs are located as a target storage server;
correspondingly, in an optional implementation manner, the migrating the copy to be migrated to the target storage server may specifically include the following steps:
exchanging the role of the master copy of the copy to be migrated with the role of the slave copy of the designated copy in the target storage server; and the designated copy is a copy which belongs to the same fragment as the copy to be migrated.
In a specific application, because reading and writing of the copy usually fall on the master copy, migrating the copy to be migrated to the target storage server may be to exchange a master copy role of the copy to be migrated with a slave copy role of the copy to be migrated in the target storage server, where the copy to be migrated and the copy to be migrated belong to the same segment. Therefore, the copy to be migrated is changed into the slave copy, and a certain copy of the fragment to which the copy to be migrated belongs is changed into the master copy, so that the adjustment of the reading and writing pressure is realized. On the basis, when a to-be-migrated copy exists in any storage server, whether the storage server where other copies of the segment to which the to-be-migrated copy belongs meet a preset pressure transfer condition or not can be judged, so that the storage server where the slave copy which can be converted into the master copy is located is determined.
Specifically, if the sum of the server read-write pressure of the storage server and the read-write pressure of the copy to be migrated is less than or equal to the average read-write pressure, it indicates that the read-write pressure of the storage server is not greater than the average read-write pressure to cause an excessive read-write pressure of the storage server when the storage server is shifted to the copy to be migrated. In addition, the storage server does not perform copy migration in the current copy migration stage, so that the storage server can only perform copy migration to be migrated once at most, controllability of the whole load balancing process can be ensured, and the whole distributed table system can be ensured to reach a load balancing state. Illustratively, for the storage server where the other copies of the segment T to which the copy R to be migrated belongs are located, if the storage server satisfies: the read-write pressure server _ rw _ qps of the storage server + the read-write pressure tablet _ rw _ qs of the copy to be migrated is equal to the average read-write pressure avg _ rw _ qps, and the storage server does not perform copy migration in the current copy migration stage, and may be determined as the target storage server Dst.
In addition, when judging whether the storage server meets the preset pressure transfer condition or not for the storage server where the other copies of the segment to which the copy to be migrated belongs are located, the judgment can be performed in the order from small to large according to the read-write pressure of the storage server where the other copies of the segment to which the copy to be migrated belongs, so that the determination efficiency of the target storage server is improved.
As shown in fig. 2, a flow of a method for load balancing according to another embodiment of the present invention may include the following steps:
s201, acquiring the reading and writing pressure of each copy in each storage server in the distributed table system.
The step S201 is the same as the step S101 in the embodiment of fig. 1 of the present invention, and is not repeated herein, for details, see the description of the embodiment of fig. 1 of the present invention.
S202, aiming at each storage server, calculating the sum of the reading and writing pressures of the copies in the storage server to obtain the reading and writing pressures of the storage server.
S203, calculating the average value of the obtained read-write pressures of the storage servers to obtain the average read-write pressure of the plurality of storage servers.
S204, for each storage server, if the difference value between the read-write pressure of the storage server and the average read-write pressure is larger than or equal to a preset read-write pressure threshold value, judging that the copy to be migrated exists in the storage server.
S205, taking the storage server with the copy to be migrated as a source storage server.
And S206, aiming at each copy of the source storage server, when the reading and writing pressure of the copy is not zero and the difference value between the reading and writing pressure of the source storage server and the reading and writing pressure of the copy is larger than or equal to the average reading and writing pressure, determining the copy as the copy to be migrated.
The above steps S202 to S206 are the same as the steps of determining the source storage server and the to-be-migrated copy in the optional embodiment of fig. 1 of the present invention, and are not described herein again, for details, see the description of the optional embodiment of fig. 1 of the present invention.
S207, when the copy to be migrated exists in any storage server, judging whether the storage servers where other copies of the fragment to which the copy to be migrated belongs are located meet a preset pressure transfer condition; if the storage server meets the preset pressure transfer condition, executing steps S208 to S209; if the storage servers of other copies of the segment to which the copy to be migrated belongs do not meet the preset pressure transfer condition, executing steps S210 to S212;
wherein the preset pressure transfer conditions include: the sum of the server read-write pressure of the storage server and the read-write pressure of the copy to be migrated is less than or equal to the average read-write pressure, and a pressure transfer task corresponding to the storage server is not created in the traversal for adjusting the read-write pressure.
S208, determining the storage server where the other copies of the segment to which the copy to be migrated belongs are located as the target storage server.
S209, the role of the master copy of the copy to be migrated is interchanged with the role of the slave copy of the designated copy in the target storage server.
And the designated copy is a copy which belongs to the same fragment as the copy to be migrated.
S210, aiming at the storage servers except the source storage server in the distributed table system, judging whether the storage servers meet preset copy transfer conditions.
The preset copy transfer conditions comprise: the storage server does not store the copy of the fragment to which the copy to be migrated belongs, the sum of the read-write pressure of the storage server and the read-write pressure of the copy to be migrated is less than or equal to the average read-write pressure, and the storage server does not perform copy migration in the current copy migration stage;
s211, if the storage server meets the preset copy transfer condition, determining the storage server as a target storage server.
S212, the copy to be migrated is migrated from the source storage server to the target storage server for storage.
In a specific application, since the read-write pressure of the storage server is derived from the copy stored in the storage server, the copy to be migrated can be transferred from the source storage server where the copy to be migrated is located to the target storage server for storage. Therefore, the read-write pressure born by the source storage server is transferred to the target storage server, and the adjustment of the read-write pressure is realized. For this purpose, it may be determined whether a storage server of the distributed table system, other than the source storage server, satisfies a preset copy transfer condition to determine a target storage server.
Moreover, in order to ensure the performance of the distributed table system, only one copy belonging to the same segment in the same storage server is available, and therefore, the preset copy transfer condition needs to include: the storage server does not store the copy of the segment to which the copy to be migrated belongs, which is equivalent to that the pressure transfer condition preset in step S207 is not satisfied. And if the sum of the server read-write pressure of the storage server and the read-write pressure of the copy to be migrated is less than or equal to the average read-write pressure, the read-write pressure of the storage server is not greater than the average read-write pressure so that the read-write pressure borne by the storage server is not too large when the storage server is shifted to the read-write pressure. In addition, the storage server does not perform copy migration in the current copy migration stage, and the storage server can be guaranteed to perform a pressure transfer task at most once, so that the controllability of the whole load balancing process is guaranteed, and the distributed table system can reach a load balancing state when traversal is completed. Illustratively, for a storage server of the distributed table system other than the source storage server, if the storage server satisfies: the read-write pressure server _ rw _ qps + the read-write pressure tablet _ rw _ qs of the copy to be migrated of the storage server is equal to the average read-write pressure avg _ rw _ qps, and in the created pressure transfer task, the storage server does not perform copy migration in the current copy migration stage, and the storage server may be determined as the target storage server Dst.
In addition, when judging whether the storage server meets the preset copy transfer condition or not for the storage servers of the distributed table system except the source storage server, the judgment can be performed in the order from small to large according to the read-write pressure of the storage servers of the distributed table system except the source storage server, so as to improve the determination efficiency of the target storage server.
Corresponding to the above method embodiment, an embodiment of the present invention further provides a load balancing apparatus.
As shown in fig. 3, a load balancing apparatus according to an embodiment of the present invention is applied to a distributed table system, where the distributed table system includes a metadata server and a plurality of storage servers for storing data, and the apparatus is included in the metadata server and includes:
a read-write pressure obtaining module 301, configured to obtain read-write pressure of each copy in each storage server in the distributed table system;
a server determining module 302, configured to determine a source storage server and a target storage server from the multiple storage servers based on read-write pressure of each copy in each storage server, where the source storage server includes a copy to be migrated;
a load balancing module 303, configured to migrate the copy to be migrated to the target storage server.
In the scheme provided by the invention, a metadata server of the distributed table system acquires the read-write pressure of each copy in each storage server in the distributed table system; determining a source storage server and a target storage server from a plurality of storage servers based on the read-write pressure of each copy in each storage server, wherein the source storage server comprises the copy to be migrated; and then the copy to be migrated is migrated to the target storage server. Therefore, by migrating the to-be-migrated copy to the target storage server, the read-write pressure of the source storage server can be transferred to the target storage server, so that the balance of the read-write pressure between the source storage server and the target storage server with the to-be-migrated copy in the whole distributed table system is realized. Therefore, the problems of overlarge read-write pressure and unbalanced load of the storage server caused by the fact that a plurality of master copies with relatively large read-write pressure are concentrated in the same storage server can be solved, and load balance of a distributed table system is achieved.
Optionally, the server determining module 302 includes:
the migration judgment submodule is used for judging whether the storage server has a copy to be migrated or not according to the obtained read-write pressure of each copy in the storage server aiming at any storage server;
and the target storage server determining submodule is used for taking the storage server with the copy to be migrated as a source storage server when the copy to be migrated exists in any storage server, and determining a migratable target storage server in the distributed table system.
Optionally, the migration judgment sub-module is specifically configured to:
calculating the sum of the read-write pressure of each copy in each storage server aiming at each storage server to obtain the read-write pressure of the storage server;
calculating the average value of the obtained read-write pressures of the storage servers to obtain the average read-write pressure of the plurality of storage servers;
and for each storage server, if the difference value 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 value, judging that the copy to be migrated exists in the storage server.
Optionally, the apparatus further comprises: a to-be-migrated copy determination module configured to:
after the target storage server determining submodule takes the storage server with the copy to be migrated 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, determining the copy as the copy to be migrated.
Optionally, the target storage server determining submodule is specifically configured to:
when the to-be-migrated copy exists in any storage server, judging whether the storage servers where other copies of the fragment to which the to-be-migrated copy belongs are in accordance with a preset pressure transfer condition; wherein the preset pressure transfer condition includes: the sum of the read-write pressure of the storage server and the read-write pressure of the copy to be migrated is less than or equal to the average read-write pressure, and the storage server does not perform copy migration in the current copy migration stage;
and if the preset pressure transfer condition is met, determining the storage server where other copies of the fragment to which the copy to be migrated belongs are located as the target storage server.
Optionally, the load balancing module 303 is specifically configured to:
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;
and the designated copy is a copy which belongs to the same fragment as the copy to be migrated.
Optionally, the target storage server determining submodule is specifically configured to:
after judging whether the storage servers where the other copies of the segment to which the copy to be migrated belongs meet the preset pressure transfer condition or not, if not, judging whether the storage servers meet the preset pressure transfer condition or not by aiming at the storage servers except the source storage server in the distributed table system;
if the preset copy transfer condition is met, determining the storage server as a target storage server; wherein the preset copy transfer conditions include: the storage server does not store the copy of the fragment to which the copy to be migrated belongs, the sum of the read-write pressure of the storage server and the read-write pressure of the copy to be migrated is less than or equal to the average read-write pressure, and the storage server does not perform copy migration in the current copy migration stage;
the load balancing module 303 is specifically configured to:
and migrating the copy to be migrated from the source storage server to the target storage server for storage.
Optionally, the read-write pressure obtaining module 301 is specifically configured to:
and periodically acquiring the reading and writing pressure of each copy in each storage server in the distributed table system.
As shown in fig. 4, a load balancing apparatus according to an embodiment of the present invention is applied to a distributed table system, where the distributed table system includes a metadata server and a plurality of storage servers for storing data, and the apparatus is included in the storage servers and includes:
a request information receiving module 401, configured to receive read request information and/or write request information of each copy;
a read-write pressure determining module 402, configured to determine the read-write pressure of each copy according to the received read request information and/or write request information of each copy.
In the scheme provided by the invention, a metadata server of the distributed table system acquires the read-write pressure of each copy in each storage server in the distributed table system; determining a source storage server and a target storage server from a plurality of storage servers based on the read-write pressure of each copy in each storage server, wherein the source storage server comprises the copy to be migrated; and then the copy to be migrated is migrated to the target storage server. Therefore, by migrating the to-be-migrated copy to the target storage server, the read-write pressure of the source storage server can be transferred to the target storage server, so that the balance of the read-write pressure between the source storage server and the target storage server with the to-be-migrated copy in the whole distributed table system is realized. Therefore, the problems of overlarge read-write pressure and unbalanced load of the storage server caused by the fact that a plurality of master copies with relatively large read-write pressure are concentrated in the same storage server can be solved, and load balance of a distributed table system is achieved.
Corresponding to the foregoing embodiment, an embodiment of the present invention further provides a server, and as shown in fig. 5, the server may include:
the system comprises a processor 501, a communication interface 502, a memory 503 and a communication bus 504, wherein the processor 501, the communication interface 502 and the memory 503 are communicated with each other through the communication bus 504;
a memory 503 for storing a computer program;
the processor 501 is configured to implement the steps of any load balancing method in the above embodiments when executing the computer program stored in the memory 503.
In a specific application, the server in the embodiment of fig. 5 of the present invention may be a metadata server in a distributed table system, or a storage server in a distributed table system.
In the scheme provided by the invention, a metadata server of the distributed table system acquires the read-write pressure of each copy in each storage server in the distributed table system; determining a source storage server and a target storage server from a plurality of storage servers based on the read-write pressure of each copy in each storage server, wherein the source storage server comprises the copy to be migrated; and then the copy to be migrated is migrated to the target storage server. Therefore, by migrating the to-be-migrated copy to the target storage server, the read-write pressure of the source storage server can be transferred to the target storage server, so that the balance of the read-write pressure between the source storage server and the target storage server with the to-be-migrated copy in the whole distributed table system is realized. Therefore, the problems of overlarge read-write pressure and unbalanced load of the storage server caused by the fact that a plurality of master copies with relatively large read-write pressure are concentrated in the same storage server can be solved, and load balance of a distributed table system is achieved.
The Memory may include a RAM (Random Access Memory) or an NVM (Non-Volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.
A computer-readable storage medium according to an embodiment of the present invention is included in a metadata server, and a computer program is stored in the computer-readable storage medium, and when being executed by a processor, the computer program implements the steps of any load balancing method in the foregoing embodiments.
In the scheme provided by the invention, a metadata server of the distributed table system acquires the read-write pressure of each copy in each storage server in the distributed table system; determining a source storage server and a target storage server from a plurality of storage servers based on the read-write pressure of each copy in each storage server, wherein the source storage server comprises the copy to be migrated; and then the copy to be migrated is migrated to the target storage server. Therefore, by migrating the to-be-migrated copy to the target storage server, the read-write pressure of the source storage server can be transferred to the target storage server, so that the balance of the read-write pressure between the source storage server and the target storage server with the to-be-migrated copy in the whole distributed table system is realized. Therefore, the problems of overlarge read-write pressure and unbalanced load of the storage server caused by the fact that a plurality of master copies with relatively large read-write pressure are concentrated in the same storage server can be solved, and load balance of a distributed table system is achieved.
In yet another embodiment, a computer program product containing instructions is provided, which when run on a computer, causes the computer to perform the method of load balancing as described in any of the above embodiments.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website, computer, server, or data center to another website, computer, server, or data center via wire (e.g., coaxial cable, fiber, DSL (Digital Subscriber Line), or wireless (e.g., infrared, radio, microwave, etc.), the computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device including one or more integrated servers, data centers, etc., the available medium may be magnetic medium (e.g., floppy disk, hard disk, tape), optical medium (e.g., DVD (Digital Versatile Disc, digital versatile disc)), or a semiconductor medium (e.g.: SSD (Solid State Disk)), etc.
In this document, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the device and server embodiments, since they are substantially similar to the method embodiments, the description is simple, and the relevant points can be referred to the partial description of the method embodiments.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.
Claims (15)
1. A method of load balancing, applied to a distributed table system including a metadata server and a plurality of storage servers for storing data, the method performed by the metadata server, comprising:
acquiring the read-write pressure of each copy in each storage server in the distributed table system;
determining a source storage server and a target storage server from the plurality of storage servers based on the read-write pressure of each copy in each storage server, wherein the source storage server comprises a copy to be migrated;
and migrating the copy to be migrated to the target storage server.
2. The method of claim 1, wherein determining a source storage server and a target storage server from the plurality of storage servers based on the read-write pressure of the respective copy in each storage server comprises:
for any storage server, judging whether the storage server has a copy to be migrated or not based on the obtained read-write pressure of each copy in the storage server;
and when the copy to be migrated exists in any storage server, taking the storage server with the copy to be migrated as a source storage server, and determining a migratable target storage server in the distributed table system.
3. The method according to claim 2, wherein the determining, for any storage server, whether there is a copy to be migrated in the storage server based on the obtained read-write pressure of each copy in the storage server includes:
calculating the sum of the read-write pressure of each copy in each storage server aiming at each storage server to obtain the read-write pressure of the storage server;
calculating the average value of the obtained read-write pressures of the storage servers to obtain the average read-write pressure of the plurality of storage servers;
and for each storage server, if the difference value 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 value, judging that the copy to be migrated exists in the storage server.
4. The method according to claim 3, wherein after the storage server having the copy to be migrated exists as an origin storage server, the method further comprises:
and 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, determining the copy as a copy to be migrated.
5. The method of claim 4, wherein determining migratable target storage servers in the distributed table system comprises:
judging whether the storage servers where other copies of the fragments to which the copies to be migrated belong are located meet preset pressure transfer conditions or not; wherein the preset pressure transfer condition includes: the sum of the read-write pressure of the storage server and the read-write pressure of the copy to be migrated is less than or equal to the average read-write pressure, and the storage server does not perform copy migration in the current copy migration stage;
and if the preset pressure transfer condition is met, determining the storage server where other copies of the fragment to which the copy to be migrated belongs are located as the target storage server.
6. The method of claim 5, wherein the migrating the copy to be migrated to the target storage server comprises:
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;
and the designated copy is a copy which belongs to the same fragment as the copy to be migrated.
7. The method according to claim 5, wherein after the determining whether the storage server where the other copy of the segment to which the copy to be migrated belongs is located meets a preset pressure transfer condition, the method further comprises:
if the storage servers of other copies of the segment to which the copy to be migrated belongs do not meet the preset pressure transfer condition, judging whether the storage server meets the preset copy transfer condition or not aiming at the storage servers except the source storage server in the distributed table system;
if the preset copy transfer condition is met, determining the storage server as a target storage server; wherein the preset copy transfer conditions include: the storage server does not store the copy of the fragment to which the copy to be migrated belongs, the sum of the read-write pressure of the storage server and the read-write pressure of the copy to be migrated is less than or equal to the average read-write pressure, and the storage server does not perform copy migration in the current copy migration stage;
the migrating the copy to be migrated to the target storage server includes:
and migrating the copy to be migrated from the source storage server to the target storage server for storage.
8. The method according to any one of claims 1 to 7, wherein the obtaining of the read-write pressure of each copy in each storage server in the distributed table system comprises:
and periodically acquiring the reading and writing pressure of each copy in each storage server in the distributed table system.
9. A method of load balancing, applied to a distributed table system including a metadata server and a plurality of storage servers for storing data, the method performed by the storage servers, comprising:
receiving reading request information and/or writing request information of each copy;
and determining the read-write pressure of each copy according to the received read request information and/or write request information of each copy.
10. An apparatus for load balancing, applied to a distributed table system including a metadata server and a plurality of storage servers for storing data, the apparatus being included in the metadata server and comprising:
the reading and writing pressure acquisition module is used for acquiring the reading and writing pressure of each copy in each storage server in the distributed table system;
a server determining module, configured to determine a source storage server and a target storage server from the multiple storage servers based on read-write pressure of each copy in each storage server, where the source storage server includes a copy to be migrated;
and the load balancing module is used for migrating the copy to be migrated to the target storage server.
11. The apparatus of claim 10, wherein the server determination module comprises:
the migration judgment submodule is used for judging whether the storage server has a copy to be migrated or not according to the obtained read-write pressure of each copy in the storage server aiming at any storage server;
and the target storage server determining submodule is used for taking the storage server with the copy to be migrated as a source storage server when the copy to be migrated exists in any storage server, and determining a migratable target storage server in the distributed table system.
12. The apparatus according to claim 11, wherein the migration determination submodule is specifically configured to:
calculating the sum of the read-write pressure of each copy in each storage server aiming at each storage server to obtain the read-write pressure of the storage server;
calculating the average value of the obtained read-write pressures of the storage servers to obtain the average read-write pressure of the plurality of storage servers;
and for each storage server, if the difference value 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 value, judging that the copy to be migrated exists in the storage server.
13. An apparatus for load balancing, applied to a distributed table system including a metadata server and a plurality of storage servers for storing data, the apparatus being included in the storage servers and comprising:
the request information receiving module is used for receiving the reading request information and/or the writing request information of each copy;
and the read-write pressure determining module is used for determining the read-write pressure of each copy according to the received read request information and/or write request information of each copy.
14. A server is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing the communication between the processor and the memory through the bus; a memory for storing a computer program; a processor for executing a program stored in the memory to perform the method steps of any of claims 1-9.
15. A computer-readable storage medium, characterized in that a computer program is stored in the storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of the claims 1-9.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010620901.6A CN113867928A (en) | 2020-06-30 | 2020-06-30 | Load balancing method and device and server |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010620901.6A CN113867928A (en) | 2020-06-30 | 2020-06-30 | Load balancing method and device and server |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113867928A true CN113867928A (en) | 2021-12-31 |
Family
ID=78981887
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010620901.6A Pending CN113867928A (en) | 2020-06-30 | 2020-06-30 | Load balancing method and device and server |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113867928A (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070011485A1 (en) * | 2004-12-17 | 2007-01-11 | Cassatt Corporation | Application-based specialization for computing nodes within a distributed processing system |
CN104580427A (en) * | 2014-12-27 | 2015-04-29 | 北京奇虎科技有限公司 | Master-slave balance method and device in distributed memory system |
CN110007866A (en) * | 2019-04-11 | 2019-07-12 | 苏州浪潮智能科技有限公司 | A kind of storage unit performance optimization method, device, storage equipment and storage medium |
CN110321225A (en) * | 2019-07-08 | 2019-10-11 | 腾讯科技(深圳)有限公司 | Load-balancing method, meta data server and computer readable storage medium |
-
2020
- 2020-06-30 CN CN202010620901.6A patent/CN113867928A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070011485A1 (en) * | 2004-12-17 | 2007-01-11 | Cassatt Corporation | Application-based specialization for computing nodes within a distributed processing system |
CN104580427A (en) * | 2014-12-27 | 2015-04-29 | 北京奇虎科技有限公司 | Master-slave balance method and device in distributed memory system |
CN110007866A (en) * | 2019-04-11 | 2019-07-12 | 苏州浪潮智能科技有限公司 | A kind of storage unit performance optimization method, device, storage equipment and storage medium |
CN110321225A (en) * | 2019-07-08 | 2019-10-11 | 腾讯科技(深圳)有限公司 | Load-balancing method, meta data server and computer readable storage medium |
Non-Patent Citations (1)
Title |
---|
HEDGEHOG1112: "(五)分布式存储***概要", pages 1 - 4, Retrieved from the Internet <URL:https://www.jianshu.com/p/cfb33ccd0b77> * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10412170B2 (en) | Retention-based data management in a network-based data store | |
CN109947668B (en) | Method and device for storing data | |
US10715460B2 (en) | Opportunistic resource migration to optimize resource placement | |
US8504556B1 (en) | System and method for diminishing workload imbalance across multiple database systems | |
EP3467652A1 (en) | Data balancing method and device | |
US8661055B2 (en) | File server system and storage control method | |
US10235047B2 (en) | Memory management method, apparatus, and system | |
CN111475483B (en) | Database migration method and device and computing equipment | |
KR20150111952A (en) | Method and system for using a recursive event listener on a node in hierarchical data structure | |
US20160036909A1 (en) | Adaptive asynchronous data replication in a data storage system | |
WO2017201984A1 (en) | Data processing method, associated apparatus, and data storage system | |
TWI705368B (en) | Block chain data compression processing method and device, computer equipment and computer readable storage medium | |
CN111143113B (en) | Method, electronic device and computer program product for copying metadata | |
US20230030856A1 (en) | Distributed table storage processing method, device and system | |
CN112328592A (en) | Data storage method, electronic device and computer readable storage medium | |
CN101483668A (en) | Network storage and access method, device and system for hot spot data | |
CN112073395B (en) | File distribution method and device | |
CN107797758B (en) | Date storage method, data access method and device | |
CN113407108A (en) | Data storage method and system | |
CN111444148A (en) | Data transmission method and device based on MapReduce | |
CN113867928A (en) | Load balancing method and device and server | |
Zhang et al. | Key based data analytics across data centers considering bi-level resource provision in cloud computing | |
CN114647701A (en) | Load balancing method and device for distributed database, electronic equipment and medium | |
CN113849482A (en) | Data migration method and device and electronic equipment | |
US11157322B2 (en) | Hyper-converged infrastructure (HCI) ephemeral workload/data provisioning system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |