CN110311957B - Server load balancing method and related equipment - Google Patents

Server load balancing method and related equipment Download PDF

Info

Publication number
CN110311957B
CN110311957B CN201910514178.0A CN201910514178A CN110311957B CN 110311957 B CN110311957 B CN 110311957B CN 201910514178 A CN201910514178 A CN 201910514178A CN 110311957 B CN110311957 B CN 110311957B
Authority
CN
China
Prior art keywords
access request
access
access requests
sequence
sets
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
CN201910514178.0A
Other languages
Chinese (zh)
Other versions
CN110311957A (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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201910514178.0A priority Critical patent/CN110311957B/en
Priority to PCT/CN2019/101956 priority patent/WO2020248363A1/en
Publication of CN110311957A publication Critical patent/CN110311957A/en
Application granted granted Critical
Publication of CN110311957B publication Critical patent/CN110311957B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • 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
    • 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/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
    • H04L67/1008Server selection for load balancing based on parameters of servers, e.g. available memory or workload
    • 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
    • H04L67/1023Server selection for load balancing based on a hash applied to IP addresses or costs
    • 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/56Provisioning of proxy services
    • 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
    • H04L67/63Routing a service request depending on the request content or context

Abstract

The application relates to resource allocation in the technical field of data processing, in particular to a server load balancing method and related equipment, wherein the method comprises the following steps: obtaining M first access requests sent by N clients, wherein each client corresponds to at least one first access request, N is an integer larger than 1, and M is an integer larger than or equal to N; calling a pre-stored load balancing strategy, wherein the load balancing strategy is used for reasonably distributing M first access requests to P webpage servers, P is an integer larger than 1, and P is an integer smaller than N; determining a web server corresponding to each first access request in the M first access requests according to a load balancing strategy; and forwarding each first access request to the corresponding webpage server. By adopting the embodiment of the application, the efficiency of load balancing of the server can be improved.

Description

Server load balancing method and related equipment
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a server load balancing method and related devices.
Background
A common use for software load balancing is Nginx. Nginx is a high performance HTTP and reverse proxy server. At present, a server load balancing method is that a reverse proxy server allocates access requests only according to weights corresponding to web servers, that is, the larger the weight of a web server is, the larger the number of access requests allocated to the web server is. This approach results in inefficient server load balancing.
Disclosure of Invention
The embodiment of the application provides a server load balancing method and related equipment, which are used for improving the efficiency of server load balancing.
In a first aspect, an embodiment of the present application provides a server load balancing method, where the method includes:
obtaining M first access requests sent by N clients, wherein each client corresponds to at least one first access request, N is an integer greater than 1, and M is an integer greater than or equal to N;
calling a pre-stored load balancing strategy, wherein the load balancing strategy is used for reasonably distributing the M first access requests to P webpage servers, P is an integer larger than 1, and P is an integer smaller than N;
determining a web server corresponding to each first access request in the M first access requests according to the load balancing strategy;
and forwarding each first access request to the corresponding webpage server.
In a second aspect, an embodiment of the present application provides a server load balancing apparatus, where the apparatus includes:
an obtaining unit, configured to obtain M first access requests sent by N clients, where each client corresponds to at least one first access request, N is an integer greater than 1, and M is an integer greater than or equal to N;
the calling unit is used for calling a pre-stored load balancing strategy, wherein the load balancing strategy is used for reasonably distributing the M first access requests to P webpage servers, P is an integer larger than 1, and P is an integer smaller than N;
the determining unit is used for determining a webpage server corresponding to each first access request in the M first access requests according to the load balancing strategy;
and the forwarding unit is used for forwarding each first access request to the corresponding webpage server.
In a third aspect, an embodiment of the present application provides a server, including a processor, a memory, a communication interface, and one or more programs, where the one or more programs are stored in the memory and configured to be executed by the processor, and where the program includes instructions for performing some or all of the steps of the method according to the first aspect of the embodiment of the present application.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium for storing a computer program, where the computer program is executed by a processor to implement some or all of the steps described in the method according to the first aspect of the embodiments of the present application.
It can be seen that, in the embodiment of the present application, the reverse proxy server obtains M first access requests sent by N clients, determines, according to a pre-stored load balancing policy, a web server corresponding to each first access request in the M first access requests, and forwards each first access request to its corresponding web server. Compared with the method that the access requests are distributed only according to the weight corresponding to the webpage server, the weight is in direct proportion to the number of the access requests, the method and the device reasonably distribute the M first access requests to the P webpage servers through the load balancing strategy, and therefore the method and the device are beneficial to improving the efficiency of server load balancing.
These and other aspects of the present application will be more readily apparent from the following description of the embodiments.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments or the background art of the present application, the drawings required to be used in the embodiments or the background art of the present application will be described below.
Fig. 1A is a schematic flowchart of a server load balancing method according to an embodiment of the present application;
FIG. 1B is a schematic diagram provided by an embodiment of the present application;
FIG. 1C is another schematic illustration provided by an embodiment of the present application;
fig. 2 is a schematic flowchart of another server load balancing method according to an embodiment of the present application;
fig. 3 is a schematic flowchart of another server load balancing method according to an embodiment of the present application;
fig. 4 is a block diagram illustrating functional units of a server load balancing apparatus according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of a server according to an embodiment of the present application.
Detailed description of the invention
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The following are detailed below.
The terms "first," "second," "third," and "fourth," etc. in the description and claims of this application and in the accompanying drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
Hereinafter, some terms in the present application are explained to facilitate understanding by those skilled in the art.
(1) The client, also called client, refers to a program corresponding to the server and providing local services to the client. Except for some application programs which only run locally, the application programs are generally installed on common clients and need to be operated together with a server.
(2) Servers, also known as servers, are devices that provide computing services. The server is constructed to include a processor, a hard disk, a memory, a system bus, etc., similar to a general-purpose computer architecture. Under a network environment, the server is divided into a file server, a database server, an application server, a WEB server and the like according to different service types provided by the server.
The following describes embodiments of the present application in detail.
Referring to fig. 1A, fig. 1A is a schematic flow chart of a server load balancing method according to an embodiment of the present application, where the server load balancing method includes steps 101 and 104, and specifically includes the following steps:
101: the reverse proxy server obtains M first access requests sent by N clients, each client corresponds to at least one first access request, N is an integer larger than 1, and M is an integer larger than or equal to N.
Herein, the reverse proxy server is nginnx, which is a lightweight Web server/reverse proxy server and email (IMAP/POP3) proxy server.
In one possible example, the obtaining, by the reverse proxy server, M first access requests sent by N clients includes:
the reverse proxy server sends N pieces of inquiry information to the N clients, wherein each piece of inquiry information is used for indicating the corresponding client to feed back at least one first access request in a preset time period, the N pieces of inquiry information correspond to the N clients one to one, the termination time of the preset time period is the current system time, and the duration of the preset time period is less than or equal to a first threshold;
and the reverse proxy server receives at least one first access request sent by each client according to the corresponding inquiry information of the client, and obtains the M first access requests sent by the N clients.
The reverse proxy server and the N clients have a connection relationship, that is, the reverse proxy server may send query information to each of the N clients, and each of the clients may also send at least one first access request to the reverse proxy server.
The first threshold may be user-defined or reverse proxy server-defined, for example, the first threshold may be 1 s.
102: and calling a pre-stored load balancing strategy by the reverse proxy server, wherein the load balancing strategy is used for reasonably distributing the M first access requests to P webpage servers, P is an integer larger than 1, and P is an integer smaller than N.
Load Balance means that the Load Balance is shared by a plurality of operation units to be executed, such as a Web server, an FTP server, an enterprise key application server and other key task servers, so as to complete work tasks together.
The load balancing strategy comprises a first load balancing strategy and a second load balancing strategy, and the first load balancing strategy and the second load balancing strategy are stored in the reverse proxy server in advance.
In the embodiment of the application, P is generally set to be 3-5.
In one possible example, the reverse proxy server invokes a pre-stored load balancing policy, comprising:
the reverse proxy server acquires a load balancing strategy called at the kth time, wherein the load balancing strategy called at the kth time is a first load balancing strategy or a second load balancing strategy;
if the load balancing strategy invoked for the kth time is the first load balancing strategy, the reverse proxy server determines the load balancing strategy invoked for the (k +1) th time to be the second load balancing strategy;
and if the load balancing strategy invoked for the k time is the second load balancing strategy, the reverse proxy server determines the load balancing strategy invoked for the (k +1) th time to be the first load balancing strategy.
In one possible example, the reverse proxy server invokes a pre-stored load balancing policy, comprising:
determining whether the current system time is in a first time period;
if the current system moment is in a first time interval, the reverse proxy server determines that the load balancing strategy is a first load balancing strategy;
and if the current system time is not in the first time interval, the reverse proxy server determines that the load balancing strategy is the second load balancing strategy.
The first time period may be user-defined or user-defined by the reverse proxy server, and may be 0: 00 to 12:00, and can be 12:00 to 24: 00.
103: and the reverse proxy server determines a web server corresponding to each first access request in the M first access requests according to the load balancing strategy.
In one possible example, the load balancing policy includes a first load balancing policy and a second load balancing policy, and the reverse proxy server determines, according to the load balancing policy, a web server corresponding to each of the M first access requests, including:
under the condition that the load balancing strategy is the first load balancing strategy, the reverse proxy server acquires an access IP corresponding to each first access request to obtain M access IPs corresponding to the M first access requests;
the reverse proxy server divides the M first access requests according to the M access IPs to obtain Q first access request sets corresponding to the M first access requests, each first access request set comprises at least one first access request, at least one access IP corresponding to the at least one first access request belongs to the same access IP section, Q is an integer larger than 1, and Q is an integer smaller than or equal to M;
the reverse proxy server determines the number of the first access requests included in each first access request set to obtain Q first numbers corresponding to the Q first access request sets;
the reverse proxy server obtains the number of first access requests corresponding to each web server to obtain the number of P first access requests corresponding to the P web servers, wherein each first access request number is the maximum number of access requests which can be processed by the corresponding web server within a preset time length, and the preset time length is less than or equal to a second threshold value;
the reverse proxy server calls a first pre-stored allocation strategy, wherein the first allocation strategy is used for reasonably allocating the Q first access request sets to the P webpage servers;
and the reverse proxy server determines a web server corresponding to each first access request set according to the first distribution strategy, the Q first quantities and the P first access request quantities.
Specifically, the embodiment of the reverse proxy server obtaining the first access request number corresponding to each web server may be: acquiring a first weight corresponding to an mth webpage server, wherein the mth webpage server is one of P webpage servers; determining the first access request quantity corresponding to the first weight according to the mapping relation between the weight and the first access request quantity; determining the number of first access requests corresponding to the first weight as the number of first access requests corresponding to the mth web server; and (P-1) webpage servers except the mth webpage server at the P webpage servers are subjected to the same operation, so that the first access request quantity corresponding to each webpage server in the (P-1) webpage servers is obtained.
The second threshold may be user-defined or reverse proxy server-defined, for example, the second threshold may be 1 s.
In one possible example, the dividing, by the reverse proxy server, the M first access requests according to the M access IPs to obtain Q first access request sets corresponding to the M first access requests includes:
the reverse proxy server acquires a subnet mask corresponding to each access IP to obtain M subnet masks corresponding to the M access IPs, wherein each subnet mask corresponds to a first access request;
if the subnet mask i and the subnet mask j belong to the same subnet mask segment, the reverse proxy server determines that the access IP corresponding to the subnet mask i and the access IP corresponding to the subnet mask j belong to the same access IP segment, and the subnet mask i and the subnet mask j are both one of the M subnet masks;
the reverse proxy server divides the first access request corresponding to the subnet mask i and the first access request corresponding to the subnet mask j into the same first access request set;
and the reverse proxy server executes the same operation on (M-2) subnet masks except the subnet mask i and the subnet mask j in the M subnet masks to obtain the Q first access request sets corresponding to the M first access requests.
The subnet mask (subnet mask) is also called network mask, address mask, which is a kind of bit mask used to indicate which bit identifiers of an IP address are the subnet where the host is located, and which bit identifiers are the host. The subnet mask cannot exist alone and it must be used in conjunction with the IP address. The subnet mask is a 32-bit address.
The subnet mask segment can be user-defined or reverse proxy server-defined, and the subnet mask segment is pre-stored in the reverse proxy server.
In one possible example, the reverse proxy server determining, according to the first allocation policy, the Q first numbers and the P first access request numbers, a web server corresponding to each first access request set, includes:
the reverse proxy server sequences the P webpage servers once according to the sequence of the P first access requests from large to small in number to obtain a first webpage server sequence corresponding to the P webpage servers;
when P is less than Q and less than 2P, the reverse proxy server sorts the Q first access request sets according to the sequence of the Q first access request sets from large to small to obtain first set sequences corresponding to the Q first access request sets;
the reverse proxy server divides the first set sequence into a second set sequence and a third set sequence, wherein the second set sequence comprises P first access request sets, and the third set sequence comprises (Q-P) first access request sets;
the reverse proxy server determines a web server corresponding to each of the P first access request sets included in the second set sequence, and the position of each of the P first access request sets included in the second set sequence is the same as the position of the corresponding web server in the first web server sequence;
the reverse proxy server obtains the first remaining access request quantity corresponding to each web server to obtain P first remaining access request quantities corresponding to the P web servers;
the reverse proxy server performs secondary sequencing on the P webpage servers according to the sequence of the P first residual access request numbers from large to small to obtain a second webpage server sequence corresponding to the P webpage servers;
the reverse proxy server determines a web server corresponding to each of the (Q-P) first access request sets included in the third set sequence, and the position of each of the (Q-P) first access request sets included in the third set sequence is the same as the position of the corresponding web server in the second web server sequence.
The average value of the P first numbers corresponding to the P first access request sets included in the second set sequence is larger than the average value of the (Q-P) first numbers corresponding to the (Q-P) first access request sets included in the third set sequence.
Specifically, the implementation manner of obtaining the number of the first remaining access requests corresponding to each web server by the reverse proxy server to obtain the number of the P first remaining access requests corresponding to the P web servers may be: acquiring the number of first access requests corresponding to an nth webpage server, wherein the nth webpage server is one of P webpage servers; acquiring a first quantity corresponding to a first access request set corresponding to an nth webpage server; determining the difference value between the first access request quantity corresponding to the nth webpage server and the first quantity corresponding to the first access request set corresponding to the nth webpage server as the first residual access request quantity corresponding to the nth webpage server; and (P-1) webpage servers except the nth webpage server execute the same operation to obtain (P-1) first residual access request quantity corresponding to the (P-1) webpage servers.
When Q is less than or equal to P or Q is greater than or equal to 2P, the embodiment of determining the web server corresponding to each first access request set according to the first allocation policy, Q first numbers and P first access request numbers may refer to the embodiment of determining the web server corresponding to each first access request set according to the first allocation policy, Q first numbers and P first access request numbers when P < Q < 2P, which will not be described herein.
For example, as shown in fig. 1B, assuming that M is 100 and P is 5, the first web server sequence is: web server 2 (200 number of first access requests) -web server 4 (180 number of first access requests) -web server 3 (160 number of first access requests) -web server 5 (150 number of first access requests) -web server 1 (145 number of first access requests), reverse proxy server divides 100 first access requests into 8 first access request sets, which are set 1(20 first access requests), set 2(8 first access requests), set 3(16 first access requests), set 4(17 first access requests), set 5(9 first access requests), set 6(14 first access requests), set 7(5 first access requests) and set 8(11 first access requests), respectively, sorts the 8 first access request sets, obtaining a first set sequence as follows: set 1-set 4-set 3-set 6-set 8-set 5-set 2-set 7, dividing the first set sequence into a second set sequence (set 1-set 4-set 3-set 6-set 8) and a third set sequence (set 5-set 2-set 7); determining that the set 1 corresponds to the web server 2, the set 4 corresponds to the web server 4, the set 3 corresponds to the web server 3, the set 6 corresponds to the web server 5, the set 8 corresponds to the web server 1, and the second web server sequence is as follows: web server 2 (first remaining number of access requests is 180) -web server 4 (first remaining number of access requests is 163) -web server 3 (first remaining number of access requests is 144) -web server 5 (first remaining number of access requests is 136) -web server 1 (first remaining number of access requests is 134); and determining that the set 5 corresponds to the web server 2, the set 2 corresponds to the web server 4, and the set 7 corresponds to the web server 3.
As can be seen, in this example, the reverse proxy server divides the M first access requests into Q first access request sets according to M access IPs corresponding to the M first access requests; the Q first access request sets are sequenced according to the sequence of the Q first numbers corresponding to the Q first access request sets from large to small to obtain a first set sequence; when P < Q < 2P, dividing the first set sequence into a second set sequence comprising P first access request sets and a third set sequence comprising (Q-P) first access request sets; determining a web server corresponding to each first access request set in the P first access request sets included in the second set sequence; performing secondary sequencing on the P first residual access requests according to the sequence of the quantity of the P first residual access requests corresponding to the P webpage servers from large to small to obtain a second webpage server sequence; and determining the web page server corresponding to each first access request set in the (Q-P) first access request sets included in the third set sequence. Compared with the method that the access requests are distributed only according to the weight corresponding to the webpage server, the weight is in direct proportion to the number of the access requests, the method and the device reasonably distribute the M first access requests to the P webpage servers through the first load balancing strategy, and therefore the method and the device are beneficial to improving the efficiency of server load balancing.
In one possible example, the load balancing policy includes a first load balancing policy and a second load balancing policy, and the reverse proxy server determines, according to the load balancing policy, a web server corresponding to each of the M first access requests, including:
under the condition that the load balancing policy is the second load balancing policy, the reverse proxy server obtains R second access requests and S third access requests which are included in the M first access requests, wherein each second access request includes cookie information, and each third access request does not include cookie information;
the reverse proxy server acquires route parameters corresponding to each second access request to obtain R route parameters corresponding to the R second access requests;
the reverse proxy server divides the R second access requests according to the R route parameters to obtain T second access request sets corresponding to the R second access requests, each second access request set comprises at least one second access request, at least one route parameter corresponding to the at least one second access request is the same, T is an integer larger than 1, and T is an integer smaller than M;
the reverse proxy server determines a webpage server corresponding to each second access request set in the T second access request sets according to the mapping relation between the route parameter and the webpage server;
the reverse proxy server calls a pre-stored second distribution strategy, wherein the second distribution strategy is used for reasonably distributing the S third access requests to the P webpage servers;
and the reverse proxy server determines a web server corresponding to each third access request in the S third access requests according to the second distribution strategy.
Where cookie refers to data information stored on the user's local terminal and route refers to the purpose for displaying, manually adding and modifying routing table entries.
In one possible example, the reverse proxy server determining, according to the second allocation policy, a web server corresponding to each of the S third access requests includes:
the reverse proxy server acquires the second residual access request quantity corresponding to each webpage server to obtain P second residual access request quantities corresponding to the P webpage servers;
the reverse proxy server sorts the P webpage servers according to the sequence of the number of the P second residual access requests from large to small to obtain a third webpage server sequence corresponding to the P webpage servers;
the reverse proxy server divides the S third access requests into P third access request sets according to the ratio corresponding to the number of the P second remaining access requests;
the reverse proxy server determines the number of the third access requests included in each third access request set to obtain P second numbers corresponding to the P third access request sets;
the reverse proxy server sorts the P third access request sets according to the number of the P second access request sets from large to small to obtain a fourth set sequence corresponding to the P third access request sets;
and the reverse proxy server determines a web server corresponding to each third access request set, wherein the position of each third access request set in the P third access request sets in the fourth set sequence is the same as the position of the corresponding web server in the third web server sequence.
The mapping relationship between the route parameter and the web server is shown in the following table 1:
TABLE 1
route parameter Web page server
First route value Web server 1
Second route value Web server 2
Third route value Web server 3
...... ......
Specifically, the embodiment of obtaining the number of the second remaining access requests corresponding to each web server by the reverse proxy server to obtain the number of the P second remaining access requests corresponding to the P web servers may be: acquiring the number of first access requests corresponding to a P-th web server, wherein the P-th web server is one of P web servers; acquiring a third quantity corresponding to at least one second access request included in a second access request set corresponding to the p-th webpage server; determining the difference value between the first access request quantity corresponding to the p-th webpage server and the third quantity corresponding to the second access request set corresponding to the p-th webpage server as the second residual access request quantity corresponding to the p-th webpage server; and (P-1) webpage servers except the P-th webpage server execute the same operation to obtain (P-1) second residual access request quantity corresponding to the (P-1) webpage servers.
For example, as shown in fig. 1C, it is assumed that M is 115, P is 5, the number of first access requests corresponding to the web server 2 is 217, the number of first access requests corresponding to the web server 4 is 180, the number of first access requests corresponding to the web server 3 is 162, the number of first access requests corresponding to the web server 5 is 147, the number of first access requests corresponding to the web server 1 is 140, the reverse proxy server obtains 36 second access requests and 79 third access requests included in the 115 first access requests, divides the 36 second access requests into 3 second access request sets, which are set 9(17 second access requests), set 10(12 second access requests), and set 11(7 second access requests), respectively; the reverse proxy server determines that the set 9 corresponds to the web server 2, the set 10 corresponds to the web server 3, and the set 11 corresponds to the web server 5; the third web server sequence is: web server 2 (second remaining number of access requests is 200) -web server 4 (second remaining number of access requests is 180) -web server 3 (second remaining number of access requests is 150) -web server 5 (second remaining number of access requests is 140) -web server 1 (second remaining number of access requests is 140); the ratio of the 5 second remaining access numbers is 20: 18:15:14: 14; dividing the 79 third access requests into 5 third access request sets, which are respectively as follows: set 12(18 third access requests), set 13(14 third access requests), set 14(15 third access requests), set 15(20 third access requests), and set 16(14 third access requests); sequencing the 5 third access request sets to obtain a fourth set sequence as follows: set 15-set 12-set 14-set 16-set 13; the reverse proxy server determines that the set 15 corresponds to the web server 2, the set 12 corresponds to the web server 4, the set 14 corresponds to the web server 3, the set 16 corresponds to the web server 5, and the set 13 corresponds to the web server 1.
As can be seen, in this example, the reverse proxy server obtains R second access requests and S third access requests included in the M first access requests; dividing the R second access requests into T second access request sets according to the R route parameters corresponding to the R second access requests; determining a web server corresponding to each second access request set in the T second access request sets according to the mapping relation between the route parameter and the web server; sequencing the P webpage servers according to the sequence of the P second residual access request numbers corresponding to the P webpage servers from large to small to obtain a third webpage server sequence; dividing S third access requests into P third access request sets according to the ratio corresponding to the number of the P second remaining access requests; sequencing the P third access request sets according to P second quantities corresponding to the P third access request sets to obtain a fourth set sequence; and determining the web page server corresponding to each third access request set. Compared with the method that the access requests are distributed only according to the weight corresponding to the webpage server, the weight is in direct proportion to the number of the access requests, the M first access requests are reasonably distributed to the P webpage servers through the second load balancing strategy, and therefore the method is beneficial to improving the efficiency of server load balancing.
104: and the reverse proxy server forwards each first access request to the corresponding webpage server.
It can be seen that, in the embodiment of the present application, the reverse proxy server obtains M first access requests sent by N clients, determines, according to a pre-stored load balancing policy, a web server corresponding to each first access request in the M first access requests, and forwards each first access request to its corresponding web server. Compared with the method that the access requests are distributed only according to the weight corresponding to the webpage server, the weight is in direct proportion to the number of the access requests, the method and the device reasonably distribute the M first access requests to the P webpage servers through the load balancing strategy, and therefore the method and the device are beneficial to improving the efficiency of server load balancing.
Referring to fig. 2, fig. 2 is a schematic flow chart of another server load balancing method provided in the embodiment of the present application, which is consistent with the embodiment shown in fig. 1A, where the server load balancing method includes steps 201 and 213 as follows:
201: the reverse proxy server obtains M first access requests sent by N clients, each client corresponds to at least one first access request, N is an integer larger than 1, and M is an integer larger than or equal to N.
202: and calling a first pre-stored load balancing strategy by the reverse proxy server, wherein the first load balancing strategy is used for reasonably distributing the M first access requests to P webpage servers, P is an integer larger than 1, and P is an integer smaller than N.
203: and the reverse proxy server acquires the access IP corresponding to each first access request to obtain M access IPs corresponding to the M first access requests.
204: the reverse proxy server divides the M first access requests according to the M access IPs to obtain Q first access request sets corresponding to the M first access requests, each first access request set comprises at least one first access request, at least one access IP corresponding to the at least one first access request belongs to the same access IP section, Q is an integer larger than 1, and Q is an integer smaller than or equal to M.
205: and the reverse proxy server determines the number of the first access requests included in each first access request set to obtain Q first numbers corresponding to the Q first access request sets.
206: the reverse proxy server obtains the number of first access requests corresponding to each web server to obtain the number of P first access requests corresponding to the P web servers, wherein each first access request number is the maximum number of access requests which can be processed by the corresponding web server within a preset time length, and the preset time length is less than or equal to a second threshold value.
207: and the reverse proxy server sequences the P webpage servers once according to the sequence of the P first access requests from large to small in number to obtain a first webpage server sequence corresponding to the P webpage servers.
208: and when the P is less than Q and less than 2P, the reverse proxy server sorts the Q first access request sets according to the sequence of the Q first access request sets from large to small to obtain first set sequences corresponding to the Q first access request sets.
209: the reverse proxy server divides the first set sequence into a second set sequence and a third set sequence, wherein the second set sequence comprises P first access request sets, and the third set sequence comprises (Q-P) first access request sets.
210: the reverse proxy server determines a web server corresponding to each of the P first access request sets included in the second set sequence, and the position of each of the P first access request sets included in the second set sequence is the same as the position of its corresponding web server in the first web server sequence.
211: the reverse proxy server obtains the first remaining access request quantity corresponding to each web server, and obtains the P first remaining access request quantities corresponding to the P web servers.
212: and the reverse proxy server performs secondary sequencing on the P webpage servers according to the sequence of the P first residual access request numbers from large to small to obtain a second webpage server sequence corresponding to the P webpage servers.
213: the reverse proxy server determines a web server corresponding to each of the (Q-P) first access request sets included in the third set sequence, and the position of each of the (Q-P) first access request sets included in the third set sequence is the same as the position of the corresponding web server in the second web server sequence.
It should be noted that, the specific implementation of the steps of the method shown in fig. 2 can refer to the specific implementation described in the above method, and will not be described here.
Consistent with the embodiments shown in fig. 1A and fig. 2, please refer to fig. 3, fig. 3 is a schematic flow chart of another server load balancing method provided in the embodiments of the present application, where the server load balancing method includes steps 301 and 312 as follows:
301: the reverse proxy server obtains M first access requests sent by N clients, each client corresponds to at least one first access request, N is an integer larger than 1, and M is an integer larger than or equal to N.
302: and calling a pre-stored second load balancing strategy by the reverse proxy server, wherein the second load balancing strategy is used for reasonably distributing the M first access requests to P webpage servers, P is an integer larger than 1, and P is an integer smaller than N.
303: and the reverse proxy server acquires R second access requests and S third access requests which are included by the M first access requests, wherein each second access request comprises cookie information, and each third access request does not comprise the cookie information.
304: and the reverse proxy server acquires the route parameter corresponding to each second access request to obtain R route parameters corresponding to the R second access requests.
305: the reverse proxy server divides the R second access requests according to the R route parameters to obtain T second access request sets corresponding to the R second access requests, each second access request set comprises at least one second access request, at least one route parameter corresponding to the at least one second access request is the same, T is an integer larger than 1, and T is an integer smaller than M.
306: and the reverse proxy server determines the webpage server corresponding to each second access request set in the T second access request sets according to the mapping relation between the route parameter and the webpage server.
307: and the reverse proxy server acquires the second residual access request quantity corresponding to each webpage server to obtain P second residual access request quantities corresponding to the P webpage servers.
308: and the reverse proxy server sorts the P webpage servers according to the sequence of the P second residual access request numbers from large to small to obtain a third webpage server sequence corresponding to the P webpage servers.
309: and the reverse proxy server divides the S third access requests into P third access request sets according to the ratio corresponding to the P second residual access request quantities.
310: and the reverse proxy server determines the number of the third access requests included in each third access request set to obtain P second numbers corresponding to the P third access request sets.
311: and the reverse proxy server sorts the P third access request sets according to the number of the P second access request sets from large to small to obtain a fourth set sequence corresponding to the P third access request sets.
312: and the reverse proxy server determines a web server corresponding to each third access request set, wherein the position of each third access request set in the P third access request sets in the fourth set sequence is the same as the position of the corresponding web server in the third web server sequence.
It should be noted that, the specific implementation of the steps of the method shown in fig. 3 can refer to the specific implementation described in the above method, and will not be described here.
Referring to fig. 4, fig. 4 is a block diagram of functional units of a server load balancing apparatus according to an embodiment of the present application, where the server load balancing apparatus 400 includes:
an obtaining unit 401, configured to obtain M first access requests sent by N clients, where each client corresponds to at least one first access request, N is an integer greater than 1, and M is an integer greater than or equal to N;
a calling unit 402, configured to call a pre-stored load balancing policy, where the load balancing policy is used to reasonably allocate the M first access requests to P web servers, P is an integer greater than 1, and P is an integer smaller than N;
a determining unit 403, configured to determine, according to the load balancing policy, a web server corresponding to each first access request in the M first access requests;
a forwarding unit 404, configured to forward each first access request to its corresponding web server.
It can be seen that, in the embodiment of the present application, M first access requests sent by N clients are obtained, a web server corresponding to each first access request in the M first access requests is determined according to a pre-stored load balancing policy, and each first access request is forwarded to its corresponding web server. Compared with the method that the access requests are distributed only according to the weight corresponding to the webpage server, the weight is in direct proportion to the number of the access requests, the method and the device reasonably distribute the M first access requests to the P webpage servers through the load balancing strategy, and therefore the method and the device are beneficial to improving the efficiency of server load balancing.
In one possible example, in terms of acquiring M first access requests sent by N clients, the acquiring unit 401 is specifically configured to:
sending N pieces of inquiry information to the N clients, wherein each piece of inquiry information is used for indicating the corresponding client to feed back at least one first access request in a preset time period, the N pieces of inquiry information correspond to the N clients one to one, the termination time of the preset time period is the current system time, and the duration of the preset time period is less than or equal to a first threshold;
and receiving at least one first access request sent by each client according to the corresponding inquiry information of the client, and obtaining the M first access requests sent by the N clients.
In a possible example, in terms of determining, according to the load balancing policy, a web server corresponding to each first access request in the M first access requests, the determining unit 403 is specifically configured to:
under the condition that the load balancing strategy is the first load balancing strategy, acquiring an access IP corresponding to each first access request to obtain M access IPs corresponding to the M first access requests;
dividing the M first access requests according to the M access IPs to obtain Q first access request sets corresponding to the M first access requests, wherein each first access request set comprises at least one first access request, at least one access IP corresponding to at least one first access request belongs to the same access IP section, Q is an integer larger than 1, and Q is an integer smaller than or equal to M;
determining the number of the first access requests included in each first access request set to obtain Q first numbers corresponding to the Q first access request sets;
acquiring a first access request quantity corresponding to each web server to obtain P first access request quantities corresponding to the P web servers, wherein each first access request quantity is the maximum access request quantity which can be processed by the corresponding web server within a preset time length, and the preset time length is less than or equal to a second threshold value;
calling a pre-stored first allocation strategy, wherein the first allocation strategy is used for reasonably allocating the Q first access request sets to the P webpage servers;
and determining the web server corresponding to each first access request set according to the first distribution strategy, the Q first quantities and the P first access request quantities.
In a possible example, in terms of dividing the M first access requests according to the M access IPs to obtain Q first access request sets corresponding to the M first access requests, the determining unit 403 is specifically configured to:
acquiring a subnet mask corresponding to each access IP to obtain M subnet masks corresponding to the M access IPs, wherein each subnet mask corresponds to a first access request;
if the subnet mask i and the subnet mask j belong to the same subnet mask segment, determining that the access IP corresponding to the subnet mask i and the access IP corresponding to the subnet mask j belong to the same access IP segment, wherein the subnet mask i and the subnet mask j are both one of the M subnet masks;
dividing the first access request corresponding to the subnet mask i and the first access request corresponding to the subnet mask j into the same first access request set;
and performing the same operation on (M-2) subnet masks except the subnet mask i and the subnet mask j in the M subnet masks to obtain the Q first access request sets corresponding to the M first access requests.
In a possible example, in terms of determining, according to the first allocation policy, the Q first numbers and the P first access request numbers, a web server corresponding to each first access request set, the determining unit 403 is specifically configured to:
sequencing the P webpage servers once according to the sequence of the quantity of the P first access requests from large to small to obtain a first webpage server sequence corresponding to the P webpage servers;
when P is less than Q and less than 2P, sequencing the Q first access request sets according to the sequence of the Q first numbers from large to small to obtain first set sequences corresponding to the Q first access request sets;
dividing the first sequence of sets into a second sequence of sets comprising P first access request sets and a third sequence of sets comprising (Q-P) first access request sets;
determining a web server corresponding to each of the P first access request sets included in the second set sequence, where the position of each of the P first access request sets included in the second set sequence is the same as the position of its corresponding web server in the first web server sequence;
acquiring the number of first residual access requests corresponding to each webpage server to obtain the number of P first residual access requests corresponding to the P webpage servers;
performing secondary sequencing on the P webpage servers according to the sequence of the P first residual access request numbers from large to small to obtain a second webpage server sequence corresponding to the P webpage servers;
determining a web server corresponding to each of the (Q-P) first access request sets included in the third sequence of sets, wherein the position of each of the (Q-P) first access request sets included in the third sequence of sets is the same as the position of its corresponding web server in the second sequence of web servers.
In a possible example, in terms of determining, according to the load balancing policy, a web server corresponding to each first access request in the M first access requests, the determining unit 403 is specifically configured to:
under the condition that the load balancing policy is the second load balancing policy, acquiring R second access requests and S third access requests which are included in the M first access requests, wherein each second access request includes cookie information, and each third access request does not include cookie information;
acquiring route parameters corresponding to each second access request to obtain R route parameters corresponding to the R second access requests;
dividing the R second access requests according to the R route parameters to obtain T second access request sets corresponding to the R second access requests, wherein each second access request set comprises at least one second access request, at least one route parameter corresponding to the at least one second access request is the same, T is an integer larger than 1, and T is an integer smaller than M;
determining a web server corresponding to each second access request set in the T second access request sets according to the mapping relation between the route parameter and the web server;
calling a pre-stored second distribution strategy, wherein the second distribution strategy is used for reasonably distributing the S third access requests to the P webpage servers;
and determining a web server corresponding to each third access request in the S third access requests according to the second allocation policy.
In a possible example, in terms of determining, according to the second allocation policy, a web server corresponding to each of the S third access requests, the determining unit 403 is specifically configured to:
acquiring the number of second residual access requests corresponding to each webpage server to obtain the number of P second residual access requests corresponding to the P webpage servers;
sequencing the P webpage servers according to the sequence of the number of the P second residual access requests from large to small to obtain a third webpage server sequence corresponding to the P webpage servers;
dividing the S third access requests into P third access request sets according to the ratio corresponding to the number of the P second remaining access requests;
determining the number of the third access requests included in each third access request set to obtain P second numbers corresponding to the P third access request sets;
sequencing the P third access request sets according to the number of the P second numbers from large to small to obtain a fourth set sequence corresponding to the P third access request sets;
and determining a web server corresponding to each third access request set, wherein the position of each third access request set in the P third access request sets in the fourth set sequence is the same as the position of the corresponding web server in the third web server sequence.
Consistent with the embodiments shown in fig. 1A, fig. 2 and fig. 3, please refer to fig. 5, fig. 5 is a schematic structural diagram of a server provided in an embodiment of the present application, where the server includes a processor, a memory, a communication interface, and one or more programs, the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for performing the following steps:
obtaining M first access requests sent by N clients, wherein each client corresponds to at least one first access request, N is an integer greater than 1, and M is an integer greater than or equal to N;
calling a pre-stored load balancing strategy, wherein the load balancing strategy is used for reasonably distributing the M first access requests to P webpage servers, P is an integer larger than 1, and P is an integer smaller than N;
determining a web server corresponding to each first access request in the M first access requests according to the load balancing strategy;
and forwarding each first access request to the corresponding webpage server.
It can be seen that, in the embodiment of the present application, M first access requests sent by N clients are obtained, a web server corresponding to each first access request in the M first access requests is determined according to a pre-stored load balancing policy, and each first access request is forwarded to its corresponding web server. Compared with the method that the access requests are distributed only according to the weight corresponding to the webpage server, the weight is in direct proportion to the number of the access requests, the method and the device reasonably distribute the M first access requests to the P webpage servers through the load balancing strategy, and therefore the method and the device are beneficial to improving the efficiency of server load balancing.
In one possible example, in terms of obtaining M first access requests sent by N clients, the program includes instructions specifically for performing the following steps:
sending N pieces of inquiry information to the N clients, wherein each piece of inquiry information is used for indicating the corresponding client to feed back at least one first access request in a preset time period, the N pieces of inquiry information correspond to the N clients one to one, the termination time of the preset time period is the current system time, and the duration of the preset time period is less than or equal to a first threshold;
and receiving at least one first access request sent by each client according to the corresponding inquiry information of the client, and obtaining the M first access requests sent by the N clients.
In one possible example, in terms of determining, according to the load balancing policy, a web server corresponding to each of the M first access requests, the program includes instructions specifically configured to:
under the condition that the load balancing strategy is the first load balancing strategy, acquiring an access IP corresponding to each first access request to obtain M access IPs corresponding to the M first access requests;
dividing the M first access requests according to the M access IPs to obtain Q first access request sets corresponding to the M first access requests, wherein each first access request set comprises at least one first access request, at least one access IP corresponding to at least one first access request belongs to the same access IP section, Q is an integer larger than 1, and Q is an integer smaller than or equal to M;
determining the number of the first access requests included in each first access request set to obtain Q first numbers corresponding to the Q first access request sets;
acquiring a first access request quantity corresponding to each web server to obtain P first access request quantities corresponding to the P web servers, wherein each first access request quantity is the maximum access request quantity which can be processed by the corresponding web server within a preset time length, and the preset time length is less than or equal to a second threshold value;
calling a pre-stored first allocation strategy, wherein the first allocation strategy is used for reasonably allocating the Q first access request sets to the P webpage servers;
and determining the web server corresponding to each first access request set according to the first distribution strategy, the Q first quantities and the P first access request quantities.
In one possible example, in terms of dividing the M first access requests according to the M access IPs to obtain Q first access request sets corresponding to the M first access requests, the program includes instructions specifically configured to perform the following steps:
acquiring a subnet mask corresponding to each access IP to obtain M subnet masks corresponding to the M access IPs, wherein each subnet mask corresponds to a first access request;
if the subnet mask i and the subnet mask j belong to the same subnet mask segment, determining that the access IP corresponding to the subnet mask i and the access IP corresponding to the subnet mask j belong to the same access IP segment, wherein the subnet mask i and the subnet mask j are both one of the M subnet masks;
dividing the first access request corresponding to the subnet mask i and the first access request corresponding to the subnet mask j into the same first access request set;
and performing the same operation on (M-2) subnet masks except the subnet mask i and the subnet mask j in the M subnet masks to obtain the Q first access request sets corresponding to the M first access requests.
In one possible example, in determining the web server corresponding to each first access request set according to the first allocation policy, the Q first numbers and the P first access request numbers, the program includes instructions specifically configured to:
sequencing the P webpage servers once according to the sequence of the quantity of the P first access requests from large to small to obtain a first webpage server sequence corresponding to the P webpage servers;
when P is less than Q and less than 2P, sequencing the Q first access request sets according to the sequence of the Q first numbers from large to small to obtain first set sequences corresponding to the Q first access request sets;
dividing the first sequence of sets into a second sequence of sets comprising P first access request sets and a third sequence of sets comprising (Q-P) first access request sets;
determining a web server corresponding to each of the P first access request sets included in the second set sequence, where the position of each of the P first access request sets included in the second set sequence is the same as the position of its corresponding web server in the first web server sequence;
acquiring the number of first residual access requests corresponding to each webpage server to obtain the number of P first residual access requests corresponding to the P webpage servers;
performing secondary sequencing on the P webpage servers according to the sequence of the P first residual access request numbers from large to small to obtain a second webpage server sequence corresponding to the P webpage servers;
determining a web server corresponding to each of the (Q-P) first access request sets included in the third sequence of sets, wherein the position of each of the (Q-P) first access request sets included in the third sequence of sets is the same as the position of its corresponding web server in the second sequence of web servers.
In one possible example, in terms of determining, according to the load balancing policy, a web server corresponding to each of the M first access requests, the program includes instructions specifically configured to:
under the condition that the load balancing policy is the second load balancing policy, acquiring R second access requests and S third access requests which are included in the M first access requests, wherein each second access request includes cookie information, and each third access request does not include cookie information;
acquiring route parameters corresponding to each second access request to obtain R route parameters corresponding to the R second access requests;
dividing the R second access requests according to the R route parameters to obtain T second access request sets corresponding to the R second access requests, wherein each second access request set comprises at least one second access request, at least one route parameter corresponding to the at least one second access request is the same, T is an integer larger than 1, and T is an integer smaller than M;
determining a web server corresponding to each second access request set in the T second access request sets according to the mapping relation between the route parameter and the web server;
calling a pre-stored second distribution strategy, wherein the second distribution strategy is used for reasonably distributing the S third access requests to the P webpage servers;
and determining a web server corresponding to each third access request in the S third access requests according to the second allocation policy.
In one possible example, in determining, according to the second allocation policy, a web server corresponding to each of the S third access requests, the program includes instructions specifically configured to:
acquiring the number of second residual access requests corresponding to each webpage server to obtain the number of P second residual access requests corresponding to the P webpage servers;
sequencing the P webpage servers according to the sequence of the number of the P second residual access requests from large to small to obtain a third webpage server sequence corresponding to the P webpage servers;
dividing the S third access requests into P third access request sets according to the ratio corresponding to the number of the P second remaining access requests;
determining the number of the third access requests included in each third access request set to obtain P second numbers corresponding to the P third access request sets;
sequencing the P third access request sets according to the number of the P second numbers from large to small to obtain a fourth set sequence corresponding to the P third access request sets;
and determining a web server corresponding to each third access request set, wherein the position of each third access request set in the P third access request sets in the fourth set sequence is the same as the position of the corresponding web server in the third web server sequence.
Embodiments of the present application further provide a computer storage medium for storing a computer program, where the computer program is executed by a processor to implement part or all of the steps of any one of the methods described in the above method embodiments, and the computer includes a server.
Embodiments of the present application also provide a computer program product comprising a non-transitory computer readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps of any of the methods as described in the above method embodiments. The computer program product may be a software installation package, the computer comprising a server.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present application is not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required in this application.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus may be implemented in other manners. For example, the above-described embodiments of the apparatus are merely illustrative, and for example, the above-described division of the units is only one type of division of logical functions, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of some interfaces, devices or units, and may be an electric or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit may be stored in a computer readable memory if it is implemented in the form of a software functional unit and sold or used as a stand-alone product. Based on such understanding, the technical solution of the present application may be substantially implemented or a part of or all or part of the technical solution contributing to the prior art may be embodied in the form of a software product stored in a memory, and including several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the above-mentioned method of the embodiments of the present application. And the aforementioned memory comprises: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by associated hardware instructed by a program, which may be stored in a computer-readable memory, which may include: flash Memory disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.
The foregoing detailed description of the embodiments of the present application has been presented to illustrate the principles and implementations of the present application, and the above description of the embodiments is only provided to help understand the method and the core concept of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific implementation and application scope, and in view of the above, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A method for server load balancing, the method comprising:
sending N pieces of inquiry information to N clients, wherein each inquiry information is used for indicating the corresponding client to feed back at least one first access request in a preset time period, the N pieces of inquiry information correspond to the N clients one to one, the termination time of the preset time period is the current system time, and the duration of the preset time period is less than or equal to a first threshold;
receiving at least one first access request sent by each client for corresponding inquiry information of the client to obtain M first access requests sent by the N clients, wherein each client corresponds to at least one first access request, N is an integer greater than 1, and M is an integer greater than or equal to N;
calling a pre-stored second load balancing strategy, wherein the second load balancing strategy is used for reasonably distributing the M first access requests to P webpage servers, P is an integer larger than 1, and P is an integer smaller than N;
according to the second load balancing strategy, R second access requests and S third access requests which are included in the M first access requests are obtained, each second access request comprises cookie information, and each third access request does not comprise the cookie information;
acquiring route parameters corresponding to each second access request to obtain R route parameters corresponding to the R second access requests;
dividing the R second access requests according to the R route parameters to obtain T second access request sets corresponding to the R second access requests, wherein each second access request set comprises at least one second access request, at least one route parameter corresponding to the at least one second access request is the same, T is an integer larger than 1, and T is an integer smaller than M;
determining a web server corresponding to each second access request set in the T second access request sets according to the mapping relation between the route parameter and the web server;
calling a pre-stored second distribution strategy, wherein the second distribution strategy is used for reasonably distributing the S third access requests to the P webpage servers;
determining a web server corresponding to each of the S third access requests according to the second allocation policy;
and forwarding each first access request to the corresponding webpage server.
2. The method of claim 1, wherein determining, according to the second allocation policy, a web server to which each of the S third access requests corresponds comprises:
acquiring the number of second residual access requests corresponding to each webpage server to obtain the number of P second residual access requests corresponding to the P webpage servers;
sequencing the P webpage servers according to the sequence of the number of the P second residual access requests from large to small to obtain a third webpage server sequence corresponding to the P webpage servers;
dividing the S third access requests into P third access request sets according to the ratio corresponding to the number of the P second remaining access requests;
determining the number of the third access requests included in each third access request set to obtain P second numbers corresponding to the P third access request sets;
sequencing the P third access request sets according to the number of the P second numbers from large to small to obtain a fourth set sequence corresponding to the P third access request sets;
and determining a web server corresponding to each third access request set, wherein the position of each third access request set in the P third access request sets in the fourth set sequence is the same as the position of the corresponding web server in the third web server sequence.
3. A method for server load balancing, the method comprising:
sending N pieces of inquiry information to N clients, wherein each inquiry information is used for indicating the corresponding client to feed back at least one first access request in a preset time period, the N pieces of inquiry information correspond to the N clients one to one, the termination time of the preset time period is the current system time, and the duration of the preset time period is less than or equal to a first threshold;
receiving at least one first access request sent by each client for corresponding inquiry information of the client to obtain M first access requests sent by the N clients, wherein each client corresponds to at least one first access request, N is an integer greater than 1, and M is an integer greater than or equal to N;
calling a pre-stored first load balancing strategy, wherein the first load balancing strategy is used for reasonably distributing the M first access requests to P webpage servers, P is an integer larger than 1, and P is an integer smaller than N;
according to the first load balancing strategy, obtaining an access IP corresponding to each first access request, and obtaining M access IPs corresponding to the M first access requests;
dividing the M first access requests according to the M access IPs to obtain Q first access request sets corresponding to the M first access requests, wherein each first access request set comprises at least one first access request, at least one access IP corresponding to at least one first access request belongs to the same access IP section, Q is an integer larger than 1, and Q is an integer smaller than or equal to M;
determining the number of the first access requests included in each first access request set to obtain Q first numbers corresponding to the Q first access request sets;
acquiring a first access request quantity corresponding to each web server to obtain P first access request quantities corresponding to the P web servers, wherein each first access request quantity is the maximum access request quantity which can be processed by the corresponding web server within a preset time length, and the preset time length is less than or equal to a second threshold value;
calling a pre-stored first allocation strategy, wherein the first allocation strategy is used for reasonably allocating the Q first access request sets to the P webpage servers;
sequencing the P webpage servers once according to the sequence of the quantity of the P first access requests from large to small to obtain a first webpage server sequence corresponding to the P webpage servers;
when P is less than Q and less than 2P, sequencing the Q first access request sets according to the sequence of the Q first numbers from large to small to obtain first set sequences corresponding to the Q first access request sets;
dividing the first sequence of sets into a second sequence of sets comprising P first access request sets and a third sequence of sets comprising (Q-P) first access request sets;
determining a web server corresponding to each of the P first access request sets included in the second set sequence, where the position of each of the P first access request sets included in the second set sequence is the same as the position of its corresponding web server in the first web server sequence;
acquiring the number of first residual access requests corresponding to each webpage server to obtain the number of P first residual access requests corresponding to the P webpage servers;
performing secondary sequencing on the P webpage servers according to the sequence of the P first residual access request numbers from large to small to obtain a second webpage server sequence corresponding to the P webpage servers;
determining a web server corresponding to each of the (Q-P) first access request sets included in the third sequence of sets, wherein the position of each of the (Q-P) first access request sets included in the third sequence of sets is the same as the position of its corresponding web server in the second sequence of web servers.
4. The method according to claim 3, wherein the dividing the M first access requests according to the M access IPs to obtain Q first access request sets corresponding to the M first access requests includes;
acquiring a subnet mask corresponding to each access IP to obtain M subnet masks corresponding to the M access IPs, wherein each subnet mask corresponds to a first access request;
if the subnet mask i and the subnet mask j belong to the same subnet mask segment, determining that the access IP corresponding to the subnet mask i and the access IP corresponding to the subnet mask j belong to the same access IP segment, wherein the subnet mask i and the subnet mask j are both one of the M subnet masks;
dividing the first access request corresponding to the subnet mask i and the first access request corresponding to the subnet mask j into the same first access request set;
and performing the same operation on (M-2) subnet masks except the subnet mask i and the subnet mask j in the M subnet masks to obtain the Q first access request sets corresponding to the M first access requests.
5. An apparatus for server load balancing, the apparatus comprising:
an obtaining unit, configured to send N pieces of query information to N clients, where each query information is used to instruct a corresponding client to feed back at least one first access request in a preset time period, the N pieces of query information are in one-to-one correspondence with the N clients, a termination time of the preset time period is a current system time, and a duration of the preset time period is less than or equal to a first threshold; receiving at least one first access request sent by each client for corresponding inquiry information of the client to obtain M first access requests sent by the N clients, wherein each client corresponds to at least one first access request, N is an integer greater than 1, and M is an integer greater than or equal to N;
the calling unit is used for calling a prestored second load balancing strategy, the second load balancing strategy is used for reasonably distributing the M first access requests to P webpage servers, P is an integer larger than 1, and P is an integer smaller than N;
a determining unit, configured to obtain, according to the second load balancing policy, R second access requests and S third access requests that are included in the M first access requests, where each second access request includes cookie information and each third access request does not include cookie information; dividing the R second access requests according to the R route parameters to obtain T second access request sets corresponding to the R second access requests, wherein each second access request set comprises at least one second access request, at least one route parameter corresponding to the at least one second access request is the same, T is an integer larger than 1, and T is an integer smaller than M; determining a web server corresponding to each second access request set in the T second access request sets according to the mapping relation between the route parameter and the web server; calling a pre-stored second distribution strategy, wherein the second distribution strategy is used for reasonably distributing the S third access requests to the P webpage servers; determining a web server corresponding to each of the S third access requests according to the second allocation policy;
and the forwarding unit is used for forwarding each first access request to the corresponding webpage server.
6. The apparatus of claim 5, wherein, in determining the web server corresponding to each of the S third access requests according to the second allocation policy, the determining unit is configured to:
acquiring the number of second residual access requests corresponding to each webpage server to obtain the number of P second residual access requests corresponding to the P webpage servers;
sequencing the P webpage servers according to the sequence of the number of the P second residual access requests from large to small to obtain a third webpage server sequence corresponding to the P webpage servers;
dividing the S third access requests into P third access request sets according to the ratio corresponding to the number of the P second remaining access requests;
determining the number of the third access requests included in each third access request set to obtain P second numbers corresponding to the P third access request sets;
sequencing the P third access request sets according to the number of the P second numbers from large to small to obtain a fourth set sequence corresponding to the P third access request sets;
and determining a web server corresponding to each third access request set, wherein the position of each third access request set in the P third access request sets in the fourth set sequence is the same as the position of the corresponding web server in the third web server sequence.
7. An apparatus for server load balancing, the apparatus comprising:
an obtaining unit, configured to send N pieces of query information to N clients, where each query information is used to instruct a corresponding client to feed back at least one first access request in a preset time period, the N pieces of query information are in one-to-one correspondence with the N clients, a termination time of the preset time period is a current system time, and a duration of the preset time period is less than or equal to a first threshold; receiving at least one first access request sent by each client for corresponding inquiry information of the client to obtain M first access requests sent by the N clients, wherein each client corresponds to at least one first access request, N is an integer greater than 1, and M is an integer greater than or equal to N;
the calling unit is used for calling a prestored first load balancing strategy, wherein the first load balancing strategy is used for reasonably distributing the M first access requests to P webpage servers, P is an integer larger than 1, and P is an integer smaller than N;
a determining unit, configured to obtain, according to the first load balancing policy, an access IP corresponding to each first access request, and obtain M access IPs corresponding to the M first access requests; dividing the M first access requests according to the M access IPs to obtain Q first access request sets corresponding to the M first access requests, wherein each first access request set comprises at least one first access request, at least one access IP corresponding to at least one first access request belongs to the same access IP section, Q is an integer larger than 1, and Q is an integer smaller than or equal to M; determining the number of the first access requests included in each first access request set to obtain Q first numbers corresponding to the Q first access request sets; acquiring a first access request quantity corresponding to each web server to obtain P first access request quantities corresponding to the P web servers, wherein each first access request quantity is the maximum access request quantity which can be processed by the corresponding web server within a preset time length, and the preset time length is less than or equal to a second threshold value; calling a pre-stored first allocation strategy, wherein the first allocation strategy is used for reasonably allocating the Q first access request sets to the P webpage servers; sequencing the P webpage servers once according to the sequence of the quantity of the P first access requests from large to small to obtain a first webpage server sequence corresponding to the P webpage servers; when P is less than Q and less than 2P, sequencing the Q first access request sets according to the sequence of the Q first numbers from large to small to obtain first set sequences corresponding to the Q first access request sets; dividing the first sequence of sets into a second sequence of sets comprising P first access request sets and a third sequence of sets comprising (Q-P) first access request sets; determining a web server corresponding to each of the P first access request sets included in the second set sequence, where the position of each of the P first access request sets included in the second set sequence is the same as the position of its corresponding web server in the first web server sequence; acquiring the number of first residual access requests corresponding to each webpage server to obtain the number of P first residual access requests corresponding to the P webpage servers; performing secondary sequencing on the P webpage servers according to the sequence of the P first residual access request numbers from large to small to obtain a second webpage server sequence corresponding to the P webpage servers; determining a web server corresponding to each of the (Q-P) first access request sets included in the third sequence of sets, the position of each of the (Q-P) first access request sets included in the third sequence of sets being the same as the position of its corresponding web server in the second sequence of web servers;
and the forwarding unit is used for forwarding each first access request to the corresponding webpage server.
8. The apparatus according to claim 7, wherein the determining unit is configured to, in terms of dividing the M first access requests according to the M access IPs to obtain Q first access request sets corresponding to the M first access requests;
acquiring a subnet mask corresponding to each access IP to obtain M subnet masks corresponding to the M access IPs, wherein each subnet mask corresponds to a first access request;
if the subnet mask i and the subnet mask j belong to the same subnet mask segment, determining that the access IP corresponding to the subnet mask i and the access IP corresponding to the subnet mask j belong to the same access IP segment, wherein the subnet mask i and the subnet mask j are both one of the M subnet masks;
dividing the first access request corresponding to the subnet mask i and the first access request corresponding to the subnet mask j into the same first access request set;
and performing the same operation on (M-2) subnet masks except the subnet mask i and the subnet mask j in the M subnet masks to obtain the Q first access request sets corresponding to the M first access requests.
9. A server comprising a processor, memory, a communication interface, and one or more programs stored in the memory and configured to be executed by the processor, the programs comprising instructions for performing the method of any of claims 1-4.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium is used to store a computer program, which is executed by a processor to implement the method according to any of claims 1-4.
CN201910514178.0A 2019-06-14 2019-06-14 Server load balancing method and related equipment Active CN110311957B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201910514178.0A CN110311957B (en) 2019-06-14 2019-06-14 Server load balancing method and related equipment
PCT/CN2019/101956 WO2020248363A1 (en) 2019-06-14 2019-08-22 Load balancing method for server and related apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910514178.0A CN110311957B (en) 2019-06-14 2019-06-14 Server load balancing method and related equipment

Publications (2)

Publication Number Publication Date
CN110311957A CN110311957A (en) 2019-10-08
CN110311957B true CN110311957B (en) 2022-03-15

Family

ID=68075955

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910514178.0A Active CN110311957B (en) 2019-06-14 2019-06-14 Server load balancing method and related equipment

Country Status (2)

Country Link
CN (1) CN110311957B (en)
WO (1) WO2020248363A1 (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103401799A (en) * 2013-07-30 2013-11-20 曙光信息产业(北京)有限公司 Method and device for realizing load balance
CN104579996A (en) * 2013-10-17 2015-04-29 中国电信股份有限公司 Cluster load balancing method and system

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8180896B2 (en) * 2008-08-06 2012-05-15 Edgecast Networks, Inc. Global load balancing on a content delivery network
CN101677319A (en) * 2008-09-19 2010-03-24 华为技术有限公司 Method, apparatus and system for service access on the basis of XMPP protocol
US8769541B2 (en) * 2009-12-31 2014-07-01 Facebook, Inc. Load balancing web service by rejecting connections
CN103188163A (en) * 2011-12-31 2013-07-03 中国移动通信集团浙江有限公司 Load balancing method and device
CN105100260B (en) * 2012-03-31 2018-10-09 北京奇虎科技有限公司 A kind of method and device to be accessed by proxy server
CN104811503A (en) * 2015-05-21 2015-07-29 龙信数据(北京)有限公司 R statistical modeling system
CN109347947A (en) * 2018-10-15 2019-02-15 郑州云海信息技术有限公司 A kind of method of load balancing, name server and cluster nas server

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103401799A (en) * 2013-07-30 2013-11-20 曙光信息产业(北京)有限公司 Method and device for realizing load balance
CN104579996A (en) * 2013-10-17 2015-04-29 中国电信股份有限公司 Cluster load balancing method and system

Also Published As

Publication number Publication date
CN110311957A (en) 2019-10-08
WO2020248363A1 (en) 2020-12-17

Similar Documents

Publication Publication Date Title
CN107026907B (en) Load balancing method, load balancer and load balancing system
AU2017404110B2 (en) Agent allocation method and device, server, and storage medium
CN109327550B (en) Access request distribution method and device, storage medium and computer equipment
CN110086886B (en) Dynamic session holding method and device
CN104348798B (en) A kind of method, apparatus, dispatch server and system for distributing network
CN109672711B (en) Reverse proxy server Nginx-based http request processing method and system
CN109155994A (en) A kind of user face method for managing resource, user&#39;s veil member and control plane network element
CN108933829A (en) A kind of load-balancing method and device
CN107579924B (en) Flow allocation method and device
CN112825527A (en) Service node distribution method and device based on MEC and related server
CN110233866B (en) Load balancing method and load balancer
CN104796561A (en) Agent distribution method, CTI (Computer Telephony Integration) equipment, terminal and agent distribution system
CN110198267B (en) Traffic scheduling method, system and server
CN112769943A (en) Service processing method and device
CN110691042A (en) Resource allocation method and device
CN111385357B (en) Network resource management method and device, computer equipment and storage medium
US10645183B2 (en) Redirection of client requests to multiple endpoints
CN109413117B (en) Distributed data calculation method, device, server and computer storage medium
CN110311957B (en) Server load balancing method and related equipment
CN109582829B (en) Processing method, device, equipment and readable storage medium
CN103905324A (en) Dispatching and distributing method and system based on message five-element set
CN105871972A (en) Video resource distributed cathe method, device and system
CN104243587A (en) Load balancing method and system for message servers
CN112954084B (en) Edge computing processing method, network function example and edge service management and control center
CN110995890B (en) Domain name request scheduling method and device

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