[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN110650209B - Method and device for realizing load balancing - Google Patents

Method and device for realizing load balancing Download PDF

Info

Publication number
CN110650209B
CN110650209B CN201910953714.7A CN201910953714A CN110650209B CN 110650209 B CN110650209 B CN 110650209B CN 201910953714 A CN201910953714 A CN 201910953714A CN 110650209 B CN110650209 B CN 110650209B
Authority
CN
China
Prior art keywords
target area
node
determining
value
nodes
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
CN201910953714.7A
Other languages
Chinese (zh)
Other versions
CN110650209A (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 Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and 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 Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201910953714.7A priority Critical patent/CN110650209B/en
Publication of CN110650209A publication Critical patent/CN110650209A/en
Application granted granted Critical
Publication of CN110650209B publication Critical patent/CN110650209B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1004Server selection for load balancing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The embodiment of the application discloses a method and a device for realizing load balancing. One embodiment of the above method comprises: acquiring a server information list; in response to receiving the access request, determining a target region from the at least one region; based on the target area, the following polling steps are performed: according to the balance tree corresponding to the target area, polling a plurality of nodes in the target area, and determining whether the target area comprises available nodes or not; in response to determining that the target area comprises available nodes, taking the obtained first available node as a target node; sending the access request to a server corresponding to the target node; and in response to determining that the target area does not comprise the available nodes, determining a new target area according to the server information list, and continuing to perform the polling step. The embodiment reduces the forwarding delay and improves the forwarding efficiency.

Description

Method and device for realizing load balancing
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a method and a device for realizing load balancing.
Background
With the continued development of Internet (Internet) technology, the number of access faced by web servers has increased significantly and is more unpredictable. In a network, if only one server is used to provide services to clients, the processing power and input-output power of the server must be the bottleneck for providing the services.
In order to solve the defect that a single server has limited processing capacity and can not guarantee to provide services for clients, a distributed server system is currently presented. At the same time, load balancing techniques have emerged for better selection among multiple servers.
The load balancing technology is to set a plurality of servers capable of providing services for clients on a network side and set a load balancing device on the server side. Of course, the selection process of the server is transparent to the client and is not perceived by the user. When the client needs to be accessed, the forwarding device sends an access request to the load balancing device, the load balancing device selects one of the servers according to a certain rule after receiving the access request of the client, and the selected server responds to the client to provide service for the client.
In the load balancing technology, since the client needs to select the server according to a certain rule by the load balancing device every time the client accesses the server, such as selecting randomly or selecting according to the current service load condition of the server, the selected server for providing service for the client is often different in different accesses of the same client.
Disclosure of Invention
The embodiment of the application provides a method and a device for realizing load balancing.
In a first aspect, an embodiment of the present application provides a method for implementing load balancing, which is applied to a load balancing device, and includes: acquiring a server information list, wherein the server information list comprises at least one area where each server is located, and index variables and balance trees corresponding to the at least one area; in response to receiving the access request, determining a target area from the at least one area; based on the target area, the following polling steps are performed: according to the balance tree corresponding to the target area, polling a plurality of nodes in the target area, and determining whether the target area comprises available nodes or not; in response to determining that the target area includes available nodes, taking the obtained first available node as a target node; the access request is sent to a server corresponding to the target node; and in response to determining that the target area does not comprise the available nodes, determining a new target area according to the server information list, and continuing to execute the polling step.
In some embodiments, the at least one region is ordered in the server side information list from near to far from the load balancing device; and determining the target area from the areas where the service ends are located, including: and taking the first area in the server information list as a target area.
In some embodiments, the determining a new target area according to the server side information list includes: and taking the area positioned behind the target area in the server information list as a new target area.
In some embodiments, the balanced tree includes nodes and index values corresponding to the nodes; and polling a plurality of nodes in the balance tree corresponding to the target area to determine whether the target area includes available nodes, including: determining a current node from a plurality of nodes in the balance tree corresponding to the target area according to the value of the index variable; judging whether the current node is an available node or not; if the current node is an available node, determining that the target area comprises the available node; if the current node is an unavailable node, determining a new current node from the plurality of nodes, and continuing to execute the judging step.
In some embodiments, determining the current node from the plurality of nodes in the balanced tree corresponding to the target area according to the value of the index variable includes: acquiring the current value of the index variable, and executing the following modification steps based on the current value: taking the current value as a value to be modified; when the value to be modified is modified, determining whether the value to be modified is equal to the current value of the index variable; if the value is equal to the current node, modifying the value to be modified, and determining the current node according to the obtained modified value; if not, the current value of the index variable is acquired again, and the modification step is continued.
In some embodiments, the balancing tree includes a load limit value of the server; and determining whether the current node is an available node, including: determining the access request bearing capacity of the current node at the receiving moment of the access request; and determining whether the access request bearing capacity is smaller than the bearing limit value, and if so, determining the current node as an available node.
In a second aspect, an embodiment of the present application provides a device for implementing load balancing, where the device is disposed on a load balancing device, and the device includes: the system comprises an acquisition unit, a storage unit and a control unit, wherein the acquisition unit is configured to acquire a server information list, and the server information list comprises at least one area where each server is located, and index variables and balance trees corresponding to the at least one area; a determining unit configured to determine a target area from the at least one area in response to receiving an access request; a polling unit configured to perform the following polling steps based on the target area: according to the balance tree corresponding to the target area, polling a plurality of nodes in the target area, and determining whether the target area comprises available nodes or not; in response to determining that the target area includes available nodes, taking the obtained first available node as a target node; the access request is sent to a server corresponding to the target node; and a feedback unit configured to determine a new target area according to the server information list in response to determining that the target area does not include an available node, and continue to perform the polling step.
In some embodiments, the at least one region is ordered in the server side information list from near to far from the load balancing device; and the above-mentioned determination unit is further configured to: and taking the first area in the server information list as a target area.
In some embodiments, the feedback unit is further configured to: and taking the area positioned behind the target area in the server information list as a new target area.
In some embodiments, the balanced tree includes nodes and index values corresponding to the nodes; and the polling unit is further configured to: determining a current node from a plurality of nodes in the balance tree corresponding to the target area according to the value of the index variable; judging whether the current node is an available node or not; if the current node is an available node, determining that the target area comprises the available node; if the current node is an unavailable node, determining a new current node from the plurality of nodes, and continuing to execute the judging step.
In some embodiments, the above-described polling unit is further configured to: acquiring the current value of the index variable, and executing the following modification steps based on the current value: taking the current value as a value to be modified; when the value to be modified is modified, determining whether the value to be modified is equal to the current value of the index variable; if the value is equal to the current node, modifying the value to be modified, and determining the current node according to the obtained modified value; if not, the current value of the index variable is acquired again, and the modification step is continued.
In some embodiments, the balancing tree includes a load limit value of the server; and the polling unit is further configured to: determining the access request bearing capacity of the current node at the receiving moment of the access request; and determining whether the access request bearing capacity is smaller than the bearing limit value, and if so, determining the current node as an available node.
In a third aspect, an embodiment of the present application provides an electronic device, including: one or more processors; and a storage device having one or more programs stored thereon, which when executed by the one or more processors cause the one or more processors to implement the method as described in any of the embodiments of the first aspect.
In a fourth aspect, embodiments of the present application provide a computer readable medium having stored thereon a computer program which, when executed by a processor, implements a method as described in any of the embodiments of the first aspect.
The method and the device for realizing load balancing provided by the above embodiments of the present application may first obtain a server information list. The server information list includes at least one region in which the server is provided and at least one balanced tree corresponding to the at least one region. The balanced tree comprises a plurality of nodes, and each node corresponds to one service end. Upon receipt of the access request, a target region may be determined from the at least one region. Then, based on the target area, the following polling steps are performed: and according to the balance tree corresponding to the target area, polling a plurality of nodes in the target area, and determining whether the target area comprises available nodes. And if the available nodes are determined to be included in the target area, the first available node which is polled is taken as the target node. And sending the access request to a server corresponding to the target node. If the target area does not comprise the available nodes, determining a new target area according to the server information list, and continuing to execute the polling step. The method of the embodiment can forward the access request according to the area of the server, reduces the forwarding delay and improves the forwarding efficiency.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the detailed description of non-limiting embodiments, made with reference to the following drawings, in which:
FIG. 1 is an exemplary system architecture diagram in which an embodiment of the present application may be applied;
FIG. 2 is a flow chart of one embodiment of a method of implementing load balancing according to the present application;
FIG. 3 is a schematic diagram of a server side information list;
FIG. 4 is a schematic diagram of an application scenario of a method of implementing load balancing according to the present application;
FIG. 5 is a flow chart of another embodiment of determining available nodes in a method of implementing load balancing according to the present application;
FIG. 6 is a schematic structural diagram of one embodiment of an apparatus to implement load balancing according to the present application;
fig. 7 is a schematic diagram of a computer system suitable for use in implementing embodiments of the present application.
Detailed Description
The present application is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be noted that, for convenience of description, only the portions related to the present invention are shown in the drawings.
It should be noted that, in the case of no conflict, the embodiments and features in the embodiments may be combined with each other. The present application will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 illustrates an exemplary system architecture 100 to which embodiments of a method of implementing load balancing or an apparatus implementing load balancing of the present application may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, a forwarding device 103, a load balancing device 104, and servers 105, 106, 107. The terminal devices 101, 102 may interact with the forwarding device 103 via a network, the forwarding device 103 may interact with the load balancing device 104 via a network, and the load balancing device 104 may interact with the servers 105, 106, 107 via a network. The network may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The user may send an access request to the forwarding device 103 over the network using the terminal devices 101, 102. Various communication client applications, such as a web browser application, a shopping class application, a search class application, an instant messaging tool, a mailbox client, social platform software, etc., may be installed on the terminal devices 101, 102.
The terminal devices 101 and 102 may be hardware or software. When the terminal devices 101, 102 are hardware, they may be various electronic devices having a display screen and supporting request transmission, including but not limited to smartphones, tablet computers, laptop and desktop computers, and the like. When the terminal devices 101, 102 are software, they can be installed in the above-listed electronic devices. Which may be implemented as multiple software or software modules (e.g., to provide distributed services), or as a single software or software module. The present invention is not particularly limited herein.
The forwarding device 103 may be a device, such as a router, switch, etc., that may be capable of receiving and forwarding requests. Specifically, forwarding device 103 may send an access request to load balancing device 104.
The load balancing device 104 may be a device capable of receiving requests and sending requests, such as a gateway or the like. The load balancing device 104 may select a server that receives the access request sent by the terminal device 101, 102 by various load balancing algorithms.
The servers 105, 106, 107 may be servers providing various services, such as a background server processing access requests sent by the terminal devices 101, 102.
The servers 105, 106, 107 may be hardware or software. When the servers 105, 106, 107 are hardware, they may be implemented as a distributed server cluster formed by a plurality of servers, or as a single server. When the servers 105, 106, 107 are software, they may be implemented as multiple software or software modules (e.g., to provide distributed services), or as a single software or software module. The present invention is not particularly limited herein.
It should be noted that, the method for implementing load balancing provided in the embodiments of the present application is generally executed by the load balancing device 104, and accordingly, the apparatus for implementing load balancing is generally disposed in the load balancing device 104.
It should be understood that the number of terminal devices, forwarding devices, load balancing devices and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, forwarding devices, load balancing devices, and servers, as desired for implementation.
With continued reference to fig. 2, a flow 200 of one embodiment of a method of implementing load balancing in accordance with the present application is shown. The method for realizing load balancing in the embodiment comprises the following steps:
Step 201, a server information list is obtained.
In this embodiment, the execution body of the method for implementing load balancing (for example, the load balancing device 104 shown in fig. 1) may acquire the server information list through a wired connection manner or a wireless connection manner. In this embodiment, the server information list may include at least one area where each server is located and a balanced tree corresponding to each area. The balanced tree comprises a plurality of nodes, and each node corresponds to one service end. The server may be configured to process an access request sent by the terminal device.
In some optional implementations of this embodiment, the server information list may be generated by manually preset information of each server. The information of each service end can include identification, the area where the service end is located, website address, weight and bearing limit. The identifier is used for uniquely identifying a server, the area in which the server is located is used for representing an area in which the server is located (for example, beijing, suzhou, qingdao, etc.), the website is used for representing a network address of the server, the weight is preset manually, and generally, the higher the weight is, the more times of processing the access request are. The bearer limit refers to a maximum value of the service end processing the access request, and may be, for example, a throughput maximum value, a query rate per second (QPS) maximum value, a concurrency number maximum value, and the like.
The above-described composition form of the server side information list may be as shown in fig. 3. In fig. 3, the list includes 3 elements, each representing an area where the server is located. Each element includes a balanced tree and an index, and the balanced tree encapsulates information of all servers in the area. Thus, the storage space is greatly saved while the retrieval speed is ensured.
Specific description will be given by taking table 1 as an example.
TABLE 1 information Table at the Server
For the server in the Beijing area, the index value corresponding to the server 1 is 4, the index value corresponding to the server 2 is 6, the index value corresponding to the server 3 is 7, the index value corresponding to the server 4 is 10, and the index value corresponding to the server 5 is 12. The initial value of the index variable may be set to 12.
In some optional implementations of this embodiment, the at least one area is ordered in the server information list according to a distance from the load balancing device from near to far.
For example, the executive body is located in Beijing, and the areas include Beijing, qingdao, and Suzhou. In the server information list, the Beijing area is located at the first position, the Qingdao area is located at the second position, and the Suzhou area is located at the third position.
In response to receiving the access request, a target region is determined from the at least one region, step 202.
After the executing body receives the access request, the target area can be determined from the at least one area. The access request may be sent by the forwarding device to the executing body. The execution subject may set an area nearest to the execution subject as the target area. Or the execution body may also use the area with the largest number of servers as the target area. Alternatively, the execution body may set the region where the sum of weights is largest as the target region.
In some optional implementations of this embodiment, the execution body may use an area located at the top in the server side information list as the target area.
In this way, the server in the target area is closer to the execution subject, and delay in sending the access request can be reduced.
Step 203, based on the target area, the following polling steps 2031 to 2033 are performed.
After determining the target area, the execution subject may perform the following polling steps to poll each server in the target area.
In step 2031, a plurality of nodes in the target area are polled according to the balance tree corresponding to the target area, and whether the target area includes an available node is determined.
In this embodiment, after determining the target area, the execution body may poll the plurality of nodes in the target area according to the balance tree corresponding to the target area. Specifically, the execution body may determine whether each server in the target area is available in turn. If a certain service end is available, the target area is indicated to comprise available nodes. When judging whether the server is available, the execution body can judge whether the server is available by comparing the delay, throughput and QPS of the server with preset maximum values respectively.
In response to determining that the target area includes an available node, step 2032, the resulting first available node is taken as the target node.
When it is determined that the available node is included in the target area, the execution body may take the resulting first available node as the target node. In this embodiment, this saves time in retrieving available nodes.
Step 2033, sending the access request to the server corresponding to the target node.
After determining the target node, the execution body may use the server corresponding to the target node as the server for processing the access request, and then may send the access request to the server corresponding to the target node.
In step 204, in response to determining that the target area does not include an available node, a new target area is determined according to the server side information list, and the polling step is continued.
In this embodiment, if the execution subject determines that the target area does not include the available node, it is indicated that each server in the target area is unavailable. The execution body may determine a new target area from the server-side information list and then continue the polling step. I.e., each server in the new target area is polled to determine if the new target area includes available nodes.
In some optional implementations of this embodiment, the execution body may use an area located next to the target area in the server side information list as the new target area. Taking the server side information list shown in fig. 3 as an example, in step 202, a Beijing area is determined as a target area, and in step 204, a Qingdao is determined as a target area.
With continued reference to fig. 4, fig. 4 is a schematic diagram of an application scenario of the method for implementing load balancing according to the present embodiment. In the application scenario of fig. 4, a user sends an access request through a terminal 401, the access request is forwarded by a router 402 and then reaches a gateway 403, the gateway 403 is set in a zhou area, and a target area is determined to be a state according to the areas of a state, a Qingdao and a Beijing which are included in a server information list. And then, according to the balance tree corresponding to the Suzhou area, all nodes in the Suzhou area are polled to obtain available nodes. And taking the obtained first available node as a target node. Gateway 403 then sends the access request to the server 404 corresponding to the target node.
The method for implementing load balancing provided in the above embodiment of the present application may first obtain a server information list. The server information list includes at least one region in which the server is provided and at least one balanced tree corresponding to the at least one region. The balanced tree comprises a plurality of nodes, and each node corresponds to one service end. Upon receipt of the access request, a target region may be determined from the at least one region. Then, based on the target area, the following polling steps are performed: and according to the balance tree corresponding to the target area, polling a plurality of nodes in the target area, and determining whether the target area comprises available nodes. And if the available nodes are determined to be included in the target area, the first available node which is polled is taken as the target node. And sending the access request to a server corresponding to the target node. If the target area does not comprise the available nodes, determining a new target area according to the server information list, and continuing to execute the polling step. The method of the embodiment can forward the access request according to the area of the server, reduces the forwarding delay and improves the forwarding efficiency.
With continued reference to fig. 5, a flow 500 of one embodiment of determining available nodes in a method of implementing load balancing according to the present application is shown. In this embodiment, the balanced tree includes a plurality of nodes, each node having an index value.
As shown in fig. 5, the method for implementing load balancing in this embodiment may include the following steps:
step 501, determining a current node from a plurality of nodes in the balance tree corresponding to the target area according to the value of the index variable.
In this embodiment, the execution body may determine the current node from a plurality of nodes in the balanced tree corresponding to the target area according to the value of the index variable (index). Specifically, the execution body may use a node corresponding to a smallest index value among values of index variables, where the index value is greater than or equal to the smallest index value in the balance tree, as the current node. For example, if the value of the index variable is any one of 1 to 4, the corresponding node is the server 1, if the value of the index variable is 5 or 6, the corresponding node is the server 2, and so on.
In some alternative implementations of the present embodiment, the step 501 may specifically determine the current node by the following steps not shown in fig. 5: acquiring the current value of the index variable, and executing the following modification steps based on the current value: taking the current value as a value to be modified; when the value to be modified is modified, determining whether the value to be modified is equal to the current value of the index variable; if the current node is equal to the current node, modifying the value to be modified, and determining the current node according to the obtained modified value; if not, the current value of the index variable is acquired again, and the modifying step is continued.
In this implementation, the execution body may first obtain the current value of the index variable. The execution body may then take the current value as the value to be modified. Then, at the moment when the value to be modified is modified, it is determined whether the value to be modified is equal to the current value of the index variable. If equal, it indicates that no other thread is to modify the current value of the index variable. The execution body may modify the value to be modified and determine the current node from the resulting modified value. Here, modifying may refer to subtracting 1 or adding 1 to the value to be modified. If not, it is stated that there are other threads currently present that have modified the current value of the index variable. The execution body may acquire the current value of the index variable again and continue to execute the modification step described above.
According to the implementation mode, whether more than two threads exist at present or not can be judged in an unlocking mode, the same value is modified at the same time, the correctness of data is ensured, and meanwhile, the calculation performance is improved.
Step 502, it is determined whether the current node is an available node.
After determining the current node, the execution body may determine whether the current node is an available node. Specifically, the execution body may determine whether the server is available by comparing the delay, throughput, and QPS of the server with preset maximum values, respectively.
In some optional implementations of this embodiment, the balancing tree includes a load limit value of the server. Step 502 may be implemented by the following steps, not shown in fig. 5: determining the access request bearing capacity of the current node at the receiving moment of the access request; it is determined whether the access request bearer amount is less than a bearer limit value, and if so, the current node is determined to be an available node.
In this implementation manner, the executing body may first determine the receiving time of the access request, and the access request carrying capacity of the current node. Specifically, the executing body may query, at the device storing the access request load amounts of the nodes at the respective times, the access request load amounts of the current nodes at the receiving times of the access requests. Such storage devices may include Redis (distributed database), memory, and the like. The executing body may compare the above access request load amount with a load limit value. If the access request bearer size is less than the bearer limit, it is indicated that the current node may also continue to process access requests, i.e. the current node is an available node. The implementation mode can protect the server through setting the bearing limit value, and avoid the collapse of the server due to overload bearing.
In step 503, if the current node is an available node, it is determined that the target area includes the available node.
If the execution body judges that the current node is an available node, it may be determined that the available node is included in the target area.
In step 504, if the current node is an unavailable node, a new current node is determined among the plurality of nodes, and the determining step is continued.
If the executing entity determines that the current node is not available, the executing entity may determine a new current node from the plurality of nodes and then proceed to the determining step.
According to the method for realizing load balancing, which is provided by the embodiment of the application, the correctness of the data can be ensured in an unlocking mode, and the computing performance is improved.
With further reference to fig. 6, as an implementation of the method shown in the foregoing figures, the present application provides an embodiment of an apparatus for implementing load balancing, where an embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 6, and the apparatus may be specifically applied to various electronic devices.
As shown in fig. 6, the apparatus 600 for implementing load balancing of the present embodiment includes: an acquisition unit 601, a determination unit 602, a polling unit 603, and a feedback unit 604.
The acquiring unit 601 is configured to acquire a server side information list. The server information list comprises at least one area where each server is located, and index variables and balance trees corresponding to the at least one area.
The determining unit 602 is configured to determine the target area from the at least one area in response to receiving the access request.
A polling unit 603 configured to perform the following polling steps based on the target area: according to the balance tree corresponding to the target area, polling a plurality of nodes in the target area, and determining whether the target area comprises available nodes or not; in response to determining that the target area comprises available nodes, taking the obtained first available node as a target node; and sending the access request to a server corresponding to the target node.
And a feedback unit 604 configured to determine a new target area according to the server information list in response to determining that the available nodes are not included in the target area, and continue to perform the polling step.
In some optional implementations of this embodiment, at least one region is ordered in the server side information list from near to far from the distance between the load balancing device. The determining unit 602 is further configured to: and taking the first area in the server information list as a target area.
In some optional implementations of the present embodiment, the feedback unit 604 is further configured to: and taking the area positioned at the rear of the target area in the server information list as a new target area.
In some alternative implementations of the present embodiment, the balanced tree includes nodes and index values corresponding to the nodes. The polling unit 603 may be further configured to: determining a current node from a plurality of nodes in the balance tree corresponding to the target area according to the value of the index variable; judging whether the current node is an available node or not; if the current node is an available node, determining that the target area comprises the available node; if the current node is an unavailable node, determining a new current node in the plurality of nodes, and continuing to execute the judging step.
In some optional implementations of the present embodiment, the polling unit 603 is further configured to: acquiring the current value of the index variable, and executing the following modification steps based on the current value: taking the current value as a value to be modified; when the value to be modified is modified, determining whether the value to be modified is equal to the current value of the index variable; if the current node is equal to the current node, modifying the value to be modified, and determining the current node according to the obtained modified value; if not, the current value of the index variable is acquired again, and the modifying step is continued.
In some alternative implementations of the present embodiment, the balancing tree includes a load limit value for the server. The polling unit 603 is further configured to: determining the access request bearing capacity of the current node at the receiving moment of the access request; it is determined whether the access request bearer amount is less than a bearer limit value, and if so, the current node is determined to be an available node.
It should be understood that the units 601 to 604 described in the apparatus 600 for realizing load balancing correspond to the respective steps in the method described with reference to fig. 2. Thus, the operations and features described above with respect to the method of implementing load balancing are equally applicable to the apparatus 600 and the units contained therein, and are not described in detail herein.
Referring now to fig. 7, a schematic diagram of an electronic device (e.g., the load balancing device of fig. 1) 700 suitable for use in implementing embodiments of the present disclosure is shown. The electronic device shown in fig. 7 is only one example and should not impose any limitations on the functionality and scope of use of embodiments of the present disclosure.
As shown in fig. 7, the electronic device 700 may include a processing means (e.g., a central processor, a graphics processor, etc.) 701, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 702 or a program loaded from a storage means 708 into a Random Access Memory (RAM) 703. In the RAM703, various programs and data required for the operation of the electronic device 700 are also stored. The processing device 701, the ROM 702, and the RAM703 are connected to each other through a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
In general, the following devices may be connected to the I/O interface 705: input devices 706 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 707 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 708 including, for example, magnetic tape, hard disk, etc.; and a communication device 709. The communication means 709 may allow the electronic device 700 to communicate wirelessly or by wire with other devices to exchange data. While fig. 7 shows an electronic device 700 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead. Each block shown in fig. 7 may represent one device or a plurality of devices as needed.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via communication device 709, or installed from storage 708, or installed from ROM 702. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing device 701. It should be noted that, the computer readable medium according to the embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In an embodiment of the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. Whereas in embodiments of the present disclosure, the computer-readable signal medium may comprise a data signal propagated in baseband or as part of a carrier wave, with computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: acquiring a server information list, wherein the server information list comprises at least one area in which each server is located, at least one index variable corresponding to the at least one area and a balance tree, and the balance tree comprises a plurality of nodes, and each node corresponds to one server; in response to receiving the access request, determining a target region from the at least one region; based on the target area, the following polling steps are performed: according to the balance tree corresponding to the target area, polling a plurality of nodes in the target area, and determining whether the target area comprises available nodes or not; in response to determining that the target area comprises the available nodes, taking the first available node obtained by polling as a target node; sending the access request to a server corresponding to the target node; and in response to determining that the target area does not comprise the available nodes, determining a new target area according to the server information list, and continuing to perform the polling step.
Computer program code for carrying out operations of embodiments of the present disclosure may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments described in the present disclosure may be implemented by means of software, or may be implemented by means of hardware. The described units may also be provided in a processor, for example, described as: a processor includes an acquisition unit, a determination unit, a polling unit, and a feedback unit. The names of these units do not constitute a limitation on the unit itself in some cases, and for example, the acquisition unit may also be described as "a unit that acquires a server side information list".
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by those skilled in the art that the scope of the invention in the embodiments of the present disclosure is not limited to the specific combination of the above technical features, but encompasses other technical features formed by any combination of the above technical features or their equivalents without departing from the spirit of the invention. Such as the above-described features, are mutually substituted with (but not limited to) the features having similar functions disclosed in the embodiments of the present disclosure.

Claims (12)

1. A method for implementing load balancing, applied to load balancing equipment, comprising:
Acquiring a server information list, wherein the server information list comprises at least one area where each server is located, and index variables and balance trees corresponding to the at least one area;
in response to receiving the access request, determining a target area from the at least one area;
based on the target area, the following polling steps are performed: according to the balance tree corresponding to the target area, polling a plurality of nodes in the target area, and determining whether the target area comprises available nodes or not; in response to determining that the target area includes available nodes, taking the obtained first available node as a target node; sending the access request to a server corresponding to the target node;
in response to determining that the target area does not include an available node, determining a new target area according to the server information list, and continuing to execute the polling step;
the balance tree comprises nodes and index values corresponding to the nodes; and polling a plurality of nodes in the balance tree corresponding to the target area, and determining whether the target area includes available nodes includes: determining a current node from a plurality of nodes in the balance tree corresponding to the target area according to the value of the index variable; judging whether the current node is an available node or not; if the current node is an available node, determining that the target area comprises the available node;
And determining the current node from a plurality of nodes in the balance tree corresponding to the target area according to the value of the index variable, wherein the determining comprises the following steps: acquiring a current value of an index variable, and executing the following modification steps based on the current value: taking the current value as a value to be modified; when the value to be modified is modified, determining whether the value to be modified is equal to the current value of the index variable; if the value is equal to the current node, modifying the value to be modified, and determining the current node according to the obtained modified value; if not, the current value of the index variable is acquired again, and the modifying step is continued.
2. The method of claim 1, wherein the at least one region is ordered in the server side information list from near to far from the distance between the load balancing devices; and
the determining the target area from the area where the server is located includes:
and taking the area at the first position in the server information list as a target area.
3. The method of claim 2, wherein the determining a new target area according to the server-side information list comprises:
and taking the area positioned behind the target area in the server information list as a new target area.
4. The method of claim 1, wherein,
the polling is performed on a plurality of nodes in the balance tree corresponding to the target area, and determining whether the target area includes available nodes or not further includes:
if the current node is an unavailable node, determining a new current node in the plurality of nodes, and continuing to execute the judging step.
5. The method of claim 4, wherein the balancing tree comprises a server-side bearer limit value; and
the determining whether the current node is an available node includes:
determining the access request bearing capacity of the current node at the receiving moment of the access request;
and determining whether the access request bearing capacity is smaller than the bearing limit value, and if so, determining that the current node is an available node.
6. An apparatus for implementing load balancing, provided in a load balancing device, comprising:
the system comprises an acquisition unit, a storage unit and a control unit, wherein the acquisition unit is configured to acquire a server information list, and the server information list comprises at least one area where each server is located, and index variables and balance trees corresponding to the at least one area;
a determining unit configured to determine a target area from the at least one area in response to receiving the access request;
A polling unit configured to perform the following polling steps based on the target area: according to the balance tree corresponding to the target area, polling a plurality of nodes in the target area, and determining whether the target area comprises available nodes or not; in response to determining that the target area includes available nodes, taking the obtained first available node as a target node; sending the access request to a server corresponding to the target node;
a feedback unit configured to determine a new target area according to the server information list in response to determining that the target area does not include an available node, and continue to perform the polling step;
the balance tree comprises nodes and index values corresponding to the nodes; and the polling unit is further configured to: determining a current node from a plurality of nodes in the balance tree corresponding to the target area according to the value of the index variable; judging whether the current node is an available node or not; if the current node is an available node, determining that the target area comprises the available node;
the polling unit is further configured to: acquiring a current value of an index variable, and executing the following modification steps based on the current value: taking the current value as a value to be modified; when the value to be modified is modified, determining whether the value to be modified is equal to the current value of the index variable; if the value is equal to the current node, modifying the value to be modified, and determining the current node according to the obtained modified value; if not, the current value of the index variable is acquired again, and the modifying step is continued.
7. The apparatus of claim 6, wherein the at least one region is ordered in the server side information list from near to far distance from the load balancing device; and
the determination unit is further configured to:
and taking the area at the first position in the server information list as a target area.
8. The apparatus of claim 7, wherein the feedback unit is further configured to:
and taking the area positioned behind the target area in the server information list as a new target area.
9. The apparatus of claim 6, wherein,
the polling unit is further configured to:
if the current node is an unavailable node, determining a new current node in the plurality of nodes, and continuing to execute the judging step.
10. The apparatus of claim 9, wherein the balancing tree comprises a service-side bearer limit value; and
the polling unit is further configured to:
determining the access request bearing capacity of the current node at the receiving moment of the access request;
and determining whether the access request bearing capacity is smaller than the bearing limit value, and if so, determining that the current node is an available node.
11. An electronic device, comprising:
one or more processors;
a storage device having one or more programs stored thereon,
when executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-5.
12. A computer readable medium having stored thereon a computer program, wherein the program when executed by a processor implements the method of any of claims 1-5.
CN201910953714.7A 2019-10-09 2019-10-09 Method and device for realizing load balancing Active CN110650209B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910953714.7A CN110650209B (en) 2019-10-09 2019-10-09 Method and device for realizing load balancing

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910953714.7A CN110650209B (en) 2019-10-09 2019-10-09 Method and device for realizing load balancing

Publications (2)

Publication Number Publication Date
CN110650209A CN110650209A (en) 2020-01-03
CN110650209B true CN110650209B (en) 2023-07-18

Family

ID=69012421

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910953714.7A Active CN110650209B (en) 2019-10-09 2019-10-09 Method and device for realizing load balancing

Country Status (1)

Country Link
CN (1) CN110650209B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111343235A (en) * 2020-02-06 2020-06-26 北京百度网讯科技有限公司 Data processing method and device, access system, electronic equipment and storage medium
CN111447282B (en) * 2020-03-31 2022-06-07 北京百度网讯科技有限公司 Method and device for determining transmission path
CN111683139B (en) * 2020-06-05 2022-10-21 北京百度网讯科技有限公司 Method and device for balancing load
CN113746933A (en) * 2021-09-14 2021-12-03 京东科技信息技术有限公司 Method and device for displaying information

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101989951A (en) * 2010-10-28 2011-03-23 北京瑞汛世纪科技有限公司 Method, system and equipment for selecting service node
CN102265568A (en) * 2011-06-13 2011-11-30 华为技术有限公司 Communication method and load equalizer
CN104734983A (en) * 2013-12-24 2015-06-24 中国移动通信集团公司 Scheduling system, method and device for service data request
CN104780184A (en) * 2014-01-09 2015-07-15 华耀(中国)科技有限公司 Method of using geographical location information for load balancing
CN205829703U (en) * 2015-10-22 2016-12-21 国家电网公司 The big data platform of power scheduling based on collective and distributive type Cloud Server group
CN109151009A (en) * 2018-08-09 2019-01-04 中国联合网络通信集团有限公司 A kind of CDN node distribution method and system based on MEC
CN109936635A (en) * 2019-03-12 2019-06-25 北京百度网讯科技有限公司 Load-balancing method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060112170A1 (en) * 2004-05-03 2006-05-25 Craig Sirkin Geo-locating load balancing

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101989951A (en) * 2010-10-28 2011-03-23 北京瑞汛世纪科技有限公司 Method, system and equipment for selecting service node
CN102265568A (en) * 2011-06-13 2011-11-30 华为技术有限公司 Communication method and load equalizer
CN104734983A (en) * 2013-12-24 2015-06-24 中国移动通信集团公司 Scheduling system, method and device for service data request
CN104780184A (en) * 2014-01-09 2015-07-15 华耀(中国)科技有限公司 Method of using geographical location information for load balancing
CN205829703U (en) * 2015-10-22 2016-12-21 国家电网公司 The big data platform of power scheduling based on collective and distributive type Cloud Server group
CN109151009A (en) * 2018-08-09 2019-01-04 中国联合网络通信集团有限公司 A kind of CDN node distribution method and system based on MEC
CN109936635A (en) * 2019-03-12 2019-06-25 北京百度网讯科技有限公司 Load-balancing method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
单轩.WebRTC系统管理子系统的设计与实现.《中国优秀硕士学位论文全文数据库信息科技辑》.2018,正文第13、16页. *

Also Published As

Publication number Publication date
CN110650209A (en) 2020-01-03

Similar Documents

Publication Publication Date Title
CN110650209B (en) Method and device for realizing load balancing
US10129332B2 (en) Load balancing of distributed services
CN109600447B (en) Method, device and system for processing data
CN111291103B (en) Interface data analysis method and device, electronic equipment and storage medium
CN110753112A (en) Elastic expansion method and device of cloud service
CN109218341B (en) Load balancing method and device for monitoring server and server
CN110781373B (en) List updating method and device, readable medium and electronic equipment
CN105791381A (en) Access control method and apparatus
CN112379982B (en) Task processing method, device, electronic equipment and computer readable storage medium
CN111831448A (en) Request processing method and device and electronic equipment
CN111831503B (en) Monitoring method based on monitoring agent and monitoring agent device
US9602594B2 (en) Processing requests
CN113051456A (en) Request processing method and device, electronic equipment and computer readable medium
US20170161108A1 (en) Load distribution process server, load distribution process method, and load distribution process system
US10616317B2 (en) Method and system for affinity load balancing
CN109213815B (en) Method, device, server terminal and readable medium for controlling execution times
CN112925623B (en) Task processing method, device, electronic equipment and medium
US10097484B2 (en) Using send buffers and receive buffers for sending messages among nodes in a network
US20080163238A1 (en) Dynamic load balancing architecture
CN113239301A (en) Page loading request method and device and electronic equipment
CN108520025B (en) Service node determination method, device, equipment and medium
CN115174588B (en) Bandwidth control method, device, apparatus, storage medium and program product
CN116820354B (en) Data storage method, data storage device and data storage system
CN113835796B (en) Method and device for processing information
CN111314457B (en) Method and device for setting virtual private cloud

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