WO2020248363A1 - 服务器负载均衡方法及相关设备 - Google Patents

服务器负载均衡方法及相关设备 Download PDF

Info

Publication number
WO2020248363A1
WO2020248363A1 PCT/CN2019/101956 CN2019101956W WO2020248363A1 WO 2020248363 A1 WO2020248363 A1 WO 2020248363A1 CN 2019101956 W CN2019101956 W CN 2019101956W WO 2020248363 A1 WO2020248363 A1 WO 2020248363A1
Authority
WO
WIPO (PCT)
Prior art keywords
access request
access
load balancing
web server
access requests
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.)
Ceased
Application number
PCT/CN2019/101956
Other languages
English (en)
French (fr)
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
Publication of WO2020248363A1 publication Critical patent/WO2020248363A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

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

Definitions

  • This application relates to the field of data processing technology, and in particular to a server load balancing method and related equipment.
  • the method of server load balancing is: the reverse proxy server only allocates access requests according to the weight corresponding to the web server, that is, the greater the weight of the web server, the more access requests are allocated to the web server. This approach leads to low server load balancing efficiency.
  • the embodiment of the application provides a server load balancing method and related equipment, which are used to improve the efficiency of server load balancing.
  • an embodiment of the present application provides a server load balancing method, the method including:
  • N is an integer greater than 1
  • M is an integer greater than or equal to N
  • the load balancing strategy is used to reasonably allocate the M first access requests to P web servers, where P is an integer greater than 1, and P is less than N Integer
  • an embodiment of the present application provides a server load balancing device, the device including:
  • An obtaining unit configured to obtain M first access requests sent by N clients, each client corresponding to at least one first access request, where N is an integer greater than 1, and M is greater than or equal to N Integer
  • the calling unit is used to call a pre-stored load balancing strategy, the load balancing strategy is used to reasonably allocate the M first access requests to P web servers, where P is an integer greater than 1, and P is An integer smaller than the N;
  • a determining unit configured to determine a web server corresponding to each of the M first access requests according to the load balancing policy
  • the forwarding unit is configured to forward each first access request to its corresponding web server.
  • embodiments of the present application provide a server, including 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.
  • the aforementioned program includes instructions for executing part or all of the steps in the method described in the first aspect of the embodiments of the present application.
  • an embodiment of the present application provides a computer-readable storage medium.
  • the above-mentioned computer-readable storage medium is used to store a computer program, and the above-mentioned computer program is executed by a processor to implement the method described in the first aspect of the embodiment of the present application. Part or all of the steps described in the method.
  • the reverse proxy server compared to only assigning access requests based on the weights corresponding to the web servers, in this embodiment of the application, the reverse proxy server reasonably allocates the M first access requests to the P web servers through a load balancing strategy. Helps improve the efficiency of server load balancing.
  • FIG. 1A is a schematic flowchart of a server load balancing method provided by an embodiment of the present application
  • FIG. 1B is a schematic diagram of determining a web server corresponding to a first access request set according to an embodiment of the present application
  • FIG. 1C is a schematic diagram of determining a web server corresponding to a second access request set and a third access request set according to an embodiment of the present application;
  • FIG. 2 is a schematic flowchart of another server load balancing method provided by an embodiment of the present application.
  • FIG. 3 is a block diagram of functional units of a server load balancing device provided by an embodiment of the present application.
  • Fig. 4 is a schematic structural diagram of a server provided by an embodiment of the present application.
  • Figure 1A is a schematic flowchart of a server load balancing method provided by an embodiment of the present application.
  • the execution body is a reverse proxy server.
  • the server load balancing method includes steps 101-104, which are specifically as follows:
  • the reverse proxy server is Nginx, which is a lightweight web server/reverse proxy server and email (IMAP/POP3) proxy server.
  • obtaining M first access requests sent by N clients includes:
  • N pieces of inquiry information are sent to the N clients, and each piece of inquiry information is used to instruct its corresponding client to feed back at least one first access request within a preset period of time.
  • the N pieces of inquiry information are related to the N clients.
  • One-to-one correspondence between terminals, the end 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;
  • At least one first access request sent by each client for its corresponding query information is received, and the M first access requests sent by the N clients are obtained.
  • the reverse proxy server has a connection relationship with N clients, that is, the reverse proxy server can send inquiry information to each of the N clients, and each client can also send at least one first access request. To the reverse proxy server.
  • the first threshold may be user-defined, for example, the first threshold may be 1s.
  • the load balancing strategy is used to reasonably allocate the M first access requests to P web servers, where P is an integer greater than 1, and P is less than the An integer of N.
  • Load Balance means to allocate to multiple operation units for execution, such as Web servers, FTP servers, enterprise key application servers, and other mission-critical servers, so as to jointly complete work tasks.
  • the load balancing strategy includes a first load balancing strategy and a second load balancing strategy, and the first load balancing strategy and the second load balancing strategy are pre-stored in the reverse proxy server.
  • P is generally set to 3 to 5.
  • call a pre-stored load balancing strategy including:
  • the load balancing strategy invoked for the kth time is the first load balancing strategy, determine that the load balancing strategy invoked for the (k+1)th time is the second load balancing strategy;
  • the load balancing strategy invoked for the kth time is the second load balancing strategy
  • the load balancing strategy invoked for the (k+1)th time is determined to be the first load balancing strategy.
  • call a pre-stored load balancing strategy including:
  • the load balancing strategy is determined to be the first load balancing strategy
  • the load balancing strategy is determined to be the second load balancing strategy.
  • the first time period can be user-defined, and the first time period can be from 0:00 to 12:00 or from 12:00 to 24:00.
  • the load balancing strategy includes a first load balancing strategy and a second load balancing strategy
  • the web server corresponding to each of the M first access requests is determined according to the load balancing strategy
  • the load balancing strategy is the first load balancing strategy, obtaining the access IP corresponding to each first access request, and obtaining M access IPs corresponding to the M first access requests;
  • the M first access requests are divided according to the M access IPs to obtain Q first access request sets corresponding to the M first access requests, and each first access request set includes at least one first access request set.
  • Access request, at least one access IP corresponding to the at least one first access request belongs to the same access IP segment, the Q is an integer greater than 1, and the Q is an integer less than or equal to the M;
  • the web server corresponding to each first access request set is determined according to the first allocation strategy, the Q first numbers, and the P first access request numbers.
  • the implementation manner for obtaining the number of first access requests corresponding to each web server may be: obtaining the first weight corresponding to the m-th web server, where the m-th web server is one of the P web servers; according to the weight and The mapping relationship of the first access request quantity determines the first access request quantity corresponding to the first weight; the first access request quantity corresponding to the first weight is determined as the first access request quantity corresponding to the mth web server; (P-1) web servers other than the m-th web server at the server perform the same operation to obtain the number of first access requests corresponding to each of the (P-1) web servers.
  • the second threshold may be user-defined, for example, the second threshold may be 1s.
  • 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:
  • the subnet mask i and the subnet mask j belong to the same subnet mask segment, it is determined 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,
  • the subnet mask i and the subnet mask j are both one of the M subnet masks;
  • subnet mask is also called network mask and address mask. It is used to indicate which bits of an IP address identify the subnet where the host is located, and which bits are the bit mask of the host. code.
  • the subnet mask cannot exist alone, 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, and the subnet mask segment is pre-stored in the reverse proxy server.
  • determining the web server corresponding to each first access request set according to the first allocation strategy, the Q first numbers, and the P first access request numbers includes:
  • the Q first access request sets are sorted according to the Q first number in descending order to obtain the first set corresponding to the Q first access request sets sequence;
  • the first set sequence into a second set sequence and a third set sequence
  • the second set sequence includes P first access request sets
  • the third set sequence includes (QP) first access request sets ;
  • the average value of the P first numbers corresponding to the P first access request sets included in the second set sequence is greater than the (QP) first numbers corresponding to the (QP) first access request sets included in the third set sequence average of.
  • obtaining the first remaining access request quantity corresponding to each web server, and obtaining the P first remaining access request quantity corresponding to P web servers may be implemented as follows: obtaining the first access request corresponding to the nth web server Number, the nth web server is one of the P web servers; obtain the first number corresponding to the first access request set corresponding to the nth web server; compare the first access request number corresponding to the nth web server with The difference of the first number corresponding to the first access request set is determined as the first remaining access request number corresponding to the nth web server; for P web servers except the nth web server (P-1) Each web server performs the same operation to obtain (P-1) first remaining access requests corresponding to (P-1) web servers.
  • FIG. 1B is a schematic diagram of determining the web server corresponding to the first access request set according to an embodiment of the present application.
  • M is 100 and P is 5
  • the first web server sequence is: Web server 2 (number of first access requests is 200)-Web server 4 (number of first access requests is 180)-Web server 3 (number of first access requests is 160)-Web server 5 (number of first access requests is 150 )-Web server 1 (the number of first access requests is 145)
  • the 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) Access request), set 7 (5 first access requests) and set 8 (11 first access requests), sort the 8 first access request sets, and get the first set sequence as: set 1-set 4 Set 3-set 6-set 8-set 5-set 2-set 7, divide the first set sequence into the second
  • the reverse proxy server reasonably allocates the M first access requests to P web servers through the first load balancing strategy, which helps Improve the efficiency of server load balancing.
  • the load balancing strategy includes a first load balancing strategy and a second load balancing strategy
  • the web server corresponding to each of the M first access requests is determined according to the load balancing strategy
  • each second access request and S third access requests included in the M first access requests are acquired, and each second access request is Including cookie information, each third access request does not include cookie information;
  • the R second access requests are divided 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 includes at least one second access request set. Access request, at least one route parameter corresponding to the at least one second access request is the same, the T is an integer greater than 1, and the T is an integer less than the M;
  • the web server corresponding to each third access request in the S third access requests is determined according to the second allocation strategy.
  • cookie refers to the data information stored on the user's local terminal
  • route refers to the display, manual addition, and modification of routing table items.
  • determining the web server corresponding to each third access request in the S third access requests according to the second allocation strategy includes:
  • mapping relationship between the route parameter and the web server is shown in Table 1 below:
  • obtaining the second remaining access request quantity corresponding to each web server, and obtaining the P second remaining access request quantity corresponding to P web servers may be implemented as follows: obtaining the first access request corresponding to the p-th web server
  • the p-th web server is one of the P web servers; the third number corresponding to at least one second access request included in the second access request set corresponding to the p-th web server is obtained; the p-th web server is The difference between the corresponding first access request quantity and the third quantity corresponding to the corresponding second access request set is determined as the second remaining access request quantity corresponding to the p-th web server; divide the p-th web server for P web servers
  • the other (P-1) web servers perform the same operation to obtain (P-1) second remaining access requests corresponding to (P-1) web servers.
  • FIG. 1C is a schematic diagram of determining the web server corresponding to the second access request set and the third access request set according to an embodiment of the present application.
  • M is 115
  • P is 5
  • the webpage The number of first access requests corresponding to server 2 is 217
  • the number of first access requests corresponding to web server 4 is 180
  • the number of first access requests corresponding to web server 3 is 162
  • the number of first access requests corresponding to web server 5 is 147
  • the number of first access requests corresponding to web server 1 is 140.
  • the reverse proxy server obtains 36 second access requests and 79 third access requests included in 115 first access requests, and divides the 36 second access requests into Three sets of second access requests, namely set 9 (17 second access requests), set 10 (12 second access requests) and set 11 (7 second access requests); the reverse proxy server determines set 9 Corresponding to web server 2, set 10 corresponds to web server 3, set 11 corresponds to web server 5; the sequence of the third web server is: web server 2 (the second remaining number of access requests is 200)-web server 4 (the second remaining number of access requests Is 180)-web server 3 (the second remaining number of access requests is 150)-web server 5 (the second remaining number of access requests is 140)-web server 1 (the second remaining number of access requests is 140); 5 second The ratio corresponding to the number of remaining visits is 20:18:15:14:14; the 79 third access requests are divided into 5 third access request sets, namely: 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 (
  • the reverse proxy server instead of only assigning access requests based on the weights corresponding to the web servers, in this example, the reverse proxy server reasonably distributes the M first access requests to P web servers through the second load balancing strategy, which helps Improve the efficiency of server load balancing.
  • the reverse proxy server compared to only assigning access requests based on the weights corresponding to the web servers, in this embodiment of the application, the reverse proxy server reasonably allocates the M first access requests to the P web servers through a load balancing strategy. Helps improve the efficiency of server load balancing.
  • FIG. 2 is a schematic flowchart of another server load balancing method provided by an embodiment of the present application.
  • the execution body is a reverse proxy server.
  • the server load balancing method Including steps 201-213, as follows:
  • the reverse proxy server obtains M first access requests sent by N clients, and each client corresponds to at least one first access request, where N is an integer greater than 1, and M is greater than or equal to An integer of N.
  • each first access request set includes at least one The first access request, at least one access IP corresponding to the at least one first access request belongs to the same access IP segment, the Q is an integer greater than 1, and the Q is an integer less than or equal to the M.
  • FIG. 3 is a block diagram of the functional unit composition of a server load balancing device provided by an embodiment of the present application.
  • the server load balancing device 300 includes:
  • the obtaining unit 301 is configured to obtain M first access requests sent by N clients, each client corresponding to at least one first access request, where N is an integer greater than 1, and M is greater than or equal to Integer of N;
  • the calling unit 302 is configured to call a pre-stored load balancing strategy, the load balancing strategy is used to reasonably allocate the M first access requests to P web servers, where P is an integer greater than 1, and P Is an integer less than the N;
  • the determining unit 303 is configured to determine a web server corresponding to each of the M first access requests according to the load balancing policy;
  • the forwarding unit 304 is configured to forward each first access request to its corresponding web server.
  • the foregoing obtaining unit 301 is specifically configured to:
  • N pieces of inquiry information are sent to the N clients, and each piece of inquiry information is used to instruct its corresponding client to feed back at least one first access request within a preset period of time.
  • the N pieces of inquiry information are related to the N clients.
  • One-to-one correspondence between terminals, the end 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;
  • At least one first access request sent by each client for its corresponding query information is received, and the M first access requests sent by the N clients are obtained.
  • the above determining unit 303 is specifically configured to:
  • the load balancing strategy is the first load balancing strategy, obtaining the access IP corresponding to each first access request, and obtaining M access IPs corresponding to the M first access requests;
  • the M first access requests are divided according to the M access IPs to obtain Q first access request sets corresponding to the M first access requests, and each first access request set includes at least one first access request set.
  • Access request, at least one access IP corresponding to the at least one first access request belongs to the same access IP segment, the Q is an integer greater than 1, and the Q is an integer less than or equal to the M;
  • the web server corresponding to each first access request set is determined according to the first allocation strategy, the Q first numbers, and the P first access request numbers.
  • the above determining unit 303 is specifically used for:
  • the subnet mask i and the subnet mask j belong to the same subnet mask segment, it is determined 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,
  • the subnet mask i and the subnet mask j are both one of the M subnet masks;
  • the above determining unit 303 is specifically used for:
  • the Q first access request sets are sorted according to the Q first number in descending order to obtain the first set corresponding to the Q first access request sets sequence;
  • the first set sequence into a second set sequence and a third set sequence
  • the second set sequence includes P first access request sets
  • the third set sequence includes (QP) first access request sets ;
  • the above determining unit 303 is specifically configured to:
  • each second access request and S third access requests included in the M first access requests are acquired, and each second access request is Including cookie information, each third access request does not include cookie information;
  • the R second access requests are divided 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 includes at least one second access request set. Access request, at least one route parameter corresponding to the at least one second access request is the same, the T is an integer greater than 1, and the T is an integer less than the M;
  • the web server corresponding to each third access request in the S third access requests is determined according to the second allocation strategy.
  • the above determining unit 303 is specifically configured to:
  • FIG. 4 is a schematic structural diagram of a server provided by an embodiment of the present application.
  • the server includes a processor, a memory, a communication interface, and one or more
  • the above-mentioned one or more programs are stored in the above-mentioned memory and are configured to be executed by the above-mentioned processor, and the above-mentioned program includes instructions for executing the following steps:
  • N is an integer greater than 1
  • M is an integer greater than or equal to N
  • the load balancing strategy is used to reasonably allocate the M first access requests to P web servers, where P is an integer greater than 1, and P is less than N Integer
  • the above program includes instructions specifically for executing the following steps:
  • N pieces of inquiry information are sent to the N clients, and each piece of inquiry information is used to instruct its corresponding client to feed back at least one first access request within a preset period of time.
  • the N pieces of inquiry information are related to the N clients.
  • One-to-one correspondence between terminals, the end 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;
  • At least one first access request sent by each client for its corresponding query information is received, and the M first access requests sent by the N clients are obtained.
  • the above program includes instructions specifically for executing the following steps:
  • the load balancing strategy is the first load balancing strategy, obtaining the access IP corresponding to each first access request, and obtaining M access IPs corresponding to the M first access requests;
  • the M first access requests are divided according to the M access IPs to obtain Q first access request sets corresponding to the M first access requests, and each first access request set includes at least one first access request set.
  • Access request, at least one access IP corresponding to the at least one first access request belongs to the same access IP segment, the Q is an integer greater than 1, and the Q is an integer less than or equal to the M;
  • the web server corresponding to each first access request set is determined according to the first allocation strategy, the Q first numbers, and the P first access request numbers.
  • the above procedure includes Specific instructions used to perform the following steps:
  • the subnet mask i and the subnet mask j belong to the same subnet mask segment, it is determined 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,
  • the subnet mask i and the subnet mask j are both one of the M subnet masks;
  • the above procedure includes Specific instructions used to perform the following steps:
  • the Q first access request sets are sorted according to the Q first number in descending order to obtain the first set corresponding to the Q first access request sets sequence;
  • the first set sequence into a second set sequence and a third set sequence
  • the second set sequence includes P first access request sets
  • the third set sequence includes (QP) first access request sets ;
  • the above program includes instructions specifically for executing the following steps:
  • each second access request and S third access requests included in the M first access requests are acquired, and each second access request is Including cookie information, each third access request does not include cookie information;
  • the R second access requests are divided 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 includes at least one second access request set. Access request, at least one route parameter corresponding to the at least one second access request is the same, the T is an integer greater than 1, and the T is an integer less than the M;
  • the web server corresponding to each third access request in the S third access requests is determined according to the second allocation strategy.
  • the above program includes instructions specifically for executing the following steps:
  • the embodiment of the present application also provides a computer-readable storage medium, which is used to store a computer program, and the above-mentioned computer program is executed by a processor to realize a part or part of any one of the methods described in the above-mentioned method embodiment.
  • the above-mentioned computer includes a server.
  • the embodiments of the present application also provide a computer program product.
  • the above-mentioned computer program product includes a non-transitory computer-readable storage medium storing a computer program.
  • the above-mentioned computer program is operable to cause a computer to execute any of the methods described in the above-mentioned method embodiments. Part or all of the steps of the method.
  • the computer program product may be a software installation package, and the computer includes a server.
  • the disclosed device may be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of the above-mentioned units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components can be combined or integrated. To another system, or some features can be ignored or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical or other forms.
  • the units described above as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • each unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
  • the above integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable memory.
  • the technical solution of the present application essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, A number of instructions are included to enable a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the foregoing methods of the various embodiments of the present application.
  • the aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other various media that can store program codes.
  • the program can be stored in a computer-readable memory, and the memory can include: flash disk , Read-only memory (English: Read-Only Memory, abbreviation: ROM), random access device (English: Random Access Memory, abbreviation: RAM), magnetic disk or optical disc, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Information Transfer Between Computers (AREA)
  • Computer And Data Communications (AREA)

Abstract

本申请涉及数据处理技术领域的资源分配,具体涉及一种服务器负载均衡方法及相关设备,方法包括:获取N个客户端发送的M个第一访问请求,每个客户端对应至少一个第一访问请求,N为大于1的整数,M为大于或等于N的整数;调用预先存储的负载均衡策略,负载均衡策略用于将M个第一访问请求合理分配到P个网页服务器,P为大于1的整数,P为小于N的整数;根据负载均衡策略确定M个第一访问请求中的每个第一访问请求对应的网页服务器;将每个第一访问请求转发到其对应的网页服务器。采用本申请实施例可实现提高服务器负载均衡的效率。

Description

服务器负载均衡方法及相关设备
本申请要求于2019年06月14日提交中国专利局、申请号为201910514178.0、申请名称为“服务器负载均衡方法及相关设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及数据处理技术领域,具体涉及一种服务器负载均衡方法及相关设备。
背景技术
目前,服务器负载均衡的方式为:反向代理服务器仅仅根据网页服务器对应的权重分配访问请求,即网页服务器的权重越大,分配到该网页服务器的访问请求的数量越多。这种方式导致服务器负载均衡效率较低。
发明内容
本申请实施例提供一种服务器负载均衡方法及相关设备,用于提高服务器负载均衡的效率。
第一方面,本申请实施例提供一种服务器负载均衡方法,所述方法包括:
获取N个客户端发送的M个第一访问请求,每个客户端对应至少一个第一访问请求,所述N为大于1的整数,所述M为大于或等于所述N的整数;
调用预先存储的负载均衡策略,所述负载均衡策略用于将所述M个第一访问请求合理分配到P个网页服务器,所述P为大于1的整数,所述P为小于所述N的整数;
根据所述负载均衡策略确定所述M个第一访问请求中的每个第一访问请求对应的网页服务器;
将所述每个第一访问请求转发到其对应的网页服务器。
第二方面,本申请实施例提供一种服务器负载均衡装置,所述装置包括:
获取单元,用于获取N个客户端发送的M个第一访问请求,每个客户端对应至少一个第一访问请求,所述N为大于1的整数,所述M为大于或等于所述N的整数;
调用单元,用于调用预先存储的负载均衡策略,所述负载均衡策略用于将所述M个第一访问请求合理分配到P个网页服务器,所述P为大于1的整数,所述P为小于所述N的整数;
确定单元,用于根据所述负载均衡策略确定所述M个第一访问请求中的每个第一访问请求对应的网页服务器;
转发单元,用于将所述每个第一访问请求转发到其对应的网页服务器。
第三方面,本申请实施例提供一种服务器,包括处理器、存储器、通信接口以及一个或多个程序,上述一个或多个程序被存储在上述存储器中,并且被配置由上述处理器执行,上述程序包括用于执行本申请实施例第一方面所述的方法中的部分或全部步骤的指令。
第四方面,本申请实施例提供了一种计算机可读存储介质,上述计算机可读存储介质用于存储计算机程序,上述计算机程序被处理器执行,以实现如本申请实施例第一方面所述的方法中所描述的部分或全部步骤。
可以看出,相较于仅仅根据网页服务器对应的权重分配访问请求,在本申请实施例中,反向代理服务器通过负载均衡策略将M个第一访问请求合理分配到P个网页服务器,这样有助于提高服务器负载均衡的效率。
本申请的这些方面或其他方面在以下实施例的描述中会更加简明易懂。
附图说明
为了更清楚地说明本申请实施例或背景技术中的技术方案,下面将对本申请实施例或背景技术中所 需要使用的附图进行说明。
图1A是本申请实施例提供的一种服务器负载均衡方法的流程示意图;
图1B是本申请实施例提供的一种确定第一访问请求集合对应的网页服务器的示意图;
图1C是本申请实施例提供的一种确定第二访问请求集合和第三访问请求集合对应的网页服务器的示意图;
图2是本申请实施例提供的另一种服务器负载均衡方法的流程示意图;
图3是本申请实施例提供的一种服务器负载均衡装置的功能单元组成框图;
图4是本申请实施例提供的一种服务器的结构示意图。
具体实施方式
为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分的实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本申请保护的范围。
请参见图1A,图1A是本申请实施例提供的一种服务器负载均衡方法的流程示意图,执行主体为反向代理服务器,该服务器负载均衡方法包括步骤101-104,具体如下:
101:获取N个客户端发送的M个第一访问请求,每个客户端对应至少一个第一访问请求,所述N为大于1的整数,所述M为大于或等于所述N的整数。
其中,反向代理服务器为Nginx,Nginx是一款轻量级的Web服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器。
在一个可能的示例中,获取N个客户端发送的M个第一访问请求,包括:
向所述N个客户端发送N个询问信息,每个询问信息用于指示其对应的客户端反馈预设时段内的至少一个第一访问请求,所述N个询问信息与所述N个客户端一一对应,所述预设时段的终止时刻为当前系统时刻,所述预设时段的时长小于或等于第一阈值;
接收每个客户端针对其对应的询问信息发送的至少一个第一访问请求,得到所述N个客户端发送的所述M个第一访问请求。
其中,反向代理服务器与N个客户端均具有连接关系,即反向代理服务器可以发送询问信息到N个客户端中的每个客户端,每个客户端也可以发送至少一个第一访问请求到反向代理服务器。
其中,第一阈值可以是用户自定义的,比如第一阈值可以为1s。
102:调用预先存储的负载均衡策略,所述负载均衡策略用于将所述M个第一访问请求合理分配到P个网页服务器,所述P为大于1的整数,所述P为小于所述N的整数。
其中,负载均衡(Load Balance)其意思就是分摊到多个操作单元上进行执行,例如Web服务器、FTP服务器、企业关键应用服务器和其它关键任务服务器等,从而共同完成工作任务。
其中,负载均衡策略包括第一负载均衡策略和第二负载均衡策略,第一负载均衡策略和第二负载均衡策略预先存储于反向代理服务器中。
其中,在本申请实施例中,P一般设置为3~5。
在一个可能的示例中,调用预先存储的负载均衡策略,包括:
获取第k次调用的负载均衡策略,第k次调用的负载均衡策略为第一负载均衡策略或第二负载均衡策略;
若第k次调用的负载均衡策略为第一负载均衡策略,则确定第(k+1)次调用的负载均衡策略为第二负载均衡策略;
若第k次调用的负载均衡策略为第二负载均衡策略,则确定第(k+1)次调用的负载均衡策略为第 一负载均衡策略。
在一个可能的示例中,调用预先存储的负载均衡策略,包括:
确定当前系统时刻是否处于第一时段;
若当前系统时刻处于第一时段,则确定负载均衡策略为第一负载均衡策略;
若当前系统时刻未处于第一时段,则确定负载均衡策略为第二负载均衡策略。
其中,第一时段可以是用户自定义的,第一时段可以为0:00~12:00,也可以为12:00~24:00。
103:根据所述负载均衡策略确定所述M个第一访问请求中的每个第一访问请求对应的网页服务器。
在一个可能的示例中,负载均衡策略包括第一负载均衡策略和第二负载均衡策略,根据所述负载均衡策略确定所述M个第一访问请求中的每个第一访问请求对应的网页服务器,包括:
在所述负载均衡策略为所述第一负载均衡策略的情况下,获取每个第一访问请求对应的访问IP,得到所述M个第一访问请求对应的M个访问IP;
根据所述M个访问IP将所述M个第一访问请求进行划分,得到所述M个第一访问请求对应的Q个第一访问请求集合,每个第一访问请求集合包括至少一个第一访问请求,所述至少一个第一访问请求对应的至少一个访问IP均属于同一访问IP段,所述Q为大于1的整数,所述Q为小于或等于所述M的整数;
确定每个第一访问请求集合包括的所述第一访问请求的数量,得到所述Q个第一访问请求集合对应的Q个第一数量;
获取每个网页服务器对应的第一访问请求数量,得到所述P个网页服务器对应的P个第一访问请求数量,每个第一访问请求数量为其对应的网页服务器在预设时长内能够处理的最大访问请求数量,所述预设时长小于或等于第二阈值;
调用预先存储的第一分配策略,所述第一分配策略用于将所述Q个第一访问请求集合合理分配到所述P个网页服务器;
根据所述第一分配策略、所述Q个第一数量和所述P个第一访问请求数量确定每个第一访问请求集合对应的网页服务器。
具体地获取每个网页服务器对应的第一访问请求数量的实施方式可以为:获取第m个网页服务器对应的第一权重,第m个网页服务器为P个网页服务器中的其中一个;根据权重与第一访问请求数量的映射关系确定第一权重对应的第一访问请求数量;将第一权重对应的第一访问请求数量确定为第m个网页服务器对应的第一访问请求数量;对P个网页服务器处第m个网页服务器之外的(P-1)个网页服务器执行相同的操作,得到(P-1)个网页服务器中每个网页服务器对应的第一访问请求数量。
其中,第二阈值可以是用户自定义的,比如第二阈值可以为1s。
在一个可能的示例中,根据所述M个访问IP将所述M个第一访问请求进行划分,得到所述M个第一访问请求对应的Q个第一访问请求集合,包括:
获取每个访问IP对应的子网掩码,得到所述M个访问IP对应的M个子网掩码,每个子网掩码对应一个第一访问请求;
若子网掩码i与子网掩码j属于同一子网掩码段,则确定所述子网掩码i对应的访问IP与所述子网掩码j对应的访问IP属于同一访问IP段,所述子网掩码i和所述子网掩码j均为所述M个子网掩码中的其中一个;
将所述子网掩码i对应的第一访问请求与所述子网掩码j对应的第一访问请求划分到同一个第一访问请求集合;
对所述M个子网掩码中除所述子网掩码i和所述子网掩码j之外的(M-2)个子网掩码执行相同的操作,得到所述M个第一访问请求对应的所述Q个第一访问请求集合。
其中,子网掩码(subnet mask)又叫网络掩码、地址掩码,它是一种用来指明一个IP地址的哪些 位标识是主机所在的子网,以及哪些位标识是主机的位掩码。子网掩码不能单独存在,它必须结合IP地址一起使用。子网掩码是一个32位地址。
其中,子网掩码段可以是用户自定义的,子网掩码段预先存储于反向代理服务器中。
在一个可能的示例中,根据所述第一分配策略、所述Q个第一数量和所述P个第一访问请求数量确定每个第一访问请求集合对应的网页服务器,包括:
根据所述P个第一访问请求数量从大到小的顺序将所述P个网页服务器进行一次排序,得到所述P个网页服务器对应的第一网页服务器序列;
当P<Q<2P时,根据所述Q个第一数量从大到小的顺序将所述Q个第一访问请求集合进行排序,得到所述Q个第一访问请求集合对应的第一集合序列;
将所述第一集合序列划分为第二集合序列和第三集合序列,所述第二集合序列包括P个第一访问请求集合,所述第三集合序列包括(Q-P)个第一访问请求集合;
确定所述第二集合序列包括的所述P个第一访问请求集合中的每个第一访问请求集合对应的网页服务器,所述第二集合序列包括的所述P个第一访问请求集合中的每个第一访问请求集合在所述第二集合序列中的位置与其对应的网页服务器在所述第一网页服务器序列中的位置是相同的;
获取每个网页服务器对应的第一剩余访问请求数量,得到所述P个网页服务器对应的P个第一剩余访问请求数量;
根据所述P个第一剩余访问请求数量从大到小的顺序将所述P个网页服务器进行二次排序,得到所述P个网页服务器对应的第二网页服务器序列;
确定所述第三集合序列包括的所述(Q-P)个第一访问请求集合中的每个第一访问请求集合对应的网页服务器,所述第三集合序列包括的所述(Q-P)个第一访问请求集合中的每个第一访问请求集合在所述第三集合序列中的位置与其对应的网页服务器在所述第二网页服务器序列中的位置是相同的。
其中,第二集合序列包括的P个第一访问请求集合对应的P个第一数量的平均值大于第三集合序列包括的(Q-P)个第一访问请求集合对应的(Q-P)个第一数量的平均值。
具体地,获取每个网页服务器对应的第一剩余访问请求数量,得到P个网页服务器对应的P个第一剩余访问请求数量的实施方式可以为:获取第n个网页服务器对应的第一访问请求数量,第n个网页服务器为P个网页服务器中的其中一个;获取第n个网页服务器所对应第一访问请求集合对应的第一数量;将第n个网页服务器对应的第一访问请求数量与其所对应第一访问请求集合对应的第一数量的差值确定为第n个网页服务器对应的第一剩余访问请求数量;对P个网页服务器除第n个网页服务器之外的(P-1)个网页服务器执行相同的操作,得到(P-1)个网页服务器对应的(P-1)个第一剩余访问请求数量。
其中,当Q≤P或Q≥2P时,根据第一分配策略、Q个第一数量和P个第一访问请求数量确定每个第一访问请求集合对应的网页服务器的实施方式可以参照当P<Q<2P时,根据第一分配策略、Q个第一数量和P个第一访问请求数量确定每个第一访问请求集合对应的网页服务器的实施方式,在此不再叙述。
举例来说,如图1B所示,图1B是本申请实施例提供的一种确定第一访问请求集合对应的网页服务器的示意图,假设M为100,P为5,第一网页服务器序列为:网页服务器2(第一访问请求数量为200)-网页服务器4(第一访问请求数量为180)-网页服务器3(第一访问请求数量为160)-网页服务器5(第一访问请求数量为150)-网页服务器1(第一访问请求数量为145),反向代理服务器将100个第一访问请求划分为8个第一访问请求集合,分别为集合1(20个第一访问请求)、集合2(8个第一访问请求)、集合3(16个第一访问请求)、集合4(17个第一访问请求)、集合5(9个第一访问请求)、集合6(14个第一访问请求)、集合7(5个第一访问请求)和集合8(11个第一访问请求),将8个第一访问请求集合进行排序,得到第一集合序列为:集合1-集合4-集合3-集合6-集合8-集合5-集合2-集合7,将第一集合序列划分为第二集合序列(集合1-集合4-集合3-集合6-集合8)和第三集合 序列(集合5-集合2-集合7);确定集合1对应网页服务器2,集合4对应网页服务器4,集合3对应网页服务器3,集合6对应网页服务器5,集合8对应网页服务器1,第二网页服务器序列为:网页服务器2(第一剩余访问请求数量为180)-网页服务器4(第一剩余访问请求数量为163)-网页服务器3(第一剩余访问请求数量为144)-网页服务器5(第一剩余访问请求数量为136)-网页服务器1(第一剩余访问请求数量为134);确定集合5对应网页服务器2,集合2对应网页服务器4,集合7对应网页服务器3。
可见,相较于仅仅根据网页服务器对应的权重分配访问请求,在本示例中,反向代理服务器通过第一负载均衡策略将M个第一访问请求合理分配到P个网页服务器,这样有助于提高服务器负载均衡的效率。
在一个可能的示例中,负载均衡策略包括第一负载均衡策略和第二负载均衡策略,根据所述负载均衡策略确定所述M个第一访问请求中的每个第一访问请求对应的网页服务器,包括:
在所述负载均衡策略为所述第二负载均衡策略的情况下,获取所述M个第一访问请求包括的R个第二访问请求和S个第三访问请求,每个第二访问请求均包括cookie信息,每个第三访问请求均不包括cookie信息;
获取每个第二访问请求对应的route参数,得到所述R个第二访问请求对应的R个route参数;
根据所述R个route参数将所述R个第二访问请求进行划分,得到所述R个第二访问请求对应的T个第二访问请求集合,每个第二访问请求集合包括至少一个第二访问请求,所述至少一个第二访问请求对应的至少一个route参数均相同,所述T为大于1的整数,所述T为小于所述M的整数;
根据route参数与网页服务器的映射关系确定所述T个第二访问请求集合中的每个第二访问请求集合对应的网页服务器;
调用预先存储的第二分配策略,所述第二分配策略用于将所述S个第三访问请求合理分配到所述P个网页服务器;
根据所述第二分配策略确定所述S个第三访问请求中的每个第三访问请求对应的网页服务器。
其中,cookie指的是储存在用户本地终端上的数据信息,route指的是用来显示、人工添加和修改路由表项目的。
在一个可能的示例中,根据所述第二分配策略确定所述S个第三访问请求中的每个第三访问请求对应的网页服务器,包括:
获取每个网页服务器对应的第二剩余访问请求数量,得到所述P个网页服务器对应的P个第二剩余访问请求数量;
根据所述P个第二剩余访问请求数量从大到小的顺序将所述P个网页服务器进行排序,得到所述P个网页服务器对应的第三网页服务器序列;
根据所述P个第二剩余访问请求数量对应的比值将所述S个第三访问请求划分为P个第三访问请求集合;
确定每个第三访问请求集合包括的所述第三访问请求的数量,得到所述P个第三访问请求集合对应的P个第二数量;
根据所述P个第二数量从大到小的数量将所述P个第三访问请求集合进行排序,得到所述P个第三访问请求集合对应的第四集合序列;
确定每个第三访问请求集合对应的网页服务器,所述P个第三访问请求集合中的每个第三访问请求集合在所述第四集合序列中的位置与其对应的网页服务器在所述第三网页服务器序列中的位置是相同的。
其中,route参数与网页服务器的映射关系如下表1所示:
表1
route参数 网页服务器
第一route值 网页服务器1
第二route值 网页服务器2
第三route值 网页服务器3
...... ......
具体地,获取每个网页服务器对应的第二剩余访问请求数量,得到P个网页服务器对应的P个第二剩余访问请求数量的实施方式可以为:获取第p个网页服务器对应的第一访问请求数量,第p个网页服务器为P个网页服务器中的其中一个;获取第p个网页服务器所对应第二访问请求集合包括的至少一个第二访问请求对应的第三数量;将第p个网页服务器对应的第一访问请求数量与其所对应第二访问请求集合对应的第三数量的差值确定为第p个网页服务器对应的第二剩余访问请求数量;对P个网页服务器除第p个网页服务器之外的(P-1)个网页服务器执行相同的操作,得到(P-1)个网页服务器对应的(P-1)个第二剩余访问请求数量。
举例来说,如图1C所示,图1C是本申请实施例提供的一种确定第二访问请求集合和第三访问请求集合对应的网页服务器的示意图,假设M为115,P为5,网页服务器2对应的第一访问请求数量为217,网页服务器4对应的第一访问请求数量为180,网页服务器3对应的第一访问请求数量为162,网页服务器5对应的第一访问请求数量为147,网页服务器1对应的第一访问请求数量为140,反向代理服务器获取115个第一访问请求包括的36个第二访问请求和79个第三访问请求,将36个第二访问请求划分为3个第二访问请求集合,分别为集合9(17个第二访问请求)、集合10(12个第二访问请求)和集合11(7个第二访问请求);反向代理服务器确定集合9对应网页服务器2,集合10对应网页服务器3,集合11对应网页服务器5;第三网页服务器序列为:网页服务器2(第二剩余访问请求数量为200)-网页服务器4(第二剩余访问请求数量为180)-网页服务器3(第二剩余访问请求数量为150)-网页服务器5(第二剩余访问请求数量为140)-网页服务器1(第二剩余访问请求数量为140);5个第二剩余访问数量对应的比值为20:18:15:14:14;将79个第三访问请求划分为5个第三访问请求集合,分别为:集合12(18个第三访问请求)、集合13(14个第三访问请求)、集合14(15个第三访问请求)、集合15(20个第三访问请求)和集合16(14个第三访问请求);将5个第三访问请求集合进行排序,得到第四集合序列为:集合15-集合12-集合14-集合16-集合13;反向代理服务器确定集合15对应网页服务器2,集合12对应网页服务器4,集合14对应网页服务器3,集合16对应网页服务器5,集合13对应网页服务器1。
可见,相较于仅仅根据网页服务器对应的权重分配访问请求,在本示例中,反向代理服务器通过第二负载均衡策略将M个第一访问请求合理分配到P个网页服务器,这样有助于提高服务器负载均衡的效率。
104:将所述每个第一访问请求转发到其对应的网页服务器。
可以看出,相较于仅仅根据网页服务器对应的权重分配访问请求,在本申请实施例中,反向代理服务器通过负载均衡策略将M个第一访问请求合理分配到P个网页服务器,这样有助于提高服务器负载均衡的效率。
与上述图1A所示的实施例一致的,请参见图2,图2是本申请实施例提供的另一种服务器负载均衡方法的流程示意图,执行主体为反向代理服务器,该服务器负载均衡方法包括步骤201-213,具体如下:
201:反向代理服务器获取N个客户端发送的M个第一访问请求,每个客户端对应至少一个第一访问请求,所述N为大于1的整数,所述M为大于或等于所述N的整数。
202:调用预先存储的第一负载均衡策略,所述第一负载均衡策略用于将所述M个第一访问请求合 理分配到P个网页服务器,所述P为大于1的整数,所述P为小于所述N的整数。
203:获取每个第一访问请求对应的访问IP,得到所述M个第一访问请求对应的M个访问IP。
204:根据所述M个访问IP将所述M个第一访问请求进行划分,得到所述M个第一访问请求对应的Q个第一访问请求集合,每个第一访问请求集合包括至少一个第一访问请求,所述至少一个第一访问请求对应的至少一个访问IP均属于同一访问IP段,所述Q为大于1的整数,所述Q为小于或等于所述M的整数。
205:确定每个第一访问请求集合包括的所述第一访问请求的数量,得到所述Q个第一访问请求集合对应的Q个第一数量。
206:获取每个网页服务器对应的第一访问请求数量,得到所述P个网页服务器对应的P个第一访问请求数量,每个第一访问请求数量为其对应的网页服务器在预设时长内能够处理的最大访问请求数量,所述预设时长小于或等于第二阈值。
207:根据所述P个第一访问请求数量从大到小的顺序将所述P个网页服务器进行一次排序,得到所述P个网页服务器对应的第一网页服务器序列。
208:当P<Q<2P时,根据所述Q个第一数量从大到小的顺序将所述Q个第一访问请求集合进行排序,得到所述Q个第一访问请求集合对应的第一集合序列。
209:将所述第一集合序列划分为第二集合序列和第三集合序列,所述第二集合序列包括P个第一访问请求集合,所述第三集合序列包括(Q-P)个第一访问请求集合。
210:确定所述第二集合序列包括的所述P个第一访问请求集合中的每个第一访问请求集合对应的网页服务器,所述第二集合序列包括的所述P个第一访问请求集合中的每个第一访问请求集合在所述第二集合序列中的位置与其对应的网页服务器在所述第一网页服务器序列中的位置是相同的。
211:获取每个网页服务器对应的第一剩余访问请求数量,得到所述P个网页服务器对应的P个第一剩余访问请求数量。
212:根据所述P个第一剩余访问请求数量从大到小的顺序将所述P个网页服务器进行二次排序,得到所述P个网页服务器对应的第二网页服务器序列。
213:确定所述第三集合序列包括的所述(Q-P)个第一访问请求集合中的每个第一访问请求集合对应的网页服务器,所述第三集合序列包括的所述(Q-P)个第一访问请求集合中的每个第一访问请求集合在所述第三集合序列中的位置与其对应的网页服务器在所述第二网页服务器序列中的位置是相同的。
需要说明的是,图2所示的方法的各个步骤的具体实现过程可参见上述方法所述的具体实现过程,在此不再叙述。
与上述图1A和图2所示的实施例一致的,请参见图3,图3是本申请实施例提供的一种服务器负载均衡装置的功能单元组成框图,该服务器负载均衡装置300包括:
获取单元301,用于获取N个客户端发送的M个第一访问请求,每个客户端对应至少一个第一访问请求,所述N为大于1的整数,所述M为大于或等于所述N的整数;
调用单元302,用于调用预先存储的负载均衡策略,所述负载均衡策略用于将所述M个第一访问请求合理分配到P个网页服务器,所述P为大于1的整数,所述P为小于所述N的整数;
确定单元303,用于根据所述负载均衡策略确定所述M个第一访问请求中的每个第一访问请求对应的网页服务器;
转发单元304,用于将所述每个第一访问请求转发到其对应的网页服务器。
在一个可能的示例中,在获取N个客户端发送的M个第一访问请求方面,上述获取单元301具体用于:
向所述N个客户端发送N个询问信息,每个询问信息用于指示其对应的客户端反馈预设时段内的 至少一个第一访问请求,所述N个询问信息与所述N个客户端一一对应,所述预设时段的终止时刻为当前系统时刻,所述预设时段的时长小于或等于第一阈值;
接收每个客户端针对其对应的询问信息发送的至少一个第一访问请求,得到所述N个客户端发送的所述M个第一访问请求。
在一个可能的示例中,在根据所述负载均衡策略确定所述M个第一访问请求中的每个第一访问请求对应的网页服务器方面,上述确定单元303具体用于:
在所述负载均衡策略为所述第一负载均衡策略的情况下,获取每个第一访问请求对应的访问IP,得到所述M个第一访问请求对应的M个访问IP;
根据所述M个访问IP将所述M个第一访问请求进行划分,得到所述M个第一访问请求对应的Q个第一访问请求集合,每个第一访问请求集合包括至少一个第一访问请求,所述至少一个第一访问请求对应的至少一个访问IP均属于同一访问IP段,所述Q为大于1的整数,所述Q为小于或等于所述M的整数;
确定每个第一访问请求集合包括的所述第一访问请求的数量,得到所述Q个第一访问请求集合对应的Q个第一数量;
获取每个网页服务器对应的第一访问请求数量,得到所述P个网页服务器对应的P个第一访问请求数量,每个第一访问请求数量为其对应的网页服务器在预设时长内能够处理的最大访问请求数量,所述预设时长小于或等于第二阈值;
调用预先存储的第一分配策略,所述第一分配策略用于将所述Q个第一访问请求集合合理分配到所述P个网页服务器;
根据所述第一分配策略、所述Q个第一数量和所述P个第一访问请求数量确定每个第一访问请求集合对应的网页服务器。
在一个可能的示例中,在根据所述M个访问IP将所述M个第一访问请求进行划分,得到所述M个第一访问请求对应的Q个第一访问请求集合方面,上述确定单元303具体用于:
获取每个访问IP对应的子网掩码,得到所述M个访问IP对应的M个子网掩码,每个子网掩码对应一个第一访问请求;
若子网掩码i与子网掩码j属于同一子网掩码段,则确定所述子网掩码i对应的访问IP与所述子网掩码j对应的访问IP属于同一访问IP段,所述子网掩码i和所述子网掩码j均为所述M个子网掩码中的其中一个;
将所述子网掩码i对应的第一访问请求与所述子网掩码j对应的第一访问请求划分到同一个第一访问请求集合;
对所述M个子网掩码中除所述子网掩码i和所述子网掩码j之外的(M-2)个子网掩码执行相同的操作,得到所述M个第一访问请求对应的所述Q个第一访问请求集合。
在一个可能的示例中,在根据所述第一分配策略、所述Q个第一数量和所述P个第一访问请求数量确定每个第一访问请求集合对应的网页服务器方面,上述确定单元303具体用于:
根据所述P个第一访问请求数量从大到小的顺序将所述P个网页服务器进行一次排序,得到所述P个网页服务器对应的第一网页服务器序列;
当P<Q<2P时,根据所述Q个第一数量从大到小的顺序将所述Q个第一访问请求集合进行排序,得到所述Q个第一访问请求集合对应的第一集合序列;
将所述第一集合序列划分为第二集合序列和第三集合序列,所述第二集合序列包括P个第一访问请求集合,所述第三集合序列包括(Q-P)个第一访问请求集合;
确定所述第二集合序列包括的所述P个第一访问请求集合中的每个第一访问请求集合对应的网页服务器,所述第二集合序列包括的所述P个第一访问请求集合中的每个第一访问请求集合在所述第二集合 序列中的位置与其对应的网页服务器在所述第一网页服务器序列中的位置是相同的;
获取每个网页服务器对应的第一剩余访问请求数量,得到所述P个网页服务器对应的P个第一剩余访问请求数量;
根据所述P个第一剩余访问请求数量从大到小的顺序将所述P个网页服务器进行二次排序,得到所述P个网页服务器对应的第二网页服务器序列;
确定所述第三集合序列包括的所述(Q-P)个第一访问请求集合中的每个第一访问请求集合对应的网页服务器,所述第三集合序列包括的所述(Q-P)个第一访问请求集合中的每个第一访问请求集合在所述第三集合序列中的位置与其对应的网页服务器在所述第二网页服务器序列中的位置是相同的。
在一个可能的示例中,在根据所述负载均衡策略确定所述M个第一访问请求中的每个第一访问请求对应的网页服务器方面,上述确定单元303具体用于:
在所述负载均衡策略为所述第二负载均衡策略的情况下,获取所述M个第一访问请求包括的R个第二访问请求和S个第三访问请求,每个第二访问请求均包括cookie信息,每个第三访问请求均不包括cookie信息;
获取每个第二访问请求对应的route参数,得到所述R个第二访问请求对应的R个route参数;
根据所述R个route参数将所述R个第二访问请求进行划分,得到所述R个第二访问请求对应的T个第二访问请求集合,每个第二访问请求集合包括至少一个第二访问请求,所述至少一个第二访问请求对应的至少一个route参数均相同,所述T为大于1的整数,所述T为小于所述M的整数;
根据route参数与网页服务器的映射关系确定所述T个第二访问请求集合中的每个第二访问请求集合对应的网页服务器;
调用预先存储的第二分配策略,所述第二分配策略用于将所述S个第三访问请求合理分配到所述P个网页服务器;
根据所述第二分配策略确定所述S个第三访问请求中的每个第三访问请求对应的网页服务器。
在一个可能的示例中,在根据所述第二分配策略确定所述S个第三访问请求中的每个第三访问请求对应的网页服务器方面,上述确定单元303具体用于:
获取每个网页服务器对应的第二剩余访问请求数量,得到所述P个网页服务器对应的P个第二剩余访问请求数量;
根据所述P个第二剩余访问请求数量从大到小的顺序将所述P个网页服务器进行排序,得到所述P个网页服务器对应的第三网页服务器序列;
根据所述P个第二剩余访问请求数量对应的比值将所述S个第三访问请求划分为P个第三访问请求集合;
确定每个第三访问请求集合包括的所述第三访问请求的数量,得到所述P个第三访问请求集合对应的P个第二数量;
根据所述P个第二数量从大到小的数量将所述P个第三访问请求集合进行排序,得到所述P个第三访问请求集合对应的第四集合序列;
确定每个第三访问请求集合对应的网页服务器,所述P个第三访问请求集合中的每个第三访问请求集合在所述第四集合序列中的位置与其对应的网页服务器在所述第三网页服务器序列中的位置是相同的。
与上述图1A和图2所示的实施例一致的,请参见图4,图4是本申请实施例提供的一种服务器的结构示意图,该服务器包括处理器、存储器、通信接口以及一个或多个程序,上述一个或多个程序被存储在上述存储器中,并且被配置由上述处理器执行,上述程序包括用于执行以下步骤的指令:
获取N个客户端发送的M个第一访问请求,每个客户端对应至少一个第一访问请求,所述N为大 于1的整数,所述M为大于或等于所述N的整数;
调用预先存储的负载均衡策略,所述负载均衡策略用于将所述M个第一访问请求合理分配到P个网页服务器,所述P为大于1的整数,所述P为小于所述N的整数;
根据所述负载均衡策略确定所述M个第一访问请求中的每个第一访问请求对应的网页服务器;
将所述每个第一访问请求转发到其对应的网页服务器。
在一个可能的示例中,在获取N个客户端发送的M个第一访问请求方面,上述程序包括具体用于执行以下步骤的指令:
向所述N个客户端发送N个询问信息,每个询问信息用于指示其对应的客户端反馈预设时段内的至少一个第一访问请求,所述N个询问信息与所述N个客户端一一对应,所述预设时段的终止时刻为当前系统时刻,所述预设时段的时长小于或等于第一阈值;
接收每个客户端针对其对应的询问信息发送的至少一个第一访问请求,得到所述N个客户端发送的所述M个第一访问请求。
在一个可能的示例中,在根据所述负载均衡策略确定所述M个第一访问请求中的每个第一访问请求对应的网页服务器方面,上述程序包括具体用于执行以下步骤的指令:
在所述负载均衡策略为所述第一负载均衡策略的情况下,获取每个第一访问请求对应的访问IP,得到所述M个第一访问请求对应的M个访问IP;
根据所述M个访问IP将所述M个第一访问请求进行划分,得到所述M个第一访问请求对应的Q个第一访问请求集合,每个第一访问请求集合包括至少一个第一访问请求,所述至少一个第一访问请求对应的至少一个访问IP均属于同一访问IP段,所述Q为大于1的整数,所述Q为小于或等于所述M的整数;
确定每个第一访问请求集合包括的所述第一访问请求的数量,得到所述Q个第一访问请求集合对应的Q个第一数量;
获取每个网页服务器对应的第一访问请求数量,得到所述P个网页服务器对应的P个第一访问请求数量,每个第一访问请求数量为其对应的网页服务器在预设时长内能够处理的最大访问请求数量,所述预设时长小于或等于第二阈值;
调用预先存储的第一分配策略,所述第一分配策略用于将所述Q个第一访问请求集合合理分配到所述P个网页服务器;
根据所述第一分配策略、所述Q个第一数量和所述P个第一访问请求数量确定每个第一访问请求集合对应的网页服务器。
在一个可能的示例中,在根据所述M个访问IP将所述M个第一访问请求进行划分,得到所述M个第一访问请求对应的Q个第一访问请求集合方面,上述程序包括具体用于执行以下步骤的指令:
获取每个访问IP对应的子网掩码,得到所述M个访问IP对应的M个子网掩码,每个子网掩码对应一个第一访问请求;
若子网掩码i与子网掩码j属于同一子网掩码段,则确定所述子网掩码i对应的访问IP与所述子网掩码j对应的访问IP属于同一访问IP段,所述子网掩码i和所述子网掩码j均为所述M个子网掩码中的其中一个;
将所述子网掩码i对应的第一访问请求与所述子网掩码j对应的第一访问请求划分到同一个第一访问请求集合;
对所述M个子网掩码中除所述子网掩码i和所述子网掩码j之外的(M-2)个子网掩码执行相同的操作,得到所述M个第一访问请求对应的所述Q个第一访问请求集合。
在一个可能的示例中,在根据所述第一分配策略、所述Q个第一数量和所述P个第一访问请求数量确定每个第一访问请求集合对应的网页服务器方面,上述程序包括具体用于执行以下步骤的指令:
根据所述P个第一访问请求数量从大到小的顺序将所述P个网页服务器进行一次排序,得到所述P个网页服务器对应的第一网页服务器序列;
当P<Q<2P时,根据所述Q个第一数量从大到小的顺序将所述Q个第一访问请求集合进行排序,得到所述Q个第一访问请求集合对应的第一集合序列;
将所述第一集合序列划分为第二集合序列和第三集合序列,所述第二集合序列包括P个第一访问请求集合,所述第三集合序列包括(Q-P)个第一访问请求集合;
确定所述第二集合序列包括的所述P个第一访问请求集合中的每个第一访问请求集合对应的网页服务器,所述第二集合序列包括的所述P个第一访问请求集合中的每个第一访问请求集合在所述第二集合序列中的位置与其对应的网页服务器在所述第一网页服务器序列中的位置是相同的;
获取每个网页服务器对应的第一剩余访问请求数量,得到所述P个网页服务器对应的P个第一剩余访问请求数量;
根据所述P个第一剩余访问请求数量从大到小的顺序将所述P个网页服务器进行二次排序,得到所述P个网页服务器对应的第二网页服务器序列;
确定所述第三集合序列包括的所述(Q-P)个第一访问请求集合中的每个第一访问请求集合对应的网页服务器,所述第三集合序列包括的所述(Q-P)个第一访问请求集合中每个第一访问请求集合在所述第三集合序列中的位置与其对应的网页服务器在所述第二网页服务器序列中的位置是相同的。
在一个可能的示例中,在根据所述负载均衡策略确定所述M个第一访问请求中的每个第一访问请求对应的网页服务器方面,上述程序包括具体用于执行以下步骤的指令:
在所述负载均衡策略为所述第二负载均衡策略的情况下,获取所述M个第一访问请求包括的R个第二访问请求和S个第三访问请求,每个第二访问请求均包括cookie信息,每个第三访问请求均不包括cookie信息;
获取每个第二访问请求对应的route参数,得到所述R个第二访问请求对应的R个route参数;
根据所述R个route参数将所述R个第二访问请求进行划分,得到所述R个第二访问请求对应的T个第二访问请求集合,每个第二访问请求集合包括至少一个第二访问请求,所述至少一个第二访问请求对应的至少一个route参数均相同,所述T为大于1的整数,所述T为小于所述M的整数;
根据route参数与网页服务器的映射关系确定所述T个第二访问请求集合中的每个第二访问请求集合对应的网页服务器;
调用预先存储的第二分配策略,所述第二分配策略用于将所述S个第三访问请求合理分配到所述P个网页服务器;
根据所述第二分配策略确定所述S个第三访问请求中的每个第三访问请求对应的网页服务器。
在一个可能的示例中,在根据所述第二分配策略确定所述S个第三访问请求中的每个第三访问请求对应的网页服务器方面,上述程序包括具体用于执行以下步骤的指令:
获取每个网页服务器对应的第二剩余访问请求数量,得到所述P个网页服务器对应的P个第二剩余访问请求数量;
根据所述P个第二剩余访问请求数量从大到小的顺序将所述P个网页服务器进行排序,得到所述P个网页服务器对应的第三网页服务器序列;
根据所述P个第二剩余访问请求数量对应的比值将所述S个第三访问请求划分为P个第三访问请求集合;
确定每个第三访问请求集合包括的所述第三访问请求的数量,得到所述P个第三访问请求集合对应的P个第二数量;
根据所述P个第二数量从大到小的数量将所述P个第三访问请求集合进行排序,得到所述P个第三访问请求集合对应的第四集合序列;
确定每个第三访问请求集合对应的网页服务器,所述P个第三访问请求集合中的每个第三访问请求集合在所述第四集合序列中的位置与其对应的网页服务器在所述第三网页服务器序列中的位置是相同的。
本申请实施例还提供一种计算机可读存储介质,该计算机可读存储介质用于存储计算机程序,上述计算机程序被处理器执行,以实现如上述方法实施例中记载的任一方法的部分或全部步骤,上述计算机包括服务器。
本申请实施例还提供一种计算机程序产品,上述计算机程序产品包括存储了计算机程序的非瞬时性计算机可读存储介质,上述计算机程序可操作来使计算机执行如上述方法实施例中记载的任一方法的部分或全部步骤。该计算机程序产品可以为一个软件安装包,上述计算机包括服务器。
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请并不受所描述的动作顺序的限制,因为依据本申请,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本申请所必须的。
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。
在本申请所提供的几个实施例中,应该理解到,所揭露的装置,可通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如上述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性或其它的形式。
上述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
上述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储器中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储器中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本申请各个实施例上述方法的全部或部分步骤。而前述的存储器包括:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序可以存储于一计算机可读存储器中,存储器可以包括:闪存盘、只读存储器(英文:Read-Only Memory,简称:ROM)、随机存取器(英文:Random Access Memory,简称:RAM)、磁盘或光盘等。
以上对本申请实施例进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实现方式及应用范围上均会有改变之处,综上上述,本说明书内容不应理解为对本申请的限制。

Claims (20)

  1. 一种服务器负载均衡方法,其特征在于,所述方法包括:
    获取N个客户端发送的M个第一访问请求,每个客户端对应至少一个第一访问请求,所述N为大于1的整数,所述M为大于或等于所述N的整数;
    调用预先存储的负载均衡策略,所述负载均衡策略用于将所述M个第一访问请求合理分配到P个网页服务器,所述P为大于1的整数,所述P为小于所述N的整数;
    根据所述负载均衡策略确定所述M个第一访问请求中的每个第一访问请求对应的网页服务器;
    将所述每个第一访问请求转发到其对应的网页服务器。
  2. 根据权利要求1所述的方法,其特征在于,所述获取N个客户端发送的M个第一访问请求,包括:
    向所述N个客户端发送N个询问信息,每个询问信息用于指示其对应的客户端反馈预设时段内的至少一个第一访问请求,所述N个询问信息与所述N个客户端一一对应,所述预设时段的终止时刻为当前系统时刻,所述预设时段的时长小于或等于第一阈值;
    接收每个客户端针对其对应的询问信息发送的至少一个第一访问请求,得到所述N个客户端发送的所述M个第一访问请求。
  3. 根据权利要求1或2所述的方法,其特征在于,所述调用预先存储的负载均衡策略,包括:
    获取第k次调用的负载均衡策略,所述第k次调用的负载均衡策略为第一负载均衡策略或第二负载均衡策略;
    若所述第k次调用的负载均衡策略为所述第一负载均衡策略,则确定第(k+1)次调用的负载均衡策略为所述第二负载均衡策略;
    若所述第k次调用的负载均衡策略为所述第二负载均衡策略,则确定第(k+1)次调用的负载均衡策略为所述第一负载均衡策略。
  4. 根据权利要求1或2所述的方法,其特征在于,所述调用预先存储的负载均衡策略,包括:
    确定当前系统时刻是否处于第一时段;
    若所述当前系统时刻处于所述第一时段,则确定负载均衡策略为第一负载均衡策略;
    若所述当前系统时刻未处于所述第一时段,则确定负载均衡策略为第二负载均衡策略。
  5. 根据权利要求3或4所述的方法,其特征在于,所述负载均衡策略包括第一负载均衡策略和第二负载均衡策略,所述根据所述负载均衡策略确定所述M个第一访问请求中的每个第一访问请求对应的网页服务器,包括:
    在所述负载均衡策略为所述第一负载均衡策略的情况下,获取每个第一访问请求对应的访问IP,得到所述M个第一访问请求对应的M个访问IP;
    根据所述M个访问IP将所述M个第一访问请求进行划分,得到所述M个第一访问请求对应的Q个第一访问请求集合,每个第一访问请求集合包括至少一个第一访问请求,所述至少一个第一访问请求对应的至少一个访问IP均属于同一访问IP段,所述Q为大于1的整数,所述Q为小于或等于所述M的整数;
    确定每个第一访问请求集合包括的所述第一访问请求的数量,得到所述Q个第一访问请求集合对应的Q个第一数量;
    获取每个网页服务器对应的第一访问请求数量,得到所述P个网页服务器对应的P个第一访问请求数量,每个第一访问请求数量为其对应的网页服务器在预设时长内能够处理的最大访问请求数量,所述预设时长小于或等于第二阈值;
    调用预先存储的第一分配策略,所述第一分配策略用于将所述Q个第一访问请求集合合理分配到所述P个网页服务器;
    根据所述第一分配策略、所述Q个第一数量和所述P个第一访问请求数量确定每个第一访问请求集合对应的网页服务器。
  6. 根据权利要求5所述的方法,其特征在于,所述根据所述M个访问IP将所述M个第一访问请求进行划分,得到所述M个第一访问请求对应的Q个第一访问请求集合,包括:
    获取每个访问IP对应的子网掩码,得到所述M个访问IP对应的M个子网掩码,每个子网掩码对应一个第一访问请求;
    若子网掩码i与子网掩码j属于同一子网掩码段,则确定所述子网掩码i对应的访问IP与所述子网掩码j对应的访问IP属于同一访问IP段,所述子网掩码i和所述子网掩码j均为所述M个子网掩码中的其中一个;
    将所述子网掩码i对应的第一访问请求与所述子网掩码j对应的第一访问请求划分到同一个第一访问请求集合;
    对所述M个子网掩码中除所述子网掩码i和所述子网掩码j之外的(M-2)个子网掩码执行相同的操作,得到所述M个第一访问请求对应的所述Q个第一访问请求集合。
  7. 根据权利要求6所述的方法,其特征在于,所述根据所述第一分配策略、所述Q个第一数量和所述P个第一访问请求数量确定每个第一访问请求集合对应的网页服务器,包括:
    根据所述P个第一访问请求数量从大到小的顺序将所述P个网页服务器进行一次排序,得到所述P个网页服务器对应的第一网页服务器序列;
    当P<Q<2P时,根据所述Q个第一数量从大到小的顺序将所述Q个第一访问请求集合进行排序,得到所述Q个第一访问请求集合对应的第一集合序列;
    将所述第一集合序列划分为第二集合序列和第三集合序列,所述第二集合序列包括P个第一访问请求集合,所述第三集合序列包括(Q-P)个第一访问请求集合;
    确定所述第二集合序列包括的所述P个第一访问请求集合中的每个第一访问请求集合对应的网页服务器,所述第二集合序列包括的所述P个第一访问请求集合中的每个第一访问请求集合在所述第二集合序列中的位置与其对应的网页服务器在所述第一网页服务器序列中的位置是相同的;
    获取每个网页服务器对应的第一剩余访问请求数量,得到所述P个网页服务器对应的P个第一剩余访问请求数量;
    根据所述P个第一剩余访问请求数量从大到小的顺序将所述P个网页服务器进行二次排序,得到所述P个网页服务器对应的第二网页服务器序列;
    确定所述第三集合序列包括的所述(Q-P)个第一访问请求集合中的每个第一访问请求集合对应的网页服务器,所述第三集合序列包括的所述(Q-P)个第一访问请求集合中的每个第一访问请求集合在所述第三集合序列中的位置与其对应的网页服务器在所述第二网页服务器序列中的位置是相同的。
  8. 根据权利要求3或4所述的方法,其特征在于,所述负载均衡策略包括第一负载均衡策略和第二负载均衡策略,所述根据所述负载均衡策略确定所述M个第一访问请求中的每个第一访问请求对应的网页服务器,包括:
    在所述负载均衡策略为所述第二负载均衡策略的情况下,获取所述M个第一访问请求包括的R个第二访问请求和S个第三访问请求,每个第二访问请求均包括cookie信息,每个第三访问请求均不包括cookie信息;
    获取每个第二访问请求对应的route参数,得到所述R个第二访问请求对应的R个route参数;
    根据所述R个route参数将所述R个第二访问请求进行划分,得到所述R个第二访问请求对应的T个第二访问请求集合,每个第二访问请求集合包括至少一个第二访问请求,所述至少一个第二访问请求对应的至少一个route参数均相同,所述T为大于1的整数,所述T为小于所述M的整数;
    根据route参数与网页服务器的映射关系确定所述T个第二访问请求集合中的每个第二访问请求集 合对应的网页服务器;
    调用预先存储的第二分配策略,所述第二分配策略用于将所述S个第三访问请求合理分配到所述P个网页服务器;
    根据所述第二分配策略确定所述S个第三访问请求中的每个第三访问请求对应的网页服务器。
  9. 根据权利要求8所述的方法,其特征在于,所述根据所述第二分配策略确定所述S个第三访问请求中的每个第三访问请求对应的网页服务器,包括:
    获取每个网页服务器对应的第二剩余访问请求数量,得到所述P个网页服务器对应的P个第二剩余访问请求数量;
    根据所述P个第二剩余访问请求数量从大到小的顺序将所述P个网页服务器进行排序,得到所述P个网页服务器对应的第三网页服务器序列;
    根据所述P个第二剩余访问请求数量对应的比值将所述S个第三访问请求划分为P个第三访问请求集合;
    确定每个第三访问请求集合包括的所述第三访问请求的数量,得到所述P个第三访问请求集合对应的P个第二数量;
    根据所述P个第二数量从大到小的数量将所述P个第三访问请求集合进行排序,得到所述P个第三访问请求集合对应的第四集合序列;
    确定每个第三访问请求集合对应的网页服务器,所述P个第三访问请求集合中的每个第三访问请求集合在所述第四集合序列中的位置与其对应的网页服务器在所述第三网页服务器序列中的位置是相同的。
  10. 一种服务器负载均衡装置,其特征在于,所述装置包括:
    获取单元,用于获取N个客户端发送的M个第一访问请求,每个客户端对应至少一个第一访问请求,所述N为大于1的整数,所述M为大于或等于所述N的整数;
    调用单元,用于调用预先存储的负载均衡策略,所述负载均衡策略用于将所述M个第一访问请求合理分配到P个网页服务器,所述P为大于1的整数,所述P为小于所述N的整数;
    确定单元,用于根据所述负载均衡策略确定所述M个第一访问请求中的每个第一访问请求对应的网页服务器;
    转发单元,用于将所述每个第一访问请求转发到其对应的网页服务器。
  11. 根据权利要求10所述的装置,其特征在于,在获取N个客户端发送的M个第一访问请求方面,所述获取单元具体用于:
    向所述N个客户端发送N个询问信息,每个询问信息用于指示其对应的客户端反馈预设时段内的至少一个第一访问请求,所述N个询问信息与所述N个客户端一一对应,所述预设时段的终止时刻为当前系统时刻,所述预设时段的时长小于或等于第一阈值;
    接收每个客户端针对其对应的询问信息发送的至少一个第一访问请求,得到所述N个客户端发送的所述M个第一访问请求。
  12. 根据权利要求10或11所述的装置,其特征在于,在调用预先存储的负载均衡策略方面,所述调用单元具体用于:
    获取第k次调用的负载均衡策略,所述第k次调用的负载均衡策略为第一负载均衡策略或第二负载均衡策略;
    若所述第k次调用的负载均衡策略为所述第一负载均衡策略,则确定第(k+1)次调用的负载均衡策略为所述第二负载均衡策略;
    若所述第k次调用的负载均衡策略为所述第二负载均衡策略,则确定第(k+1)次调用的负载均衡策略为所述第一负载均衡策略。
  13. 根据权利要求10或11所述的装置,其特征在于,在调用预先存储的负载均衡策略方面,所述调用单元具体用于:
    确定当前系统时刻是否处于第一时段;
    若所述当前系统时刻处于所述第一时段,则确定负载均衡策略为第一负载均衡策略;
    若所述当前系统时刻未处于所述第一时段,则确定负载均衡策略为第二负载均衡策略。
  14. 根据权利要求12或13所述的装置,其特征在于,所述负载均衡策略包括第一负载均衡策略和第二负载均衡策略,在根据所述负载均衡策略确定所述M个第一访问请求中的每个第一访问请求对应的网页服务器方面,所述确定单元具体用于:
    在所述负载均衡策略为所述第一负载均衡策略的情况下,获取每个第一访问请求对应的访问IP,得到所述M个第一访问请求对应的M个访问IP;
    根据所述M个访问IP将所述M个第一访问请求进行划分,得到所述M个第一访问请求对应的Q个第一访问请求集合,每个第一访问请求集合包括至少一个第一访问请求,所述至少一个第一访问请求对应的至少一个访问IP均属于同一访问IP段,所述Q为大于1的整数,所述Q为小于或等于所述M的整数;
    确定每个第一访问请求集合包括的所述第一访问请求的数量,得到所述Q个第一访问请求集合对应的Q个第一数量;
    获取每个网页服务器对应的第一访问请求数量,得到所述P个网页服务器对应的P个第一访问请求数量,每个第一访问请求数量为其对应的网页服务器在预设时长内能够处理的最大访问请求数量,所述预设时长小于或等于第二阈值;
    调用预先存储的第一分配策略,所述第一分配策略用于将所述Q个第一访问请求集合合理分配到所述P个网页服务器;
    根据所述第一分配策略、所述Q个第一数量和所述P个第一访问请求数量确定每个第一访问请求集合对应的网页服务器。
  15. 根据权利要求14所述的装置,其特征在于,在根据所述M个访问IP将所述M个第一访问请求进行划分,得到所述M个第一访问请求对应的Q个第一访问请求集合方面,所述确定单元具体用于:
    获取每个访问IP对应的子网掩码,得到所述M个访问IP对应的M个子网掩码,每个子网掩码对应一个第一访问请求;
    若子网掩码i与子网掩码j属于同一子网掩码段,则确定所述子网掩码i对应的访问IP与所述子网掩码j对应的访问IP属于同一访问IP段,所述子网掩码i和所述子网掩码j均为所述M个子网掩码中的其中一个;
    将所述子网掩码i对应的第一访问请求与所述子网掩码j对应的第一访问请求划分到同一个第一访问请求集合;
    对所述M个子网掩码中除所述子网掩码i和所述子网掩码j之外的(M-2)个子网掩码执行相同的操作,得到所述M个第一访问请求对应的所述Q个第一访问请求集合。
  16. 根据权利要求15所述的装置,其特征在于,在根据所述第一分配策略、所述Q个第一数量和所述P个第一访问请求数量确定每个第一访问请求集合对应的网页服务器方面,所述确定单元具体用于:
    根据所述P个第一访问请求数量从大到小的顺序将所述P个网页服务器进行一次排序,得到所述P个网页服务器对应的第一网页服务器序列;
    当P<Q<2P时,根据所述Q个第一数量从大到小的顺序将所述Q个第一访问请求集合进行排序,得到所述Q个第一访问请求集合对应的第一集合序列;
    将所述第一集合序列划分为第二集合序列和第三集合序列,所述第二集合序列包括P个第一访问请求集合,所述第三集合序列包括(Q-P)个第一访问请求集合;
    确定所述第二集合序列包括的所述P个第一访问请求集合中的每个第一访问请求集合对应的网页服务器,所述第二集合序列包括的所述P个第一访问请求集合中的每个第一访问请求集合在所述第二集合序列中的位置与其对应的网页服务器在所述第一网页服务器序列中的位置是相同的;
    获取每个网页服务器对应的第一剩余访问请求数量,得到所述P个网页服务器对应的P个第一剩余访问请求数量;
    根据所述P个第一剩余访问请求数量从大到小的顺序将所述P个网页服务器进行二次排序,得到所述P个网页服务器对应的第二网页服务器序列;
    确定所述第三集合序列包括的所述(Q-P)个第一访问请求集合中的每个第一访问请求集合对应的网页服务器,所述第三集合序列包括的所述(Q-P)个第一访问请求集合中的每个第一访问请求集合在所述第三集合序列中的位置与其对应的网页服务器在所述第二网页服务器序列中的位置是相同的。
  17. 根据权利要求12或13所述的装置,其特征在于,所述负载均衡策略包括第一负载均衡策略和第二负载均衡策略,在根据所述负载均衡策略确定所述M个第一访问请求中的每个第一访问请求对应的网页服务器方面,所述确定单元具体用于:
    在所述负载均衡策略为所述第二负载均衡策略的情况下,获取所述M个第一访问请求包括的R个第二访问请求和S个第三访问请求,每个第二访问请求均包括cookie信息,每个第三访问请求均不包括cookie信息;
    获取每个第二访问请求对应的route参数,得到所述R个第二访问请求对应的R个route参数;
    根据所述R个route参数将所述R个第二访问请求进行划分,得到所述R个第二访问请求对应的T个第二访问请求集合,每个第二访问请求集合包括至少一个第二访问请求,所述至少一个第二访问请求对应的至少一个route参数均相同,所述T为大于1的整数,所述T为小于所述M的整数;
    根据route参数与网页服务器的映射关系确定所述T个第二访问请求集合中的每个第二访问请求集合对应的网页服务器;
    调用预先存储的第二分配策略,所述第二分配策略用于将所述S个第三访问请求合理分配到所述P个网页服务器;
    根据所述第二分配策略确定所述S个第三访问请求中的每个第三访问请求对应的网页服务器。
  18. 根据权利要求17所述的装置,其特征在于,在根据所述第二分配策略确定所述S个第三访问请求中的每个第三访问请求对应的网页服务器方面,所述确定单元具体用于:
    获取每个网页服务器对应的第二剩余访问请求数量,得到所述P个网页服务器对应的P个第二剩余访问请求数量;
    根据所述P个第二剩余访问请求数量从大到小的顺序将所述P个网页服务器进行排序,得到所述P个网页服务器对应的第三网页服务器序列;
    根据所述P个第二剩余访问请求数量对应的比值将所述S个第三访问请求划分为P个第三访问请求集合;
    确定每个第三访问请求集合包括的所述第三访问请求的数量,得到所述P个第三访问请求集合对应的P个第二数量;
    根据所述P个第二数量从大到小的数量将所述P个第三访问请求集合进行排序,得到所述P个第三访问请求集合对应的第四集合序列;
    确定每个第三访问请求集合对应的网页服务器,所述P个第三访问请求集合中的每个第三访问请求集合在所述第四集合序列中的位置与其对应的网页服务器在所述第三网页服务器序列中的位置是相同的。
  19. 一种服务器,其特征在于,包括处理器、存储器、通信接口以及一个或多个程序,所述一个或多个程序被存储在所述存储器中,并且被配置由所述处理器执行,所述程序包括用于执行如权利要求1-9 任一项所述的方法中的部分或全部步骤的指令。
  20. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质用于存储计算机程序,所述计算机程序被处理器执行,以实现如权利要求1-9任一项所述的方法。
PCT/CN2019/101956 2019-06-14 2019-08-22 服务器负载均衡方法及相关设备 Ceased WO2020248363A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910514178.0 2019-06-14
CN201910514178.0A CN110311957B (zh) 2019-06-14 2019-06-14 服务器负载均衡方法及相关设备

Publications (1)

Publication Number Publication Date
WO2020248363A1 true WO2020248363A1 (zh) 2020-12-17

Family

ID=68075955

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/101956 Ceased WO2020248363A1 (zh) 2019-06-14 2019-08-22 服务器负载均衡方法及相关设备

Country Status (2)

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

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115701066A (zh) * 2021-07-14 2023-02-07 中移(成都)信息通信科技有限公司 一种域名访问方法、终端及存储介质
CN115801783A (zh) * 2022-10-19 2023-03-14 慧之安信息技术股份有限公司 一种物联网边缘端的负载均衡方法和系统

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101677319A (zh) * 2008-09-19 2010-03-24 华为技术有限公司 一种基于xmpp协议访问业务的方法、装置及系统
CN102624920A (zh) * 2012-03-31 2012-08-01 奇智软件(北京)有限公司 一种通过代理服务器进行访问的方法及装置
CN103188163A (zh) * 2011-12-31 2013-07-03 中国移动通信集团浙江有限公司 一种负载均衡方法及装置

Family Cites Families (6)

* 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
US8769541B2 (en) * 2009-12-31 2014-07-01 Facebook, Inc. Load balancing web service by rejecting connections
CN103401799A (zh) * 2013-07-30 2013-11-20 曙光信息产业(北京)有限公司 负载均衡的实现方法和装置
CN104579996A (zh) * 2013-10-17 2015-04-29 中国电信股份有限公司 一种集群负载均衡方法和系统
CN104811503A (zh) * 2015-05-21 2015-07-29 龙信数据(北京)有限公司 一种r统计建模系统
CN109347947A (zh) * 2018-10-15 2019-02-15 郑州云海信息技术有限公司 一种负载均衡的方法、域名服务器及集群nas服务器

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101677319A (zh) * 2008-09-19 2010-03-24 华为技术有限公司 一种基于xmpp协议访问业务的方法、装置及系统
CN103188163A (zh) * 2011-12-31 2013-07-03 中国移动通信集团浙江有限公司 一种负载均衡方法及装置
CN102624920A (zh) * 2012-03-31 2012-08-01 奇智软件(北京)有限公司 一种通过代理服务器进行访问的方法及装置

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115701066A (zh) * 2021-07-14 2023-02-07 中移(成都)信息通信科技有限公司 一种域名访问方法、终端及存储介质
CN115801783A (zh) * 2022-10-19 2023-03-14 慧之安信息技术股份有限公司 一种物联网边缘端的负载均衡方法和系统

Also Published As

Publication number Publication date
CN110311957B (zh) 2022-03-15
CN110311957A (zh) 2019-10-08

Similar Documents

Publication Publication Date Title
US11895154B2 (en) Method and system for virtual machine aware policy management
CN113037869B (zh) 用于内容分发网络系统的回源的方法和装置
WO2021098407A1 (zh) 基于mec的服务节点分配方法、装置及相关服务器
CN103945000B (zh) 一种负载均衡方法及负载均衡器
TWI507988B (zh) 伺服器及其分配用戶端設備更新韌體的方法
CN110086886B (zh) 动态会话保持方法及装置
CN108933829A (zh) 一种负载均衡方法及装置
Buyakar et al. Prototyping and load balancing the service based architecture of 5G core using NFV
US11102139B1 (en) Shared queue management utilizing shuffle sharding
CN106878197A (zh) 一种云平台消息传输的管理系统及方法
CN107579924A (zh) 一种流量调拨方法和装置
US20110153826A1 (en) Fault tolerant and scalable load distribution of resources
WO2023112012A4 (en) Traffic service threads for large pools of network addresses
CN103179009B (zh) 一种分布式管理系统的动态自适应调用方法
CN103401799A (zh) 负载均衡的实现方法和装置
WO2020248363A1 (zh) 服务器负载均衡方法及相关设备
CN106933671B (zh) 一种进行伸缩处理的方法、装置和系统
CN112261153A (zh) 一种网络资源的管理方法以及相关装置
CN116107760B (zh) 一种负载均衡方法、装置、设备及介质
CN104104611B (zh) 一种实现集群负载均衡调度的方法及装置
CN110995890B (zh) 域名请求的调度方法及装置
US11962643B2 (en) Implementing multiple load balancer drivers for a single load balancer
CN112954084B (zh) 边缘计算的处理方法、网络功能实例及边缘服务管控中心
CN114827159A (zh) 网络请求路径优化方法、装置、设备和存储介质
EP3993366A2 (en) Network load balancer, request message distribution method, program product and system

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19932363

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19932363

Country of ref document: EP

Kind code of ref document: A1