CN109376013B - Load balancing method and device - Google Patents

Load balancing method and device Download PDF

Info

Publication number
CN109376013B
CN109376013B CN201811181753.1A CN201811181753A CN109376013B CN 109376013 B CN109376013 B CN 109376013B CN 201811181753 A CN201811181753 A CN 201811181753A CN 109376013 B CN109376013 B CN 109376013B
Authority
CN
China
Prior art keywords
data server
data
current
distribution
disk usage
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.)
Active
Application number
CN201811181753.1A
Other languages
Chinese (zh)
Other versions
CN109376013A (en
Inventor
周应超
张森
田竞云
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Xiaomi Intelligent Technology Co Ltd
Original Assignee
Beijing Xiaomi Intelligent Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Xiaomi Intelligent Technology Co Ltd filed Critical Beijing Xiaomi Intelligent Technology Co Ltd
Priority to CN201811181753.1A priority Critical patent/CN109376013B/en
Publication of CN109376013A publication Critical patent/CN109376013A/en
Application granted granted Critical
Publication of CN109376013B publication Critical patent/CN109376013B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5083Techniques for rebalancing the load in a distributed system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load

Abstract

The present disclosure relates to a load balancing method and device, the method comprising: acquiring the current disk usage of each data server node in the distributed file system every other preset time; the method comprises the steps of obtaining the distribution state of current data at each data server node according to the current disk usage of each data server node, wherein the distribution state indicates that the current data distribution is balanced or indicates that the current data distribution is unbalanced, the current data are stored in each data server node, and when the distribution state indicates that the current data distribution is unbalanced, an equalizer of the distributed file system is called to execute load balancing operation. The method and the device can realize periodic load balancing, avoid the problems caused by manual operation, reduce the manual management cost and automatically operate again when the operation of the equalizer fails.

Description

Load balancing method and device
Technical Field
The present disclosure relates to the field of distributed technologies, and in particular, to a load balancing method and apparatus.
Background
With the continuous development of internet technology, the appearance of a distributed file system effectively solves the difficult problems of data storage and management. A distributed file system generally consists of a metadata server that stores metadata for the distributed file system and a data server that stores actual user data for the distributed file system. In a distributed file system, a user may add/delete data server nodes dynamically according to the increase or decrease of the data volume, so that the total number of data servers may change, and at the same time, the data server nodes may be dynamically offline or online due to the damage of a node disk and other situations during the use process, and these situations may cause imbalance in data distribution and access volume among the data server nodes, that is, imbalance in data server node load, and affect the access performance of a service.
In the related art, load balancing is generally achieved through an equalizer provided in a distributed file system, and specifically, data is moved among different data server nodes by the equalizer, so as to achieve the purpose of balancing space consumption on the data server nodes. The equalizer is typically manually initiated by a system administrator and ends when load balancing is achieved.
However, the data server nodes may be in an unbalanced state for a long time due to an emergency condition caused by manual operation, such as the system administrator forgets to start the data server nodes or a temporary network failure occurs during the operation of the equalizer.
Disclosure of Invention
To overcome the problems in the related art, the present disclosure provides a load balancing method and apparatus. The technical scheme is as follows:
according to a first aspect of the embodiments of the present disclosure, there is provided a load balancing method, including:
acquiring the current disk usage of each data server node in the distributed file system every other preset time;
acquiring the distribution state of current data at each data server node according to the current disk usage of each data server node, wherein the distribution state indicates that the current data is distributed evenly or indicates that the current data is distributed unevenly, and the current data is data stored in each data server node;
and when the distribution state indicates that the current data distribution is unbalanced, calling an equalizer of the distributed file system to execute load balancing operation.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects: the method comprises the steps of obtaining the current disk usage of each data server node in the distributed file system at preset intervals, obtaining the distribution state of current data at each data server node according to the current disk usage of each data server node, and calling an equalizer of the distributed file system to execute load balancing operation when the distribution state indicates that the current data is unevenly distributed, so that the load balancing can be periodically performed, the problems caused by manual operation are avoided, the manual management cost is reduced, and the method can automatically operate again when the equalizer fails to operate.
Further, the method further comprises:
and when the distribution state indicates that the current data distribution is balanced, sleeping in the preset time.
Further, the determining whether the current data distribution is balanced according to the current disk usage of each data server node includes:
calculating the variance of the current disk usage of all data server nodes, wherein the variance is the distribution state;
when the variance is larger than a first preset threshold value, the current data distribution is unbalanced, and when the variance is smaller than the first preset threshold value, the current data distribution is balanced.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects: the method comprises the steps of obtaining the current disk usage of each data server node in the distributed file system at preset time intervals, using the variance of the current disk usage of all the data server nodes as a distribution state, calling an equalizer of the distributed file system to execute load balancing operation when the current data distribution is determined to be unbalanced according to the variance and a first preset threshold value, so that the load balancing can be periodically performed, the problems caused by manual operation are avoided, the manual management cost is reduced, and the method can automatically operate again when the equalizer fails to operate.
Further, the determining whether the current data distribution is balanced according to the current disk usage of each data server node includes:
calculating the average value of the current disk usage of all the data server nodes;
calculating a difference value between the current disk usage of each data server node and the average value, and calculating the total disk usage X of the N data server nodes with the largest difference value and the total disk usage Y of the M data server nodes with the smallest difference value, wherein N and M are preset positive integers;
the difference between X and Y is the distribution state, when the difference between X and Y is larger than a second preset threshold, the current data distribution is unbalanced, and when the difference between X and Y is smaller than the second preset threshold, the current data distribution is balanced.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects: the method comprises the steps of obtaining the current disk usage of each data server node in the distributed file system at intervals of preset time, calculating the difference value between the current disk usage of each data server node and the average value of the current disk usage of all the data server nodes, calculating the total disk usage X of N data server nodes with the largest difference value and the total disk usage Y of M data server nodes with the smallest difference value, taking the difference value between X and Y as a distribution state, calling an equalizer of the distributed file system to execute load balancing operation when the current data distribution is determined to be unbalanced according to the difference value between X and Y and a second preset threshold value, and accordingly achieving periodic load balancing, avoiding problems caused by manual operation, reducing manual management cost and being capable of automatically running again when the equalizer fails to run.
Further, the method further comprises:
calculating the average value of the current disk usage of all the data server nodes;
calculating the difference between the current disk usage of each data server node and the average value, and selecting P data server nodes with the largest difference and Q data server nodes with the smallest difference, wherein P and Q are preset positive integers;
the invoking the balancer of the distributed file system to execute load balancing operation comprises:
and calling the equalizer to move data between the P data server nodes and the Q data server nodes.
According to a second aspect of the embodiments of the present disclosure, there is provided a load balancing apparatus, including:
the first acquisition module is configured to acquire the current disk usage of each data server node in the distributed file system at preset time intervals;
the second obtaining module is configured to obtain a distribution state of current data at each data server node according to a current disk usage of each data server node, wherein the distribution state indicates that the current data is distributed evenly or indicates that the current data is distributed unevenly, and the current data is data stored in each data server node;
a first processing module configured to invoke an equalizer of the distributed file system to perform a load balancing operation when the distribution status indicates that the current data distribution is unbalanced.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects: the method comprises the steps that the current disk usage of each data server node in the distributed file system is obtained once every preset time through a first obtaining module, the distribution state of current data at each data server node is obtained through a second obtaining module according to the current disk usage of each data server node, and when the distribution state indicates that the current data distribution is unbalanced, a balancer of the distributed file system is called to execute load balancing operation through a first processing module, so that the load balancing can be periodically performed, the problems caused by manual operation are avoided, the manual management cost is reduced, and the balancer can automatically operate again when the balancer fails to operate.
Further, the apparatus further comprises:
a second processing module configured to sleep for the preset time when the distribution status indicates that the current data distribution is balanced.
Further, the second obtaining module is specifically configured to:
calculating the variance of the current disk usage of all data server nodes, wherein the variance is the distribution state;
when the variance is larger than a first preset threshold value, the current data distribution is unbalanced, and when the variance is smaller than the first preset threshold value, the current data distribution is balanced.
Further, the second obtaining module is specifically configured to:
calculating the average value of the current disk usage of all the data server nodes;
calculating a difference value between the current disk usage of each data server node and the average value, and calculating the total disk usage X of the N data server nodes with the largest difference value and the total disk usage Y of the M data server nodes with the smallest difference value, wherein N and M are preset positive integers;
the difference between X and Y is the distribution state, when the difference between X and Y is larger than a second preset threshold, the current data distribution is unbalanced, and when the difference between X and Y is smaller than the second preset threshold, the current data distribution is balanced.
Further, the apparatus further comprises:
the computing module is configured to compute the average value of the current disk usage of all the data server nodes;
calculating the difference between the current disk usage of each data server node and the average value, and selecting P data server nodes with the largest difference and Q data server nodes with the smallest difference, wherein P and Q are preset positive integers;
the first processing module is specifically configured to:
and calling the equalizer to move data between the P data server nodes and the Q data server nodes.
According to a third aspect of the embodiments of the present disclosure, there is provided a load balancing apparatus, including:
a processor;
a memory for storing executable instructions of the processor;
wherein the processor is configured to:
acquiring the current disk usage of each data server node in the distributed file system every other preset time;
acquiring the distribution state of current data at each data server node according to the current disk usage of each data server node, wherein the distribution state indicates that the current data is distributed evenly or indicates that the current data is distributed unevenly, and the current data is data stored in each data server node;
and when the distribution state indicates that the current data distribution is unbalanced, calling an equalizer of the distributed file system to execute load balancing operation.
According to a fourth aspect of embodiments of the present disclosure, there is provided a readable storage medium having a computer program stored therein, wherein when the computer program is executed by at least one processor of a load balancing apparatus, the load balancing apparatus performs the method of the first aspect.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.
Fig. 1 is a flow diagram illustrating a method of load balancing according to an example embodiment.
Fig. 2 is a flow diagram illustrating a method of load balancing according to an example embodiment.
Fig. 3 is a flow diagram illustrating a method of load balancing according to an example embodiment.
Fig. 4 is a block diagram illustrating a load balancing apparatus in accordance with an example embodiment.
Fig. 5 is a block diagram illustrating a load balancing apparatus in accordance with an example embodiment.
Fig. 6 is a block diagram illustrating a load balancing apparatus in accordance with an example embodiment.
Fig. 7 is a block diagram illustrating a load balancing apparatus in accordance with an example embodiment.
With the foregoing drawings in mind, certain embodiments of the disclosure have been shown and described in more detail below. These drawings and written description are not intended to limit the scope of the disclosed concepts in any way, but rather to illustrate the concepts of the disclosure to those skilled in the art by reference to specific embodiments.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
Fig. 1 is a flowchart illustrating a load balancing method according to an exemplary embodiment, which is illustrated in the embodiment by applying the load balancing method to a distributed file system. The load balancing method may include the following steps.
In step S11, the current disk usage of each data server node in the distributed file system is obtained every preset time.
Specifically, in this embodiment, load balancing is performed periodically, the preset time is, for example, 1 minute or 2 minutes, and the preset time may specifically be determined according to an actual time experiment for load balancing adjustment required by the distributed file system.
In step S12, a distribution status of the current data at each data server node is obtained according to the current disk usage of each data server node, where the distribution status indicates that the current data distribution is balanced or indicates that the current data distribution is unbalanced, and the current data is the data stored at each data server node.
Specifically, how to obtain the distribution state of the current data at each data server node, there are two implementable manners in this embodiment, and as an implementable manner, S12 may be:
and S121, calculating the variance of the current disk usage of all the data server nodes, wherein the variance is in a distribution state.
The variance S may be specifically calculated by the following formula:
Figure BDA0001825167230000061
wherein the content of the first and second substances,
Figure BDA0001825167230000062
wherein x is1、x2……xnCurrent disk usage for each data server node.
And S122, when the variance is larger than a first preset threshold value, the current data distribution is unbalanced, and when the variance is smaller than the first preset threshold value, the current data distribution is balanced.
As another practicable manner, S12 may be:
s121', calculating the average value of the current disk usage of all data server nodes.
In particular, the amount of the solvent to be used,
Figure BDA0001825167230000063
s122', calculating the difference between the current disk usage of each data server node and the average value, and calculating the total disk usage X of the N data server nodes with the largest difference and the total disk usage Y of the M data server nodes with the smallest difference, wherein N and M are preset positive integers.
Specifically, the current disk usage and the average value of each data server node are calculated
Figure BDA0001825167230000064
After the difference between the data server nodes, all the data server nodes may be sorted in an order from the largest difference to the smallest difference or in an order from the smallest difference to the largest difference, and the N data server nodes with the largest difference and the M data server nodes with the smallest difference are selected according to the sorting result, where N and M are preset positive integers, and N and M are, for example, 1% of the total data server nodes. And then calculating the total disk usage X of the N data server nodes and the total disk usage Y of the M data server nodes.
S123', the difference values between X and Y are in a distribution state, when the difference value between X and Y is larger than a second preset threshold value, the current data distribution is unbalanced, and when the difference value between X and Y is smaller than the second preset threshold value, the current data distribution is balanced.
Specifically, the second preset threshold is, for example, a decimal multiple of the sum of the disk spaces of all the data server nodes, for example, the sum of the disk spaces of all the data server nodes is Q, and the second preset threshold is 0.4Q or 0.5Q, and the like.
In step S13, when the distribution status indicates that the current data distribution is unbalanced, a balancer of the distributed file system is called to perform a load balancing operation.
Specifically, when the current data distribution is unbalanced, the balancer of the distributed file system is called to perform load balancing operation, the balancer can be directly started to autonomously perform load balancing operation, or the balancer can be started to instruct the balancer to move data among data server nodes.
Optionally, before invoking the balancer of the distributed file system to perform the load balancing operation, the method of this embodiment may further include:
and S14, calculating the average value of the current disk usage of all the data server nodes.
S15, calculating the difference between the current disk usage of each data server node and the average value, and selecting P data server nodes with the largest difference and Q data server nodes with the smallest difference, wherein P and Q are preset positive integers.
At this time, S13 may be: and calling an equalizer to move data between the P data server nodes and the Q data server nodes.
Specifically, the current disk usage and the average value of each data server node may be calculated
Figure BDA0001825167230000071
After the difference value, all the data server nodes can be sorted according to the sequence of the difference value from large to small or from small to large, and the P data server nodes with the largest difference value and the Q data server nodes with the smallest difference value are selected according to the sorting result. And then instructing the equalizer to move the data between the P data server nodes and the Q data server nodes.
It should be noted that, if the current data distribution determined according to the variance of the current disk usage of all the data server nodes and the first preset threshold is balanced in S12, P data server nodes and Q data server nodes need to be obtained through S14 and S15, and if the current data distribution determined in the another manner is balanced in S12, P data server nodes and Q data server nodes do not need to be obtained through S14 and S15, in this manner, results obtained by sorting all the data server nodes in the order of the difference values from large to small or in the order of small to large are obtained, so that P data server nodes and Q data server nodes can be directly selected.
Optionally, the method of this embodiment may further include:
and when the distribution state indicates that the current data distribution is unbalanced, sleeping within a preset time.
In this embodiment, load balancing is periodically performed on the distributed file system, when the distribution status indicates that the current data distribution is unbalanced, the balancer is called to perform load balancing operations, and after a preset time, the above-mentioned S11-S13 are performed again, and when the distribution status indicates that the current data distribution is balanced, and after a preset time of hibernation, the above-mentioned S11-S13 are performed again. Thereby periodically load balancing the distributed file system.
In summary, according to the load balancing method provided in this embodiment, the current disk usage of each data server node in the distributed file system is obtained once every preset time, the distribution state of the current data at each data server node is obtained according to the current disk usage of each data server node, and when the distribution state indicates that the current data distribution is unbalanced, the balancer of the distributed file system is called to perform the load balancing operation, so that the load balancing can be performed periodically, the problem caused by manual operation is avoided, the manual management cost is reduced, and the balancer can be automatically re-operated when the balancer fails to operate.
Fig. 2 is a flowchart illustrating a load balancing method according to an exemplary embodiment, which is illustrated in the embodiment by applying the load balancing method to a distributed file system. The load balancing method may include the following steps.
In step S21, the current disk usage of each data server node in the distributed file system is obtained.
In step S22, the variance of the current disk usage of all data server nodes is calculated, and the variance is the distribution state of the current data at each data server node.
In step S23, it is determined whether the variance is greater than a first preset threshold.
If yes, executing S24 if the current data distribution is not balanced; if not, the current data distribution is balanced, and S25 is executed.
In step S24, a balancer of the distributed file system is invoked to perform a load balancing operation.
Specifically, the balancer can be directly started to autonomously perform the load balancing operation, or the balancer can be started to instruct the balancer to move data among data server nodes. The method specifically comprises the following steps:
and S241, calculating the average value of the current disk usage of all the data server nodes.
And S242, calculating a difference value between the current disk usage of each data server node and the average value, and selecting P data server nodes with the largest difference value and Q data server nodes with the smallest difference value, wherein P and Q are preset positive integers.
And S243, calling an equalizer to move data between the P data server nodes and the Q data server nodes.
In step S25, sleep for a preset time. I.e. waiting for a preset time.
After S24, execution returns to S21 after a preset time, and S21 returns to S25.
In summary, according to the load balancing method provided in this embodiment, the current disk usage of each data server node in the distributed file system is obtained at preset time intervals, the variance of the current disk usage of all data server nodes is used as a distribution state, and when the current data distribution is determined to be unbalanced according to the variance and a first preset threshold, the balancer of the distributed file system is called to perform load balancing operation, so that load balancing can be performed periodically, problems caused by manual operation are avoided, manual management cost is reduced, and the balancer can be automatically re-operated when the balancer fails to operate.
Fig. 3 is a flowchart illustrating a load balancing method according to an exemplary embodiment, which is illustrated in the embodiment by applying the load balancing method to a distributed file system. The load balancing method may include the following steps.
In step S31, the current disk usage of each data server node in the distributed file system is obtained.
In step S32, the average of the current disk usage of all data server nodes is calculated.
In step S33, a difference between the current disk usage of each data server node and the average value is calculated, and a total disk usage X of the N data server nodes with the largest difference and a total disk usage Y of the M data server nodes with the smallest difference are calculated, where N and M are preset positive integers.
In step S34, the difference between X and Y is the distribution status of the current data at each data server node, and it is determined whether the difference between X and Y is greater than a second preset threshold.
If yes, executing S35 if the current data distribution is not balanced; if not, the current data distribution is balanced, and S36 is executed.
In step S35, a balancer of the distributed file system is invoked to perform a load balancing operation.
Specifically, the balancer can be directly started to autonomously perform the load balancing operation, or the balancer can be started to instruct the balancer to move data among data server nodes. Specifically, according to the result obtained in S33, which is obtained by sorting all the data server nodes in the order from the largest difference to the smallest difference or in the order from the smallest difference, the P data server nodes with the largest difference and the Q data server nodes with the smallest difference are directly selected, where P and Q are preset positive integers. And then calling an equalizer to move data between the P data server nodes and the Q data server nodes.
In step S36, sleep for a preset time.
After S35, execution returns to S31 after a preset time, and S31 returns to S36.
In summary, the load balancing method provided in this embodiment obtains the current disk usage of each data server node in the distributed file system every preset time, calculates the difference between the current disk usage of each data server node and the average of the current disk usage of all data server nodes, and calculating the total disk usage X of the N data server nodes with the largest difference and the total disk usage Y of the M data server nodes with the smallest difference, taking the difference between X and Y as a distribution state, when the current data distribution is determined to be unbalanced according to the difference value between X and Y and a second preset threshold value, an equalizer of the distributed file system is called to execute load balancing operation, therefore, the load balancing can be periodically carried out, the problems caused by manual operation are avoided, the manual management cost is reduced, and the automatic rerun can be carried out when the operation of the equalizer fails.
The following are embodiments of the disclosed apparatus that may be used to perform embodiments of the disclosed methods. For details not disclosed in the embodiments of the apparatus of the present disclosure, refer to the embodiments of the method of the present disclosure.
Fig. 4 is a block diagram illustrating a load balancing apparatus in accordance with an example embodiment. The load balancing means may be implemented by software, hardware or a combination of both. Referring to fig. 4, the apparatus includes: a first acquisition module 11, a second acquisition module 12 and a first processing module 13, wherein,
the first obtaining module 11 is configured to obtain the current disk usage of each data server node in the distributed file system once every preset time.
The second obtaining module 12 is configured to obtain, according to the current disk usage of each data server node, a distribution state of current data at each data server node, where the distribution state indicates that the current data is distributed evenly or indicates that the current data is distributed unevenly, and the current data is data stored in each data server node.
The first processing module 13 is configured to invoke an equalizer of the distributed file system to perform a load balancing operation when the distribution status indicates that the current data distribution is unbalanced.
In summary, in the load balancing apparatus provided in this embodiment, the first obtaining module obtains the current disk usage of each data server node in the distributed file system at every preset time, the second obtaining module obtains the distribution state of the current data at each data server node according to the current disk usage of each data server node, and the first processing module calls the balancer of the distributed file system to perform the load balancing operation when the distribution state indicates that the current data distribution is unbalanced, so that load balancing can be performed periodically, problems caused by manual operations are avoided, manual management cost is reduced, and the balancer can be automatically re-operated when the balancer fails to operate.
Fig. 5 is a block diagram illustrating a load balancing apparatus in accordance with an example embodiment. As shown in fig. 5, the apparatus of this embodiment may further include, on the basis of the apparatus shown in fig. 4: a second processing module 14, where the second processing module 14 is configured to sleep for the preset time when the distribution status indicates that the current data distribution is balanced.
Optionally, the second obtaining module 12 is specifically configured to:
calculating the variance of the current disk usage of all data server nodes, wherein the variance is the distribution state;
when the variance is larger than a first preset threshold value, the current data distribution is unbalanced, and when the variance is smaller than the first preset threshold value, the current data distribution is balanced.
Optionally, the second obtaining module 12 is specifically configured to:
calculating the average value of the current disk usage of all the data server nodes;
calculating a difference value between the current disk usage of each data server node and the average value, and calculating the total disk usage X of the N data server nodes with the largest difference value and the total disk usage Y of the M data server nodes with the smallest difference value, wherein N and M are preset positive integers;
the difference between X and Y is the distribution state, when the difference between X and Y is larger than a second preset threshold, the current data distribution is unbalanced, and when the difference between X and Y is smaller than the second preset threshold, the current data distribution is balanced.
Fig. 6 is a block diagram illustrating a load balancing apparatus in accordance with an example embodiment. As shown in fig. 6, the apparatus of this embodiment may further include, on the basis of the apparatus shown in fig. 4 or fig. 5:
a calculation module 15 configured to calculate an average value of current disk usage of all data server nodes;
calculating the difference between the current disk usage of each data server node and the average value, and selecting P data server nodes with the largest difference and Q data server nodes with the smallest difference, wherein P and Q are preset positive integers;
the first processing module 13 is specifically configured to:
and calling the equalizer to move data between the P data server nodes and the Q data server nodes.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Fig. 7 is a block diagram illustrating a load balancing apparatus in accordance with an example embodiment. For example, the load balancing apparatus 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to fig. 7, the load balancing apparatus 800 may include one or more of the following components: a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input/output (I/O) interface 812, a sensor component 814, and a communication component 816.
The processing component 802 generally controls the overall operation of the load balancing apparatus 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing components 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operations at the apparatus 800. Examples of such data include instructions for any application or method operating on device 800, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
Power components 806 provide power to the various components of device 800. The power components 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the apparatus 800.
The multimedia component 808 includes a screen that provides an output interface between the device 800 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the device 800 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the apparatus 800 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 814 includes one or more sensors for providing various aspects of state assessment for the device 800. For example, the sensor assembly 814 may detect the open/closed status of the device 800, the relative positioning of components, such as a display and keypad of the device 800, the sensor assembly 814 may also detect a change in the position of the device 800 or a component of the device 800, the presence or absence of user contact with the device 800, the orientation or acceleration/deceleration of the device 800, and a change in the temperature of the device 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate communications between the apparatus 800 and other devices in a wired or wireless manner. The device 800 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 804 comprising instructions, executable by the processor 820 of the device 800 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 804 comprising instructions, executable by the processor 820 of the load balancing apparatus 800 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (8)

1. A method of load balancing, comprising:
acquiring the current disk usage of each data server node in the distributed file system every other preset time;
acquiring the distribution state of current data at each data server node according to the current disk usage of each data server node, wherein the distribution state indicates that the current data is distributed evenly or indicates that the current data is distributed unevenly, and the current data is data stored in each data server node;
when the distribution state indicates that the current data distribution is unbalanced, calling an equalizer of the distributed file system to execute load balancing operation;
when the distribution state indicates that the current data distribution is balanced, sleeping within the preset time;
the method further comprises the following steps:
calculating the average value of the current disk usage of all the data server nodes;
calculating the difference between the current disk usage of each data server node and the average value, and selecting P data server nodes with the largest difference and Q data server nodes with the smallest difference, wherein P and Q are preset positive integers;
the invoking the balancer of the distributed file system to execute load balancing operation comprises:
and calling the equalizer to move data between the P data server nodes and the Q data server nodes.
2. The method according to claim 1, wherein the obtaining the distribution status of the current data at each data server node according to the current disk usage of each data server node comprises:
calculating the variance of the current disk usage of all data server nodes, wherein the variance is the distribution state;
when the variance is larger than a first preset threshold value, the current data distribution is unbalanced, and when the variance is smaller than the first preset threshold value, the current data distribution is balanced.
3. The method according to claim 1, wherein the obtaining the distribution status of the current data at each data server node according to the current disk usage of each data server node comprises:
calculating the average value of the current disk usage of all the data server nodes;
calculating a difference value between the current disk usage of each data server node and the average value, and calculating the total disk usage X of the N data server nodes with the largest difference value and the total disk usage Y of the M data server nodes with the smallest difference value, wherein N and M are preset positive integers;
the difference between X and Y is the distribution state, when the difference between X and Y is larger than a second preset threshold, the current data distribution is unbalanced, and when the difference between X and Y is smaller than the second preset threshold, the current data distribution is balanced.
4. A load balancing apparatus, comprising:
the first acquisition module is configured to acquire the current disk usage of each data server node in the distributed file system at preset time intervals;
the second obtaining module is configured to obtain a distribution state of current data at each data server node according to a current disk usage of each data server node, wherein the distribution state indicates that the current data is distributed evenly or indicates that the current data is distributed unevenly, and the current data is data stored in each data server node;
a first processing module configured to invoke an equalizer of the distributed file system to perform a load balancing operation when the distribution status indicates that the current data distribution is unbalanced;
the device further comprises:
the second processing module is configured to sleep within the preset time when the distribution state indicates that the current data distribution is balanced;
the device further comprises:
the computing module is configured to compute the average value of the current disk usage of all the data server nodes;
calculating the difference between the current disk usage of each data server node and the average value, and selecting P data server nodes with the largest difference and Q data server nodes with the smallest difference, wherein P and Q are preset positive integers;
the first processing module is specifically configured to:
and calling the equalizer to move data between the P data server nodes and the Q data server nodes.
5. The apparatus of claim 4, wherein the second obtaining module is specifically configured to:
calculating the variance of the current disk usage of all data server nodes, wherein the variance is the distribution state;
when the variance is larger than a first preset threshold value, the current data distribution is unbalanced, and when the variance is smaller than the first preset threshold value, the current data distribution is balanced.
6. The apparatus of claim 4, wherein the second obtaining module is specifically configured to:
calculating the average value of the current disk usage of all the data server nodes;
calculating a difference value between the current disk usage of each data server node and the average value, and calculating the total disk usage X of the N data server nodes with the largest difference value and the total disk usage Y of the M data server nodes with the smallest difference value, wherein N and M are preset positive integers;
the difference between X and Y is the distribution state, when the difference between X and Y is larger than a second preset threshold, the current data distribution is unbalanced, and when the difference between X and Y is smaller than the second preset threshold, the current data distribution is balanced.
7. A load balancing apparatus, comprising:
a processor;
a memory for storing executable instructions of the processor;
wherein the processor is configured to:
acquiring the current disk usage of each data server node in the distributed file system every other preset time;
acquiring the distribution state of current data at each data server node according to the current disk usage of each data server node, wherein the distribution state indicates that the current data is distributed evenly or indicates that the current data is distributed unevenly, and the current data is data stored in each data server node;
when the distribution state indicates that the current data distribution is unbalanced, calling an equalizer of the distributed file system to execute load balancing operation;
when the distribution state indicates that the current data distribution is balanced, sleeping within the preset time;
the processor is further configured to:
calculating the average value of the current disk usage of all the data server nodes;
calculating the difference between the current disk usage of each data server node and the average value, and selecting P data server nodes with the largest difference and Q data server nodes with the smallest difference, wherein P and Q are preset positive integers;
the invoking the balancer of the distributed file system to execute load balancing operation comprises: and calling the equalizer to move data between the P data server nodes and the Q data server nodes.
8. A readable storage medium, in which a computer program is stored, which, when executed by at least one processor of a load balancing apparatus, causes the load balancing apparatus to perform the method according to any one of claims 1 to 3.
CN201811181753.1A 2018-10-11 2018-10-11 Load balancing method and device Active CN109376013B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811181753.1A CN109376013B (en) 2018-10-11 2018-10-11 Load balancing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811181753.1A CN109376013B (en) 2018-10-11 2018-10-11 Load balancing method and device

Publications (2)

Publication Number Publication Date
CN109376013A CN109376013A (en) 2019-02-22
CN109376013B true CN109376013B (en) 2020-12-15

Family

ID=65402907

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811181753.1A Active CN109376013B (en) 2018-10-11 2018-10-11 Load balancing method and device

Country Status (1)

Country Link
CN (1) CN109376013B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110321225B (en) * 2019-07-08 2021-04-30 腾讯科技(深圳)有限公司 Load balancing method, metadata server and computer readable storage medium
CN112328171A (en) * 2020-10-23 2021-02-05 苏州元核云技术有限公司 Data distribution prediction method, data equalization method, device and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106254516A (en) * 2016-08-31 2016-12-21 北京小米移动软件有限公司 Load-balancing method and device
US9600553B1 (en) * 2014-05-31 2017-03-21 Veritas Technologies Llc Distributed replication in cluster environments

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102244685B (en) * 2011-08-11 2013-09-18 中国科学院软件研究所 Distributed type dynamic cache expanding method and system for supporting load balancing
WO2014098790A1 (en) * 2012-12-17 2014-06-26 Empire Technology Development Llc Load balancing scheme
CN104978236B (en) * 2015-07-07 2018-11-06 四川大学 HDFS load source destination node choosing methods based on more measurement indexs
CN105704255B (en) * 2016-04-29 2019-01-08 浙江理工大学 A kind of server load balancing method based on genetic algorithm
CN106411733B (en) * 2016-09-08 2019-05-31 重庆邮电大学 A kind of SDN dynamic load leveling dispatching method based on link real time load
CN107231421A (en) * 2017-05-27 2017-10-03 北京力尊信通科技股份有限公司 A kind of virtual machine computing capability dynamic adjusting method, device and system
CN107911470B (en) * 2017-11-30 2018-12-14 掌阅科技股份有限公司 Distributed dynamic load-balancing method calculates equipment and computer storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9600553B1 (en) * 2014-05-31 2017-03-21 Veritas Technologies Llc Distributed replication in cluster environments
CN106254516A (en) * 2016-08-31 2016-12-21 北京小米移动软件有限公司 Load-balancing method and device

Also Published As

Publication number Publication date
CN109376013A (en) 2019-02-22

Similar Documents

Publication Publication Date Title
CN110633151B (en) Method, device and storage medium for balancing distributed message issuing cluster partitions
KR101933290B1 (en) Method, device and system for application updating
WO2019109564A1 (en) Screen display control method and apparatus
CN107040591B (en) Method and device for controlling client
US11457479B2 (en) Method and apparatus for configuring random access occasion, method and apparatus for random access
CN109376013B (en) Load balancing method and device
CN108600503B (en) Voice call control method and device
CN105227426B (en) Application interface switching method and device and terminal equipment
CN107436782B (en) Application silent installation method and device
CN109586951B (en) Method, device, electronic equipment and readable storage medium for implementing fault transfer
CN111562985A (en) Resource management method and device, electronic equipment and storage medium
CN107894909B (en) Method, device and storage medium for limiting Activity starting
CN107885464B (en) Data storage method, device and computer readable storage medium
CN107203315B (en) Click event processing method and device and terminal
CN111258952B (en) Data storage control method, device and storage medium
CN109948012B (en) Serial number generation method and device and storage medium
CN114442789A (en) Dark screen control method, device, equipment and storage medium
CN111506234B (en) Method and device for preventing false touch of edge of touch screen, storage medium and electronic equipment
CN108984294B (en) Resource scheduling method, device and storage medium
CN107257384B (en) Service state monitoring method and device
CN112416580A (en) Method, device and medium for determining optimal resource allocation mode in application runtime
CN114077461A (en) Application program running method, device, equipment and storage medium
CN111722919A (en) Method and device for running background application program, storage medium and electronic equipment
WO2022099646A1 (en) Beam configuration requesting method and device and beam configuration method and device
CN113138036B (en) Temperature detection method and device and electronic equipment

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
GR01 Patent grant
GR01 Patent grant