Load balancing scheduling method, load balancing device and related products
By detecting the connection status of the server in the load balancing device and dynamically selecting the server with normal connection status, the problem of inefficient connection establishment between the client and the server in the prior art is solved, and a higher connection success rate and efficiency are achieved.
Patent Information
- Application Number
- CN202411759006.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-03-28
AI Technical Summary
The existing load balancing scheduling method is inefficient in the connection establishment process between the client and the server, especially when the server connection state is abnormal, the possibility of connection establishment failure is high.
By introducing a connection status detection mechanism in the load balancing device, the server with normal connection status is dynamically selected to forward the connection establishment request according to the abnormal connection status of the server, thereby improving the connection success rate and efficiency.
It improves the success rate of connection establishment between the client and the server, reduces the possibility of connection establishment failure, and improves the overall connection efficiency.
Smart Images

Figure CN119728688A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to load balancing (LB) technology, and in particular to a load balancing scheduling method, a load balancing device and related products. Background Art
[0002] Load balancing scheduling refers to the process of evenly forwarding requests from multiple clients to multiple servers through reasonable allocation and scheduling. At present, load balancing scheduling can be achieved in the following way: when a client wants to access a server to obtain a service, the client can first send a connection establishment request to the load balancing device, and then the load balancing device can select a server from multiple servers according to a preset load balancing algorithm (such as a polling algorithm, a minimum connection algorithm, etc.), and forward the connection establishment request from the client to the above server, so that the server attempts to establish a connection with the client. Among them, if the server successfully establishes a connection with the client, the client can access the corresponding server through the above connection to obtain the service. On the contrary, if the server fails to establish a connection with the client, the load balancing device needs to re-determine other servers according to the load balancing algorithm to establish a connection between the client and the other servers. Thus, multiple clients can be connected to multiple servers, and through this connection, the requests of multiple clients can be evenly sent to multiple servers. It can be understood that the use of the above method may require the determination of multiple servers based on the load balancing algorithm, resulting in the need to perform connection operations between the client and multiple servers, which will affect the efficiency of establishing a connection between the client and the server. Summary of the invention
[0003] The present application provides a load balancing scheduling method, a load balancing device and related products, which can improve the efficiency of establishing a connection between a client and a server.
[0004] In the first aspect, the present application provides a load balancing scheduling method. The method can be applied to a load balancing device, wherein the load balancing device is connected to a client and multiple servers respectively. In a specific implementation, the load balancing device can receive a connection establishment request from a client, and then select a first server from multiple servers according to a preset load balancing algorithm. Afterwards, the load balancing device determines the connection status of the first server, and when the connection status of the first server is abnormal, selects a second server with a normal connection status from multiple servers according to the load balancing algorithm, and then sends the connection establishment request from the client to the second server, so that the second server establishes a connection with the above-mentioned client. Among them, the abnormal connection status of the first server indicates that the possibility of the first server successfully establishing a connection with the new client is small, and the normal connection status of the second server indicates that the possibility of the second server successfully establishing a connection with the new client is high.
[0005] In the technical solution provided by the present application, after the load balancing device selects a server from multiple servers based on the load balancing algorithm, it will also determine the possibility of the current server to successfully establish a connection with a new client according to the connection status of the server. Only when the possibility of the server to successfully establish a connection with the new client is high, the load balancing device will send the connection establishment request from the client to the above-mentioned server, thereby improving the success rate of establishing a connection between the client and the server, and thereby improving the efficiency of establishing a connection between the client and the server.
[0006] In a possible implementation, the load balancing device determines that the connection state of the first server is abnormal, including the following steps: when the current number of connections of the first server is equal to the maximum number of connections of the first server, the load balancing device determines that the connection state of the first server is abnormal. The current number of connections of the first server refers to the number of clients currently connected to the first server, and the maximum number of connections of the first server refers to the number of clients that can be connected to the first server at most.
[0007] In a possible implementation, the load balancing device may provide a configuration interface, and obtain the maximum number of connections set by the user for the first server through the configuration interface.
[0008] It is understandable that when the current number of connections of the first server is equal to the maximum number of connections of the first server, it means that the number of clients connected to the first server has reached the upper limit. In this case, even if the load balancing device sends a connection establishment request from the client to the first server, the first server cannot successfully establish a connection with the client. Through the above implementation, the load balancing device will not send an establishment request from the client to the first server where the above situation occurs, saving the time spent by the first server trying to establish a connection with the client and improving the efficiency of establishing a connection between the client and the appropriate server.
[0009] In one possible implementation, the load balancing device determines that the connection status of the first server is abnormal, including the following steps: the load balancing device determines that the connection status of the first server is abnormal based on the average time for the first server to successfully establish a connection with the client or the number of times the first server fails to establish a connection with the client.
[0010] It is understandable that when the average time for the first server to successfully establish a connection with the client is long, or the number of failed connections between the first server and the client is high, it means that the first server may have insufficient resources or a large number of unprocessed connection establishment requests. In this case, even if the load balancing device sends the connection establishment request from the client to the first server, the possibility of the first server successfully establishing a connection with the client is small. Through the above implementation method, the load balancing device will not send the establishment request from the client to the first server in the above situation, saving the time spent by the first server trying to establish a connection with the client and improving the efficiency of establishing a connection between the client and the appropriate server.
[0011] In a possible implementation, the load balancing device determines that the connection state of the first server is abnormal, including the following steps: when the state of the first server is abnormal, the load balancing device determines that the connection state of the first server is abnormal. The abnormal state of the first server depends on at least one of the following: the number of reset messages sent by the first server, the number of connections in the connecting state on the first server. The above reset message is used to instruct the first server to disconnect from the connected client.
[0012] It is understandable that the more reset messages sent by the first server, the more clients disconnected from the first server. In this case, the first server may be offline. Even if the load balancing device sends the connection establishment request from the client to the first server, the first server cannot successfully establish a connection with the client. The more connections in the connecting state on the first server, the more responses the first server has not returned to the client's connection establishment request. In this case, the first server may be stuck (i.e., the process being executed on the first server is paused or delayed). Even if the load balancing device sends the connection establishment request from the client to the first server, the possibility of the first server successfully establishing a connection with the client is small. Therefore, through the above implementation method, the load balancing device will not send the establishment request from the client to the first server where the above situation occurs, saving the time spent by the first server to try to establish a connection with the client, and improving the efficiency of establishing a connection between the client and the appropriate server.
[0013] In a possible implementation, the load balancing algorithm in the load balancing device includes a polling algorithm, a weighted polling algorithm, a least connection algorithm, a weighted least connection algorithm, and an algorithm for scheduling based on a hash value of an Internet Protocol (IP) address of a client.
[0014] In one possible implementation, when the load balancing algorithm in the load balancing device is a weighted least connection algorithm, the load balancing device selects a first server from multiple servers based on the load balancing algorithm, including the following steps: the load balancing device determines the first server based on the current weight and the current number of connections of each server in the multiple servers, wherein the current weight of each server is dynamically adjusted based on the weight set by the user for each server.
[0015] In a possible implementation, the load balancing device may provide a configuration interface, and obtain the weight set by the user for each of the above servers through the configuration interface.
[0016] In the above implementation, for a newly launched server, the load balancing device can gradually increase the current weight of the server to the weight value set by the user for the server, thereby preventing the load balancing device from forwarding a large number of connection establishment requests to the server in a short period of time.
[0017] In a possible implementation, when the connection status of the first server is normal, the load balancing device may send a connection establishment request from the client to the first server, so that the first server establishes a connection with the client. The normal connection status of the first server indicates that the first server is likely to successfully establish a connection with the new client.
[0018] In the second aspect, the present application provides a load balancing device. The device is connected to a client and multiple servers respectively. The device includes an acquisition module and a scheduling module. Among them, the acquisition module is used to receive a connection establishment request from the client. The scheduling module is used to select a first server from multiple servers according to a preset load balancing algorithm; determine the connection status of the first server; when the connection status of the first server is abnormal, select a second server with a normal connection status from multiple servers according to the load balancing algorithm, and send the connection establishment request from the client to the second server. Among them, the abnormal connection status of the first server indicates that the possibility of the first server successfully establishing a connection with the new client is small, and the normal connection status of the second server indicates that the possibility of the second server successfully establishing a connection with the new client is high.
[0019] In a possible implementation, the scheduling module is used to determine that the connection state of the first server is abnormal when the current number of connections of the first server is equal to the maximum number of connections of the first server. The current number of connections of the first server refers to the number of clients currently connected to the first server, and the maximum number of connections of the first server refers to the number of clients that can be connected to the first server at most.
[0020] In a possible implementation, the scheduling module is used to determine that the connection state of the first server is abnormal according to an average time for the first server to successfully establish a connection with the client or the number of times the first server fails to establish a connection with the client.
[0021] In a possible implementation, the scheduling module is used to determine that the connection state of the first server is abnormal when the state of the first server is abnormal. The abnormal state of the first server depends on at least one of the following: the number of reset messages sent by the first server and the number of connections in the connecting state on the first server. The reset message is used to instruct the first server to disconnect from the connected client.
[0022] In a possible implementation, the load balancing algorithm in the load balancing device includes a polling algorithm, a weighted polling algorithm, a least connection algorithm, a weighted least connection algorithm, and an algorithm for scheduling based on a hash value of a client IP address.
[0023] In one possible implementation, when the load balancing algorithm in the load balancing device is a weighted least connection algorithm, the scheduling module is used to determine the first server based on the current weight and the current number of connections of each server among multiple servers, wherein the current weight of each server is obtained by dynamically adjusting the weight set by the user for each server.
[0024] In a possible implementation, the scheduling module is further configured to send a connection establishment request from the client to the first server when the connection status of the first server is normal, so that the first server establishes a connection with the client. The normal connection status of the first server indicates that the first server is likely to successfully establish a connection with the new client.
[0025] In a third aspect, the present application provides a computing device, which includes a processor and a memory, wherein the processor is used to execute instructions stored in the memory, so that the computing device executes part or all of the method described in the first aspect and any implementation thereof.
[0026] In a fourth aspect, the present application provides a computing device cluster. The computing device cluster includes at least one computing device, and each computing device includes a processor and a memory. The processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster performs part or all of the method described in the first aspect and any implementation thereof.
[0027] In a fifth aspect, the present application provides a computer program product comprising instructions. The computer program product may be software or a program product comprising instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on a computing device, the computing device is caused to perform part or all of the method described in the first aspect and any one of its implementations.
[0028] In a sixth aspect, the present application provides a computer-readable storage medium. The computer storage medium includes computer program instructions, and when the computer program instructions are executed by a computing device, the computing device executes part or all of the method described in the first aspect and any implementation thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 It is a schematic diagram of a load balancing scheduling scenario provided by this application;
[0030] Figure 2 It is a schematic diagram of an application scenario provided by this application;
[0031] Figure 3 It is a flow chart of a load balancing scheduling method provided by the present application;
[0032] Figure 4 It is a structural diagram of a load balancing device provided by the present application;
[0033] Figure 5 It is a structural schematic diagram of a computing device provided by the present application;
[0034] Figure 6 It is a structural diagram of a computing device cluster provided by this application;
[0035] Figure 7 It is a structural diagram of another computing device cluster provided by this application. DETAILED DESCRIPTION
[0036] In order to solve the problem of low efficiency in establishing a connection between a client and a server, the present application provides a load balancing scheduling method. The method can be applied to a load balancing device, wherein the load balancing device is connected to multiple clients and multiple servers respectively, and the load balancing device can evenly connect multiple clients to multiple servers through the above connections. In a specific implementation, the load balancing device can receive a connection establishment request from a client, select a server from multiple servers according to a preset load balancing algorithm, and then determine the connection status of the server. If the connection status of the server is normal (that is, the server is more likely to successfully establish a connection with a new client), the load balancing device sends the above connection establishment request to the server to establish a connection between the above client and the server. If the connection status of the server is abnormal (that is, the server is less likely to successfully establish a connection with a new client), the load balancing device will send the above connection establishment request to other servers to establish a connection between the above client and other servers. In the above scheme, the load balancing device will not forward the connection establishment request from the client to the server with abnormal connection status, so there is no need to perform the connection operation between the client and the server with abnormal connection status, which improves the efficiency of connection establishment between the client and the appropriate server.
[0037] The technical solution provided by this application is introduced below in conjunction with the accompanying drawings.
[0038] See also Figure 1 , Figure 1 A schematic diagram of a load balancing scheduling scenario applicable to this application is shown. Figure 1 As shown, the scenario includes multiple clients 100, multiple servers 200 and a load balancing device 300, wherein the load balancing device 300 is respectively connected to the multiple clients 100 and the multiple servers 200 through a network, and the network can be a wide area network or a local area network.
[0039] The client 100 is used to initiate a request, and it can be deployed on a computing device, where the computing device can be a server, such as a central server in a cloud data center, an edge server, or a local server in a local data center, etc., or a virtual machine deployed on a server, or a terminal device, such as a smart phone, a tablet computer, a laptop, a desktop, an augmented reality (AR) device, a virtual reality (VR) device, a wearable device, a handheld processing device, an integrated handheld device, a smart conference device, a smart advertising device, a smart home appliance, etc. Exemplarily, the client 100 can be software or an application (APP) running on a terminal device controlled by a user, such as a personal computer (PC) client, an APP client, etc., or a browser-based World Wide Web (Web) client, a cloud management platform console, etc.
[0040] The server 200 is used to process the request sent by the client 100 to provide services to the client 100. Similar to the client 100, the server 200 can also be deployed on the above computing device. Exemplarily, the server 200 can be a web server, an application server, a database server, or a microservice instance, a containerized application, etc.
[0041] It is worth mentioning that Figure 1 The services provided by the multiple servers 200 shown may be the same, so any client 100 can obtain services by accessing any server 200. In order to avoid excessive load on a single server 200, the multiple clients 100 may establish connections with multiple servers 200 through a load balancing device 300, wherein the number of clients 100 connected to each server 200 is relatively small, thereby making the load difference of each server 200 relatively small.
[0042] The load balancing device 300 can be implemented by a single computing device or a computing device cluster consisting of multiple computing devices. The computing device here can be a server or a virtual machine, or a terminal device such as a desktop or laptop computer.
[0043] exist Figure 1In the scenario shown, the client 100 can send a connection establishment request to the load balancing device 300. After receiving the connection establishment request, the load balancing device 300 can select a first server from multiple servers 200 according to a preset load balancing algorithm, and then determine the connection status of the first server. If the connection status of the first server is normal, the load balancing device 300 will send the connection establishment request to the first server to establish a connection between the first server and the client 100. If the connection status of the first server is abnormal, the load balancing device 300 will select a second server from multiple servers 200 according to the load balancing algorithm, and then determine the connection status of the second server. If the connection status of the second server is normal, the load balancing device 300 will send the connection establishment request to the second server to establish a connection between the second server and the client 100. If the connection status of the second server is abnormal, the load balancing device 300 will select a third server from the multiple servers 200 according to the load balancing algorithm, and so on, until the connection status of the server selected by the load balancing device 300 is normal, and send the above-mentioned connection establishment request to the server with normal connection status to establish a connection between the above-mentioned client 100 and the server with normal connection status.
[0044] As a possible implementation, the load balancing device 300 can be deployed in a data center and provided to users as a cloud service based on the basic resources (including computing resources, storage resources, and network resources) in the data center. Figure 2 As shown, the user can register an account on the cloud management platform through the local client, log in to the cloud management platform through the account, and purchase the above cloud services on the cloud management platform. After the purchase is successful, the user can use the load balancing device 300 to establish connections between multiple clients 100 and multiple servers 200.
[0045] Next, taking a connection establishment request initiated by a client 100 (hereinafter referred to as the "target client") as an example, the process of implementing load balancing scheduling by the load balancing device 300 is described in detail. Figure 3 ,like Figure 3 As shown, the process includes the following steps:
[0046] Step 101: The target client sends a connection establishment request to the load balancing device 300. Accordingly, the load balancing device 300 receives the connection establishment request sent by the target client.
[0047] The connection establishment request is used to indicate the establishment of a connection between the target client and the server 200. In a specific implementation, the connection may be a Transmission Control Protocol (TCP) connection, in which case the connection establishment request may be a synchronize sequence numbers (SYN) message in a TCP three way handshake.
[0048] It is worth noting that the connection between the target client and the server 200 can be other types of connections besides a TCP connection, such as a User Datagram Protocol (UDP) connection or a remote procedure call (RPC) connection, etc. For ease of description, the following embodiments are all introduced by taking a TCP connection as an example.
[0049] Step 102: The load balancing device 300 selects a first server from multiple servers 200 according to a load balancing algorithm.
[0050] In a specific implementation, a load balancing algorithm is configured in the load balancing device 300, and the algorithm can be configured by the user according to business requirements, or it can be the load balancing algorithm used by default in the load balancing device 300. When the load balancing algorithm in the load balancing device 300 is obtained by user configuration, the load balancing device 300 can obtain the load balancing algorithm in the following manner: the load balancing device 300 provides a configuration interface, and the interface can be implemented through an application programming interface (application programming interface, API) or a graphical user interface (graphical user interface, GUI). The load balancing device 300 can provide multiple candidate load balancing algorithms to the user through the above configuration interface, and then the user can select a suitable load balancing algorithm from the above multiple candidate load balancing algorithms according to business requirements, and provide the selected load balancing algorithm through the above configuration interface, so that the load balancing device 300 can obtain the load balancing algorithm configured by the user.
[0051] Exemplarily, the load balancing algorithm in the load balancing device 300 can be a round robin algorithm, a least connections algorithm, a weighted round robin algorithm, a weighted least connections algorithm, or an algorithm for scheduling based on a hash value of a client IP address (hereinafter referred to as a "source IP hash algorithm"). The following describes the above-mentioned algorithms and how to implement "selecting a first server from multiple servers 200" based on these algorithms:
[0052] 1) The polling algorithm is used to instruct that connection establishment requests from multiple clients 100 are sent to multiple servers 200 in turn.
[0053] When the load balancing algorithm in the load balancing device 300 is a polling algorithm, the load balancing device 300 will cache the identifier of the server 200 selected last time, wherein the server 200 selected last time refers to the server 200 assigned by the load balancing device 300 to the previously received connection establishment request, and the identifier of the server 200 selected last time can be the ID or name of the server 200 and other information that can uniquely indicate the server 200. In this way, after the load balancing device 300 receives the connection establishment request from the target client, it can select the first server from multiple servers 200 according to the identifier of the server 200 selected last time.
[0054] For example, assume that there are n servers 200, and the n servers are server 1, server 2, ..., server n, where n is an integer greater than 1. If server m was selected last time, the first server may be server m+1, where m is an integer less than n; if server n was selected last time, the first server may be server 1.
[0055] 2) The minimum connection algorithm is used to instruct that the connection establishment request from the client 100 is sent to the server 200 with the least current connection number. The current connection number of the server 200 refers to the number of clients 100 currently connected to the server 200.
[0056] When the load balancing algorithm in the load balancing device 300 is the minimum connection algorithm, the load balancing device 300 can determine the server 200 with the least current connection number according to the current connection number of each server 200, and the server 200 is the first server.
[0057] For the current number of connections of each server 200, the load balancing device 300 can determine the client 100 connected to the server 200 by monitoring the communication messages between the server 200 and the client 100, and further determine the current number of connections of the server 200. When the communication messages between the server 200 and the client 100 include a SYN message, an acknowledgement (ACK) message, and a SYN-ACK message, it indicates that the connection between the server 200 and the client 100 is successfully established, that is, the server 200 is connected to the client 100. On the contrary, when the communication messages between the server 200 and the client 100 include only one or two of the SYN message, the SYN-ACK message, and the ACK message, it indicates that the connection between the server 200 and the client 100 fails to be established, that is, the server 200 and the client 100 are not connected.
[0058] 3) The weighted polling algorithm is used to indicate that the connection establishment requests from multiple clients 100 are sent to multiple servers 200 in turn according to the weight of the server 200 and the current number of connections of the server 200, so that the server 200 can process the connection establishment requests with corresponding weight values. Among them, the weight of the server 200 can be a value set by the user based on the processing capacity of the server 200 (such as the configuration of the server 200 and the business running on the client 100). In general, the server 200 with a higher weight can establish connections with more clients 100.
[0059] When the load balancing algorithm in the load balancing device 300 is a weighted polling algorithm, the load balancing device 300 will cache the identifier of the server 200 selected last time, as well as the weight and current number of connections of each server 200. Among them, the load balancing device 300 can obtain the weight of each server 200 in the following manner: the load balancing device 300 provides a configuration interface, which can be implemented through an API or a GUI. The user can set a weight for each server 200 through the configuration interface. Correspondingly, the load balancing device 300 can also receive the weight set by the user for each server 200 through the above configuration interface. It should be noted that, for the sake of brevity, the process of how the load balancing device 300 obtains the current number of connections of each server 200 is no longer introduced here. For details, please refer to the previous text.
[0060] Therefore, after the load balancing device 300 receives a connection establishment request from the target client, it can determine the weight and the current number of connections of the server 200 based on the identifier of the server 200 selected last time, wherein the identifier of the server 200 selected last time is associated with the weight and the current number of connections of the server 200, and then determine the first server based on the weight of the server 200 selected last time and the current number of connections of the server 200.
[0061] Still using the above example for illustration, assume that the weight of server m is k, where k is an integer greater than 0. If the current number of connections of server m is less than k, the first server is determined to be server m; if the current number of connections of server m is equal to k, the first server is determined to be server m+1.
[0062] 4) The weighted least connection algorithm is used to indicate that the connection establishment requests from multiple clients 100 are sent to multiple servers 200 according to the weight of the server 200 and the current number of connections.
[0063] When the load balancing algorithm in the load balancing device 300 is a weighted least connection algorithm, the load balancing device 300 can determine the first server according to the weight and current number of connections of each server 200. More specifically, the load balancing device 300 can calculate the ratio of the current number of connections of each server 200 to its corresponding weight, and determine the server 200 with the smallest ratio as the first server.
[0064] It should be noted that, for the sake of brevity, the process of how the load balancing device 300 obtains the weight of each server 200 and the current number of connections is not introduced here. Please refer to the previous text for details.
[0065] Furthermore, considering the following situations that may exist in practical applications: Figure 1 The multiple servers 200 shown include a newly launched server (such as a newly expanded server or a re-launched server, where the server online means that the server can operate normally and provide services), then in the server online stage (that is, the server health check changes from closed to open), the server will be the server 200 with the least current connections among the multiple servers 200. If a large number of clients 100 send connection establishment requests during this stage, all of these connection establishment requests will be sent to the newly launched server based on the weighted least connection algorithm, which will cause the server to be overloaded, and then cause subsequent connection establishment failures. Based on this, the load balancing device 300 can determine the first server through the following steps when the load balancing algorithm is the weighted least connection algorithm:
[0066] The load balancing device 300 selects a first server from the multiple servers 200 according to the current weight and the current number of connections of each server 200. The first server is the server 200 with the smallest ratio of the current number of connections to the current weight among the multiple servers 200, and the current weight of the server 200 is a value obtained by dynamically adjusting the weight set by the user for the server (hereinafter referred to as "configuration value").
[0067] In a specific implementation, the load balancing device 300 can obtain the current weight of each server 200 in the following manner: the load balancing device 300 provides a configuration interface, which can be implemented through an API or a GUI. The user can set the weight for each server 200 through the above configuration interface and based on the processing capacity of each server 200. Accordingly, the load balancing device 300 can obtain the weight set by the user for each server 200 through the above configuration interface. For each server 200, when it is detected that the server 200 is online, the load balancing device 300 will gradually increase the current weight of the server 200 from the minimum value (such as 1) to the configuration value within a preset time. The preset time here can be set by the load balancing device 300 or by the user on the above configuration interface. In this way, the load balancing device 300 can obtain the current weight of each server 200, wherein the current weight of the server 200 is less than or equal to the configuration value. In addition, for the "detection of whether the server 200 is online" involved in the above process, the load balancing device 300 can be implemented in the following way: the load balancing device 300 periodically sends a health detection message to the server 200. If the server 200 returns a response to the load balancing device, it is determined that the server 200 is online. If the server 200 does not return a response to the load balancing device 300, it is determined that the server 200 is not online.
[0068] It is understandable that, as the weight of the server 200 is greater, the ratio of the current number of connections of the server 200 to the weight is smaller, and the server is more likely to be the server 200 with the smallest ratio of the current number of connections to the weight among multiple servers 200. However, through the above method, when the server 200 is newly online, since the load balancing device 300 has not yet adjusted the current weight of the server to the configuration value, the current weight of the server is less than the configuration value at this time, and the ratio of the current number of connections of the server to the current weight is less than the ratio of the current number of connections of the server to the configuration value. In this case, the more likely the server is not the server 200 with the smallest ratio of the current number of connections to the weight among multiple servers 200, the load balancing device 300 will not continue to send connection establishment requests to the server. In other words, through the above method, it is possible to avoid the situation where an excessive number of connection establishment requests are sent to the server due to the server 200 being newly online, thereby improving the efficiency of successfully establishing a connection.
[0069] 5) The source IP hash algorithm is used to indicate that connection establishment requests from multiple clients 100 are sent to multiple servers 200 according to the hash value of the IP address of the client 100.
[0070] When the load balancing algorithm in the load balancing device 300 is a source IP hash algorithm, the load balancing device 300 can obtain the IP address of the target client according to the connection establishment request from the target client, and then use a hash algorithm (such as a secure hash algorithm (SHA), a message digest algorithm 5 (MD5), etc.) to calculate the hash value of the IP address of the target client, and then calculate the remainder of dividing the hash value by the number of servers, and determine the first server according to the remainder.
[0071] It should be understood that the above examples only introduce several load balancing algorithms that may be used by the load balancing device 300, and how to determine the first server based on these load balancing algorithms. However, in actual applications, the load balancing device 300 may also use other load balancing algorithms and determine the first server based on other load balancing algorithms, which is not limited in this application.
[0072] Step 103, the load balancing device 300 determines the connection status of the first server. When the connection status of the first server is normal, steps 104 to 105 are executed; when the connection status of the first server is abnormal, steps 106 to 107 are executed.
[0073] The connection state of the first server is used to characterize the possibility that the first server can successfully establish a connection with a new client, where "new client" refers to a client 100 that has not successfully established a connection with the first server. The connection state of the first server includes two situations: normal and abnormal. When the connection state of the first server is normal, it means that the first server is more likely to successfully establish a connection with the new client, and when the connection state of the first server is abnormal, it means that the first server is more likely to fail to establish a connection with the new client.
[0074] The connection status of the first server depends on one or more of the following factors: the current number of connections of the first server, the number of times the first server fails to establish a connection with the client, the average time for the first server to successfully establish a connection with the client, and the status of the first server. Next, based on the above-mentioned factors, the normal and abnormal connection status of the first server are introduced respectively.
[0075] 1) The connection status of the first server is abnormal
[0076] In a specific implementation, when one or more of the following first conditions are met, it can be determined that the connection state of the first server is abnormal:
[0077] ① The current number of connections of the first server is equal to the maximum number of connections of the first server.
[0078] The current number of connections of the first server refers to the number of clients 100 currently connected to the first server. In specific implementation, the way in which the load balancing device 300 obtains the current number of connections of the first server can be referred to the relevant introduction of step 102, which will not be repeated here for brevity.
[0079] The maximum number of connections of the first server refers to the number of clients 100 that can be connected to the first server at most. In a specific implementation, the load balancing device 300 can obtain the maximum number of connections of the first server in the following manner: the load balancing device 300 provides a configuration interface, which can be implemented through an API or a GUI, and the user can set the maximum number of connections for each server 200 through the configuration interface and based on the processing capacity of each server 200. Accordingly, the load balancing device 300 can receive the maximum number of connections set by the user for each server 200 through the above configuration interface, and associate the maximum number of connections of each server 200 with the identifier of each server 200 and store them. In this way, after the load balancing device 300 determines the first server by executing step 102, it can determine the maximum number of connections of the first server according to the identifier of the first server.
[0080] It is understandable that when the current number of connections of the first server is equal to the maximum number of connections of the first server, it means that the number of clients currently connected to the first server has reached the upper limit, that is, the current first server cannot successfully establish a connection with a new client. Therefore, when condition ① is met, it can be determined that the connection status of the first server is abnormal.
[0081] ② The number of times the first server fails to establish a connection with the client is greater than the first preset number.
[0082] The number of times the first server fails to establish a connection with the client refers to the number of clients 100 that fail to establish a connection with the first server within a preset time, where the preset time can be set by the user or by the load balancing device 300. Similarly, the first preset number of times can also be set by the user or by the load balancing device 300. When the preset time and the first preset number of times are set by the user, the load balancing device 300 can obtain the preset time and the first preset number of times in the following manner: the load balancing device 300 provides a configuration interface, which can be implemented through an API or a GUI, and the user can set the preset time and the first preset number of times through the configuration interface. Accordingly, the load balancing device 300 can obtain the preset time and the first preset number of times set by the user through the above configuration interface.
[0083] In a specific implementation, the load balancing device 300 can determine the client 100 that failed to establish a connection with the first server by monitoring the communication messages between the first server and different clients 100, and further determine the number of times the first server failed to establish a connection with the client. Specifically, taking the communication messages between the first server and a client 100 as an example, if the load balancing device 300 monitors that the communication messages between the client and the first server only include one or two of the SYN message, the SYN-ACK message, and the ACK message, it indicates that the connection establishment between the client and the first server failed. At this time, the load balancing device 300 can record the identifier of the client (such as the IP address of the client) and the time when the connection establishment failed, so that the load balancing device 300 can query the client 100 that failed to establish a connection with the first server within a preset time, and further determine the number of clients 100 that failed to establish a connection with the first server within a preset time (i.e., the number of times the first server failed to establish a connection with the client).
[0084] It can be understood that when the number of times the first server fails to establish a connection with the client is greater than the first preset number, it means that the connection establishment between the first server and the client often fails, then the possibility of the first server failing to establish a connection with a new client will be greater. Therefore, when condition ② is met, it can be determined that the connection status of the first server is abnormal.
[0085] ③ The average time for the first server to successfully establish a connection with the client is greater than the first time threshold.
[0086] The average time for the first server to successfully establish a connection with the client is the ratio of the total time consumed by the first server to successfully establish a connection with at least one client to the number of the at least one client, wherein the at least one client may be a client 100 that successfully establishes a connection with the first server within a preset time, and the preset time here may be set by the user or by the load balancing device 300. Similarly, the first time threshold may also be set by the user or by the load balancing device 300. When the preset time and the first time threshold are set by the user, the load balancing device 300 may obtain the preset time and the first time threshold in the following manner: the load balancing device 300 provides a configuration interface, which may be implemented through an API or a GUI, and the user may set the preset time and the first time threshold through the configuration interface. Accordingly, the load balancing device 300 may obtain the preset time and the first time threshold set by the user through the above configuration interface.
[0087] In a specific implementation, the load balancing device 300 can obtain the average time for the first server to successfully establish a connection with the client in the following manner: the load balancing device 300 determines the client 100 that has successfully established a connection with the first server by monitoring the communication messages between the first server and the client 100, and records the time spent on the connection establishment. Taking the communication messages between the first server and a client 100 as an example, if the load balancing device 300 monitors that the communication messages between the client and the first server include a SYN message, a SYN-ACK message, and an ACK message, it means that the client has successfully established a connection with the first server, and the load balancing device 300 can record the time when the connection between the client and the first server is established. Afterwards, the load balancing device 300 obtains the total time spent on the first server to successfully establish a connection with at least one client 100 based on the time when the first server successfully establishes a connection with each client 100, and then calculates the ratio of the total time to the number of the at least one client 100 to determine the average time for the first server to successfully establish a connection with the client.
[0088] It is understandable that when the average time for the first server to successfully establish a connection with the client is greater than the first time threshold, it means that the first server is slow in responding to the connection establishment request sent by the client, that is, the first server may currently have insufficient resources or a large number of unprocessed connection establishment requests. In this case, the first server is less likely to successfully establish a connection with a new client. Therefore, when condition ③ is met, it can be determined that the connection status of the first server is abnormal.
[0089] ④The status of the first server is abnormal.
[0090] The abnormal state of the first server means that the first server cannot provide services normally, and thus cannot connect to a new client. The abnormal state of the first server may include the first server going offline or the first server being stuck, wherein the first server going offline means that the first server stops providing services, and the first server being stuck means that the process being executed on the first server is paused or delayed, such as the first server being overloaded. It is understandable that when the first server goes offline, the first server will not be able to respond to the connection establishment request (i.e., SYN message) sent by the new client, and thus cannot successfully establish a connection with the new client. Similarly, when the first server is stuck, the possibility of the first server responding to the connection establishment request (i.e., SYN message) sent by the new client within the specified time is small, which leads to a greater possibility of failure to connect to the new client. Therefore, when condition ④ is met, it can be determined that the connection state of the first server is abnormal.
[0091] In a specific implementation, when the first server goes offline, the first server will send at least one reset message to the load balancing device 300, wherein each reset message is used to instruct the first server to disconnect from a connected client, where the client connected to the first server refers to the client 100 connected to the first server before the first server goes offline. That is, when the first server goes offline, the number of reset messages sent by the first server received by the load balancing device 300 will increase.
[0092] When the first server is stuck, after receiving the connection establishment request, the first server cannot return the corresponding SYN-ACK message in time. At this time, the connection between the first server and the client is in the connecting state (i.e., SYN_RECV state). In other words, when the connection between the first server and a certain client 100 is in the SYN_RECV state, it means that the client has sent a SYN message to the first server, but the first server has not yet returned a SYN-ACK message to the client. Therefore, when the first server is stuck, the number of connections in the SYN_RECV state on the first server will increase.
[0093] Therefore, the load balancing device 300 can determine the state of the first server according to the number of reset messages sent by the first server (hereinafter referred to as the "first number") and the number of connections in the SYN_RECV state on the first server (hereinafter referred to as the "second number"). Among them, when the first number and / or the second number increases significantly in a short period of time, it indicates that the state of the first server is abnormal. Exemplarily, the load balancing device 300 can determine whether the first number and / or the second number increases significantly in a short period of time in the following manner: the load balancing device 300 performs a calculation operation (such as a weighted sum operation) on the first number and the second number within a preset time. When the calculated value is greater than the preset value, it is determined that the first number and / or the second number increases significantly in a short period of time. The preset time and preset value here can be set by the user or by the load balancing device 300.
[0094] 2) The connection status of the first server is normal
[0095] In a specific implementation, when one or more of the following second conditions are met, it can be determined that the connection state of the first server is abnormal:
[0096] ① The current number of connections of the first server is less than the maximum number of connections of the first server.
[0097] It is understandable that when the current number of connections of the first server is less than the maximum number of connections of the first server, it means that the first server can still successfully establish a connection with a new client. Therefore, when condition ① is met, it can be determined that the connection status of the first server is normal.
[0098] ② The number of times the first server fails to establish a connection with the client is less than the second preset number.
[0099] The second preset number of times may be less than or equal to the first preset number of times. Moreover, similar to the setting method of the first preset number of times, the second preset number of times may also be set by the user or by the load balancing device 300, as described above.
[0100] It can be understood that when the number of failures in establishing a connection between the first server and the client is less than the second preset number, it means that the connection between the first server and the client is often successfully established, then the possibility of the first server successfully establishing a connection with a new client will be greater. Therefore, when condition ② is met, it can be determined that the connection status of the first server is normal.
[0101] ③ The average time for the first server to successfully establish a connection with the client is less than the second time threshold.
[0102] The second time threshold may be less than or equal to the first time threshold. Moreover, similar to the setting method of the first time threshold, the second time threshold may also be set by the user or by the load balancing device 300, as described above.
[0103] It is understandable that when the average time for the first server to successfully establish a connection with the client is less than the second time threshold, it means that the first server can quickly respond to the connection establishment request from the client, that is, the resources of the first server are sufficient, the number of unprocessed connection establishment requests is small, and it can successfully establish a connection with other clients. Therefore, when condition ③ is met, it can be determined that the connection status of the first server is normal.
[0104] ④The status of the first server is normal.
[0105] It can be understood that the normal status of the first server means that the first server can provide services normally and can connect to new clients. Therefore, when condition ④ is met, it can be determined that the connection status of the first server is normal.
[0106] In a specific implementation, the load balancing device 300 can determine that the status of the first server is normal in the following manner: the load balancing device 300 performs a calculation operation (such as a weighted sum operation) on the first quantity and the second quantity within a preset time. When the calculated value is less than or equal to the preset value, it indicates that the first quantity and / or the second quantity has not increased significantly in a short period of time, thereby determining that the status of the first server is normal.
[0107] In a possible implementation, it is considered that the first server determined based on the polling algorithm, the weighted polling algorithm or the source IP hash algorithm may have the following situation: the current number of connections of the first server has reached the upper limit of the number of clients that the first server can connect to. In this case, even if the connection establishment request from the target client is sent to the first server, the first server cannot establish a connection with the target client. Based on this, the load balancing device 300 can determine the connection status of the first server by comparing the current number of connections of the first server and the maximum number of connections of the first server when the load balancing algorithm is a polling algorithm, a weighted polling algorithm or a source IP hash algorithm. In this way, when the connection status of the first server is abnormal, the load balancing device 300 will not send the connection establishment request from the target client to the first server, which saves the process of the first server trying to establish a connection with the target client and improves the efficiency of successfully establishing a connection.
[0108] In another possible implementation, the following situation may exist in actual application: at least one first condition and at least one second condition are satisfied at the same time. In this case, the load balancing device 300 can determine the connection status of the first server in the following manner: the load balancing device 300 is configured with the priorities of the above-mentioned multiple first conditions and the priorities of the above-mentioned multiple second conditions. When at least one first condition and at least one second condition are satisfied at the same time, the load balancing device 300 can determine the connection status of the first server according to the condition with a higher priority. Among them, the priorities of the multiple first conditions and the priorities of the multiple second conditions can be set by the user through the configuration interface provided by the load balancing device 300, and according to business requirements and the load balancing algorithm configured in the load balancing device 300. For example, when the load balancing algorithm in the load balancing device 300 is a polling algorithm or a weighted polling algorithm, the priority of the relationship between the current number of connections of the first server and the maximum number of connections of the first server can be higher than the priority of the relationship between the current number of connections of the first server and the number of connections corresponding to the current weight of the first server.
[0109] Step 104 : The load balancing device 300 sends a connection establishment request to the first server. Correspondingly, the first server receives the connection establishment request sent by the load balancing device 300 .
[0110] Step 105: The first server establishes a connection with the target client according to the connection establishment request from the target client.
[0111] Specifically, after receiving the connection establishment request from the target client, the first server generates a SYN-ACK message according to the request, and then forwards the SYN-ACK message to the target client through the load balancing device 300. After receiving the above SYN-ACK message, the target client generates an ACK message according to the message, and then forwards the ACK message to the first server through the load balancing device 300, thereby establishing a connection between the first server and the target client.
[0112] Step 106 : The load balancing device 300 determines a second server and sends a connection establishment request from the target client to the second server. Accordingly, the second server receives the connection establishment request sent by the load balancing device 300 .
[0113] Specifically, the load balancing device 300 selects a second server from the multiple servers 200 according to the load balancing algorithm, and then determines that the connection status of the second server is normal, and then sends a connection establishment request from the target client to the second server. It should be noted that for the sake of brevity, the process of the load balancing device 300 determining the second server according to the load balancing algorithm and the process of determining that the connection status of the second server is normal are not described here. For details, please refer to the relevant description of step 102 and step 103.
[0114] It is understandable that in actual applications, the connection status of the second server may still be abnormal. In this case, the load balancing device 300 needs to further select other server 200 from multiple server 200 according to the load balancing algorithm, and determine whether the connection status of the server 200 is normal. However, for the sake of ease of description, the normal connection status of the second server is used as an example for subsequent introduction.
[0115] Step 107: The second server establishes a connection with the target client according to the connection establishment request from the target client.
[0116] Specifically, after receiving the connection establishment request from the target client, the second server generates a SYN-ACK message according to the request, and then forwards the SYN-ACK message to the target client through the load balancing device 300. After receiving the above SYN-ACK message, the target client generates an ACK message according to the message, and then forwards the ACK message to the second server through the load balancing device 300, thereby establishing a connection between the second server and the target client.
[0117] It can be seen that through the above steps 101 to 107, the load balancing device 300 will not forward the connection establishment request from the client 100 to the server 200 with an abnormal connection status, thereby saving the time spent on attempting to connect between the client and the server with an abnormal connection status, thereby improving the efficiency of establishing a connection between the client and the appropriate server.
[0118] Combination of the above Figures 1 to 3 The load balancing scheduling method provided by this application is described in detail. Figure 4 The structure of the load balancing device 300 for executing the above method is introduced.
[0119] See also Figure 4 , Figure 4 FIG. 3 shows a schematic diagram of the structure of a load balancing device 300. Figure 4 As shown, the load balancing device 300 includes an acquisition module 301 and a scheduling module 302 .
[0120] The acquisition module 301 is used to perform the steps of receiving the connection establishment request sent by the target client in the above step 101; providing a configuration interface and receiving the relevant steps of the user's configuration through the configuration interface; receiving the SYN-ACK message sent by the first server (or the second server), and receiving the ACK message sent by the target client. The scheduling module 302 is used to perform the steps of forwarding the SYN-ACK message to the target client and forwarding the ACK message to the first server (or the second server) in the above steps 102, 103, 104, 106, and 105 and 107.
[0121] It can be understood that the specific details of any possible implementation method of each module of the above-mentioned load balancing device 300 executing related steps can refer to the relevant content of the aforementioned method embodiment, and will not be repeated here.
[0122] In a specific implementation, the acquisition module 301 and the scheduling module 302 can be implemented by software or hardware. For example, the implementation of the acquisition module 301 is described below by taking the acquisition module 301 as an example. Similarly, the implementation of the scheduling module 302 can refer to the implementation of the acquisition module 301.
[0123] As an example of a software functional unit, the acquisition module 301 may include code running on a computing instance. Among them, the computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Further, the above-mentioned computing instance may be one or more. For example, the acquisition module 301 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region (region) or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including a data center or multiple data centers with similar geographical locations. Among them, usually a region may include multiple AZs.
[0124] Similarly, multiple hosts / virtual machines / containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Usually, a VPC is set up in a region. For cross-region communication between two VPCs in the same region and between VPCs in different regions, a communication gateway needs to be set up in each VPC to achieve interconnection between VPCs through the communication gateway.
[0125] As an example of a hardware functional unit, the acquisition module 301 may include at least one computing device, such as a server, etc. The acquisition module 301 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The above-mentioned PLD may be implemented by a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.
[0126] The multiple computing devices included in the acquisition module 301 can be distributed in the same region or in different regions. The multiple computing devices included in the acquisition module 301 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the acquisition module 301 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
[0127] It should be noted that, in other embodiments, the acquisition module 301 can be used to execute any step in the above-mentioned load balancing scheduling method, and the scheduling module 302 can be used to execute any step in the above-mentioned load balancing scheduling method. The steps that the acquisition module 301 and the scheduling module 302 are responsible for implementing can be specified as needed, and the acquisition module 301 and the scheduling module 302 respectively implement different steps in the above-mentioned load balancing scheduling method to realize all functions of the load balancing device 300.
[0128] The present application also provides a computing device, which may be a server, such as a server in a cloud data center, an edge server, or a local server in a local data center, or a terminal device such as a desktop computer, a laptop computer, or a smart phone.
[0129] See also Figure 5 , Figure 5 The schematic diagram of the structure of a computing device is shown as an example. Figure 5 As shown, the computing device 400 includes a bus 401, a processor 402, a memory 403, and a communication interface 404, wherein the processor 402, the memory 403, and the communication interface 404 communicate with each other through the bus 401. It should be understood that the present application does not limit the number of processors 402 and memories 403 in the computing device 400, that is, the computing device 400 may include one or more processors 402, and one or more memories 403, but for the convenience of description Figure 6 Only one processor 402 and one memory 403 are shown. The following describes each part of the computing device 400 separately.
[0130] The bus 401 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For convenience of representation, Figure 5Although only one line is used in the figure, this does not mean that the computing device 400 has only one bus or one type of bus. The bus 401 may include a path for transmitting information between various components of the computing device 400 (eg, the processor 402, the memory 403, and the communication interface 404).
[0131] The processor 402 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0132] The memory 403 may include a volatile memory, such as a random access memory (RAM). The memory 403 may also include a non-volatile memory, such as an SSD, a flash memory, a read-only memory (ROM) or a hard disk drive (HDD).
[0133] The memory 403 stores executable codes. The processor 402 executes the codes stored in the memory 403 to respectively implement the functions of the acquisition module 301 and the scheduling module 302, thereby implementing the load balancing scheduling method. In other words, the memory 403 stores instructions for executing the load balancing scheduling method.
[0134] The communication interface 404 uses a transceiver module such as but not limited to a network interface card or a transceiver to implement communication between the computing device 400 and other devices or a communication network. For example, the computing device 400 can communicate with the client 100 through the communication interface 404 to obtain the original video and hairstyle editing request.
[0135] It should be understood that the computing device 400 provided in the present application may correspond to the load balancing device 300 described above, and the functions of the various components in the computing device 400 are respectively to implement Figure 3 For the sake of brevity, the corresponding processes of each step in the method shown are not repeated here.
[0136] The present application also provides a computing device cluster. The computing device cluster includes at least one computing device, and the computing device in the computing device cluster can be a server, such as a central server in a cloud data center, an edge server, or a local server in a local data center. In some embodiments, the computing device in the computing device cluster can also be a terminal device such as a desktop computer, a laptop computer, or a smart phone.
[0137] See also Figure 6 , Figure 6 The following is a schematic diagram showing the structure of a computing device cluster. Figure 6 As shown, the computing device cluster includes at least one computing device 400. The memory 403 of one or more computing devices 400 in the computing device cluster may store the same instructions for executing the above load balancing scheduling method.
[0138] In some possible implementations, the memory 403 of one or more computing devices 400 in the computing device cluster may also store partial instructions for executing the above-mentioned load balancing scheduling method. In other words, the combination of one or more computing devices 400 can jointly execute the instructions of the load balancing scheduling method described above.
[0139] It should be noted that the memory 403 in different computing devices 400 in the computing device cluster may store different instructions, which are respectively used to execute part of the functions of the load balancing device 300. That is, the instructions stored in the memory 403 in different computing devices 400 can implement the functions of at least one of the acquisition module 301 and the scheduling module 302.
[0140] In some possible implementations, one or more computing devices 400 in the computing device cluster may be connected via a network, which may be a wide area network or a local area network, etc. Figure 7 A possible implementation is shown. Figure 7 As shown, computing device 400A and computing device 400B are connected via a network. Specifically, they are connected to the network via communication interfaces in computing device 400A and computing device 400B. In this implementation, the memory 403 in computing device 400A stores instructions for implementing the functions of acquisition module 301, and the memory 403 in computing device 400B stores instructions for implementing the functions of scheduling module 302.
[0141] Figure 7 The connection method between the computing devices 400 in the computing device cluster shown may be that considering that the load balancing scheduling method provided in the present application needs to perform a large amount of calculations, it is considered to hand over the functions of the scheduling module 302 to the computing device 400B for execution.
[0142] It should be understood that Figure 7 The functionality of the computing device 400A shown may also be performed by multiple computing devices 400. Similarly, the functionality of the computing device 400B may also be performed by multiple computing devices 400.
[0143] It should also be understood that the computing device cluster provided in the present application may correspond to the load balancing device 300 described above, and the functions of the various components in the computing device cluster are respectively to implement Figure 3 For the sake of brevity, the corresponding processes of each step in the method shown are not repeated here.
[0144] The present application also provides a computer program product including instructions. The computer program product may be software or a program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on a computing device, the computing device executes the load balancing scheduling method described above.
[0145] The present application also provides a computer-readable storage medium. The computer-readable storage medium may be any available medium that can be stored by a computing device or a data storage device such as a data center that includes one or more available media. The above-mentioned available media may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc. The computer-readable storage medium includes instructions that instruct the computing device to execute the load balancing scheduling method described above.
[0146] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the above embodiments, a person skilled in the art should understand that the technical solutions described in the above embodiments can still be modified, or some of the technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the protection scope of the technical solutions of the embodiments of the present application.
Claims
1. A load balancing scheduling method, characterized in that: The method is applied to a load balancing device, the load balancing device is connected to a client and multiple servers respectively, and the method includes: Receiving a connection establishment request from the client; Selecting a first server from the multiple servers according to a load balancing algorithm configured in the load balancing device; Determining that the connection state of the first server is abnormal, the abnormal connection state of the first server indicating that the possibility of the first server successfully establishing a connection with a new client is small; The connection establishment request is sent to a second server so that the second server establishes a connection with the client, wherein the second server is a server with a normal connection status selected from the multiple servers according to the load balancing algorithm, and the normal connection status of the second server indicates that the second server is likely to successfully establish a connection with the new client.
2. The method according to claim 1, characterized in that The determining that the connection state of the first server is abnormal includes: When the current number of connections of the first server is equal to the maximum number of connections of the first server, it is determined that the connection status of the first server is abnormal, wherein the current number of connections of the first server is the number of clients currently connected to the first server, and the maximum number of connections of the first server is the number of clients that can be connected to the first server at most.
3. The method according to claim 1 or 2, characterized in that: The determining that the connection state of the first server is abnormal includes: It is determined that the connection state of the first server is abnormal based on the average time for the first server to successfully establish a connection with the client or the number of times the first server fails to establish a connection with the client.
4. The method according to any one of claims 1 to 3, characterized in that: The determining that the connection state of the first server is abnormal includes: When the state of the first server is abnormal, determining that the connection state of the first server is abnormal; The abnormal status of the first server depends on at least one of the following: the number of reset messages sent by the first server and the number of connections in the connecting state on the first server, wherein the reset message is used to instruct the first server to disconnect from the connected client.
5. According to the method described in any one of claims 1 to 4, the load balancing algorithm includes a polling algorithm, a weighted polling algorithm, a minimum connection algorithm, a weighted minimum connection algorithm, and an algorithm for scheduling based on a hash value of an Internet Protocol (IP) address of a client.
6. The method according to claim 5, characterized in that The load balancing algorithm is the weighted least connection algorithm; The selecting a first server from the multiple servers according to the load balancing algorithm configured in the load balancing device includes: The first server is determined based on a current weight and a current number of connections of each of the multiple servers, wherein the current weight of each server is obtained by dynamically adjusting the weight set by a user for each server.
7. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: When the connection status of the first server is normal, the connection establishment request is sent to the first server so that the first server establishes a connection with the client, wherein the normal connection status of the first server indicates that the first server is likely to successfully establish a connection with the new client.
8. A load balancing device, characterized in that: The device is connected to a client and multiple servers respectively, and the device includes: An acquisition module, used for receiving a connection establishment request from the client; A scheduling module, used to select a first server from the multiple servers according to the load balancing algorithm configured in the load balancing device; determine that the connection status of the first server is abnormal, and the abnormal connection status of the first server indicates that the possibility of the first server successfully establishing a connection with a new client is small; send the connection establishment request to the second server, so that the second server establishes a connection with the client, wherein the second server is a server with a normal connection status selected from the multiple servers according to the load balancing algorithm, and the normal connection status of the second server indicates that the possibility of the second server successfully establishing a connection with the new client is high.
9. The device according to claim 8, characterized in that The scheduling module is used to determine that the connection state of the first server is abnormal when the current number of connections of the first server is equal to the maximum number of connections of the first server, wherein the current number of connections of the first server is the number of clients currently connected to the first server, and the maximum number of connections of the first server is the number of clients that can be connected to the first server at most.
10. The device according to claim 8 or 9, characterized in that The scheduling module is used to determine that the connection state of the first server is abnormal according to the average time for the first server to successfully establish a connection with the client or the number of times the first server fails to establish a connection with the client.
11. The device according to any one of claims 8 to 10, characterized in that The scheduling module is used to determine that the connection state of the first server is abnormal when the state of the first server is abnormal; The abnormal status of the first server depends on at least one of the following: the number of reset messages sent by the first server and the number of connections in the connecting state on the first server, wherein the reset message is used to instruct the first server to disconnect from the connected client.
12. According to the device according to any one of claims 8 to 11, the load balancing algorithm includes a polling algorithm, a weighted polling algorithm, a minimum connection algorithm, a weighted minimum connection algorithm, and an algorithm for scheduling based on a hash value of an Internet Protocol IP address of a client.
13. The method according to claim 12, characterized in that The load balancing algorithm is the weighted least connection algorithm; The scheduling module is used to determine the first server according to the current weight and the current number of connections of each server among the multiple servers, wherein the current weight of each server is obtained by dynamically adjusting the weight set by the user for each server.
14. The device according to any one of claims 8 to 13, characterized in that The scheduling module is also used to send the connection establishment request to the first server when the connection status of the first server is normal, so that the first server establishes a connection with the client, wherein the normal connection status of the first server indicates that the first server is likely to successfully establish a connection with the new client.
15. A computing device cluster, characterized in that: comprising at least one computing device, each computing device comprising a processor and a memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method according to any one of claims 1 to 7.
16. A computer-readable storage medium, characterized in that: The method comprises computer program instructions. When the computer program instructions are executed by a computing device, the computing device performs the method according to any one of claims 1 to 7.
17. A computer program product comprising instructions, characterized in that When the instructions are executed by a computing device cluster, the computing device cluster executes the method according to any one of claims 1 to 7.