A load balancing method, device, equipment and computer storage medium
By dynamically adjusting the connection between the client and the server, and optimizing the server inventory based on the real-time load value, the problem of server overload under TCP long connection is solved, and load balancing and system stability are achieved.
Patent Information
- Application Number
- CN202111165088.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-30
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2041-09-30
AI Technical Summary
When using TCP long connections for message transmission, existing load balancing solutions are difficult to ensure that the amount of messages processed by server nodes is relatively balanced, resulting in server overload.
By receiving the connection request from the client, obtain the load value of each server, determine the server inventory of each client, and after establishing a long TCP connection, re-get the load value to adjust the server inventory to ensure load balancing.
It effectively solves the server overload problem, maintains the processing capabilities of the entire server cluster, and ensures the stability of the system.
Smart Images

Figure CN113810304B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of cloud computing in financial technology (Fintech), and in particular to a load balancing method, device, electronic device and computer storage medium. Background Art
[0002] With the development of computer technology, more and more technologies are being applied in the financial field. Traditional finance is gradually transforming into financial technology. However, due to the security and real-time requirements of the financial industry, higher requirements are also placed on technology.
[0003] In the related art, there are several typical load balancing solutions for load balancing, such as hardware-based F5 devices, or software-based Nginx (enginex), Linux Virtual Server (Linux Virtual Server, LVS), etc.; however, when the above solutions use the Transmission Control Protocol (TCP) long connection, it is difficult to ensure that the amount of messages processed by each server node behind the load balancer is relatively balanced; that is, it is very likely that many business IPs with high business volume will be sent to the same processing server node at the same time, causing the server overload problem, and then affecting the processing capacity of the entire server cluster. Summary of the invention
[0004] The present application provides a load balancing method, device, electronic device and computer storage medium, which can solve the server overload problem in the related art when transmitting messages based on TCP long connection.
[0005] The technical solution of this application is implemented as follows:
[0006] The present invention provides a load balancing method, which includes:
[0007] After receiving a connection request sent by each of the multiple clients, obtain a load value of each server in the current network; determine a server list for each client according to the load value of each server, and send a corresponding server list to each client; the server list includes at least two servers;
[0008] After determining that each client has established a TCP persistent connection with each server in the corresponding server list, re-obtaining a load value of each server in the current network; determining a target server that does not meet the set load balancing condition according to the re-obtained load value of each server;
[0009] A target client connected to the target server is found, and a server list of the target client is adjusted; the target client is one of the multiple clients.
[0010] In some embodiments, searching for a target client connected to the target server includes:
[0011] Acquire at least two clients that establish a TCP persistent connection with the target server;
[0012] According to the amount of messages sent by each of the at least two clients to the target server, the client with the smallest amount of messages sent is determined as the target client from the at least two clients, or any client with an amount of messages sent that is less than or equal to a first set threshold is determined as the target client.
[0013] It can be understood that since the target server is a server in the current network that does not meet the set load balancing conditions, it is necessary to adjust the load value of the target server to achieve a balanced state; and the load value of the target server is determined by the amount of messages sent by each client connected to it, and therefore, based on the amount of messages sent by each client to the target server, the target client can be determined in a targeted manner; in addition, from each client connected to the target server, the client with the smallest message sending amount or less than a certain set threshold is selected as the target client, which can effectively prevent jitter problems during subsequent load adjustment of the target server and ensure the stability of the system.
[0014] In some embodiments, determining the target server that does not meet the set load balancing condition according to the re-acquired load value of each server includes:
[0015] Sorting the re-acquired load value of each server to obtain a sorting result;
[0016] From the sorting results, a server with the highest load value and a server with the lowest load value are obtained; when it is determined that the load difference between the server with the highest load value and the server with the lowest load value is greater than a second set threshold, the server with the highest load value is determined as a target server that does not meet the set load balancing condition; or,
[0017] Any server in the sorting result whose load value is greater than a third set threshold is determined as a target server that does not meet the set load balancing condition.
[0018] It can be seen that in the embodiment of the present application, after obtaining the load value of each server, the target server that does not meet the set load balancing condition can be more intuitively determined from the sorting result by sorting the load value of each server. In addition, by determining the server with the highest load value or greater than a certain set threshold as the target server for subsequent load balancing adjustment, it is possible to avoid affecting the processing capacity of the entire server cluster due to the low processing capacity of the target server.
[0019] In some embodiments, adjusting the server list of the target client includes:
[0020] The server with the highest load value in the server list of the target client is removed, and a server with the lowest current load value is added to the server list of the target client.
[0021] It can be seen that the embodiment of the present application can reduce the risk of overload caused by the server continuing to process the business data of the target client by removing the server with the highest load value in the server list of the target client.
[0022] In some embodiments, the method further comprises:
[0023] Before receiving the connection request sent by each of the multiple clients, receiving a load determination parameter reported by each server in the current network; the load determination parameter includes at least one of the number of connections of the server, the amount of messages processed by the server in the previous statistical period, and the time when the server was last allocated to the client;
[0024] The step of obtaining the load value of each server in the current network includes:
[0025] The load value of each server in the current network is determined according to the load determination parameter reported by each server in the current network.
[0026] It can be seen that the embodiment of the present application determines the parameters based on the load reported by each server in the current network, and can accurately obtain the load value of each server.
[0027] In some embodiments, when the load determination parameter includes the number of connections of the server, the amount of messages processed by the server in the previous statistical period, and the time when the server was last assigned to the client, the load determination parameter also includes a weight value of the number of connections, a weight value of the amount of messages processed, and a weight value of the time parameter;
[0028] The step of determining a parameter according to the load reported by each server in the current network to determine the load value of each server in the current network includes:
[0029] The load value of each server in the current network is determined based on the number of connections of the server reported by each server in the current network and the weight value of the connection number, the amount of messages processed by the server in the previous statistical period and the weight value of the processed message amount, the last time the server was assigned to the client and the weight value of the time parameter.
[0030] It can be seen that, in the embodiment of the present application, by further limiting the parameters included in the load determination parameters, the load value of each server in the current network can be obtained more accurately.
[0031] In some embodiments, the method further comprises:
[0032] During the current statistical period, each time the server list is adjusted, the number of adjustments is incremented by 1.
[0033] Calculating the ratio of the total number of times the server list is adjusted in the current statistical period to the total number of connections of each server in the current network to obtain the adjusted session ratio in the current statistical period;
[0034] Whether to continue adjusting the server list within the current statistical period is determined according to a relationship between the adjusted session proportion and a fourth set threshold.
[0035] It can be seen that the embodiment of the present application controls the number of adjustments to the server list in the current statistical period by adjusting the session ratio in the current statistical period, thereby preventing the problem of poor system stability caused by large-scale server connection adjustments.
[0036] In some embodiments, determining whether to continue adjusting the server list within the current statistical period according to the relationship between the adjusted session proportion and a fourth set threshold value includes:
[0037] When it is determined that the adjusted session proportion is greater than or equal to the fourth set threshold, waiting for the current statistical period to end;
[0038] When it is determined that the adjusted session proportion is less than the fourth set threshold and it is determined that there is a target server that does not meet the set load balancing condition, the server list in the current statistical period continues to be adjusted.
[0039] It can be seen that the embodiment of the present application controls the number of adjustments to the server list in the current statistical period by adjusting the comparison between the session ratio and the fourth set threshold, thereby achieving load balancing in the current statistical period while ensuring the stability of the system.
[0040] The embodiment of the present application further provides a load balancing device, which includes a first determining module, a second determining module and an adjusting module, wherein:
[0041] A first determination module is used to obtain a load value of each server in the current network after receiving a connection request sent by each of the multiple clients; determine a server list of each client according to the load value of each server, and send a corresponding server list to each client; the server list includes at least two servers;
[0042] The second determination module is used to re-acquire the load value of each server in the current network after determining that each client has established a TCP long connection with each server in the corresponding server list; and determine the target server that does not meet the set load balancing condition according to the re-acquired load value of each server;
[0043] The adjustment module is used to find a target client connected to the target server and adjust the server list of the target client; the target client is one of the multiple clients.
[0044] An embodiment of the present application provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the load balancing method provided by one or more of the aforementioned technical solutions when executing the program.
[0045] An embodiment of the present application provides a computer storage medium, which stores a computer program; after the computer program is executed, it can implement the load balancing method provided by one or more of the above-mentioned technical solutions.
[0046] The embodiment of the present application proposes a load balancing method, device, electronic device and computer storage medium, the method comprising: after receiving a connection request sent by each client among multiple clients, obtaining the load value of each server in the current network; determining the server list of each client according to the load value of each server, and issuing the corresponding server list to each client; the server list includes at least two servers; after determining that each client has established a TCP long connection with each server in the corresponding server list, re-obtaining the load value of each server in the current network; determining the target server that does not meet the set load balancing condition according to the re-obtained load value of each server; searching for a target client connected to the target server, and adjusting the server list of the target client; the target client is one of the multiple clients.
[0047] It can be seen that in the embodiment of the present application, before the client establishes a connection with the server, by obtaining the load value of each server in the current network, the server list that each client is allowed to connect to can be determined; that is, the client can be connected to multiple servers with lower load values, so that the client's business volume is more evenly sent to different servers for processing. Furthermore, after the client establishes a connection with the server, if a target server that does not meet the set load balancing conditions is found, the server list of the target client connected to the target server is adjusted to achieve the purpose of controlling the comprehensive load of the entire server cluster, maintaining a dynamic balance of the load value of each server, and effectively solving the problem of server overload. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1a It is a structural diagram of a load balancing in the related technology;
[0049] Figure 1b It is a structural diagram of another load balancing in the related technology;
[0050] Figure 2a It is a flow chart of a load balancing method in an embodiment of the present application;
[0051] Figure 2b is a structural diagram of a load balancing adjustment in an embodiment of the present application;
[0052] Figure 2c A flow chart of another load balancing method according to an embodiment of the present application;
[0053] Figure 2d It is a structural diagram of another load balancing adjustment in an embodiment of the present application;
[0054] Figure 3 It is a schematic diagram of the composition structure of the load balancing device in an embodiment of the present application;
[0055] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0056] The present application will be further described in detail below in conjunction with the accompanying drawings and Examples. It should be understood that the embodiments provided herein are only used to explain the present application and are not intended to limit the present application. In addition, the embodiments provided below are partial embodiments for implementing the present application, rather than providing all embodiments for implementing the present application. In the absence of conflict, the technical solutions recorded in the embodiments of the present application can be implemented in any combination.
[0057] It should be noted that, in the embodiments of the present application, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a method or apparatus including a series of elements includes not only the elements explicitly recorded, but also includes other elements not explicitly listed, or also includes elements inherent to the implementation of the method or apparatus. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the presence of other related elements (such as steps in a method or units in a device, for example, a unit may be a portion of a circuit, a portion of a processor, a portion of a program or software, etc.) in the method or apparatus including the element.
[0058] The term "and / or" herein is only a description of the association relationship of the associated objects, indicating that there may be three relationships. For example, I and / or J can represent the three situations that I exists alone, I and J exist at the same time, and J exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of I, J, and R can represent including any one or more elements selected from the set consisting of I, J, and R.
[0059] For example, the load balancing method provided in the embodiment of the present application includes a series of steps, but the load balancing method provided in the embodiment of the present application is not limited to the recorded steps. Similarly, the load balancing device provided in the embodiment of the present application includes a series of modules, but the load balancing device provided in the embodiment of the present application is not limited to including the modules explicitly recorded, and may also include modules required to obtain relevant task data or perform processing based on task data.
[0060] The embodiments of the present application can be applied to a computer system composed of a server, and can operate with many other general or special computing system environments or configurations. Here, the server can be a distributed cloud computing technology environment including a small computer system, a large computer system, and so on.
[0061] Electronic devices such as servers can implement corresponding functions through the execution of program modules. Generally, program modules can include routines, programs, target programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. The computer system / server can be implemented in a distributed cloud computing environment, in which tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules can be located on local or remote computing system storage media including storage devices.
[0062] Currently, TCP-based connections include long connections and short connections. In scenarios where a large amount of messages are processed and real-time requirements are high, TCP long connections are chosen to ensure low system throughput and latency.
[0063] For most application scenarios, several typical load balancing solutions such as hardware-based F5 devices or software-based Nginx, LVS, etc. can meet the needs well. However, there are exceptions. If you want to ensure that the amount of messages processed by each server node behind the load balancer is relatively balanced when using TCP long connections, it is difficult to achieve using the above solutions.
[0064] This is because the data transmission volume of different types of services is often very different. The processing volume of some business IP instances may be only a few businesses, while the processing volume of some business IP instances may be hundreds of thousands or even millions of businesses. Therefore, for these two types of business IP instances, no matter what load balancing scheduling algorithm is collected, once the load balancing scheduler makes a decision, the business IP is successfully connected to the server assigned by the load balancing scheduler. The load balancing scheduler will no longer intervene in the data exchange between the business IP and the server. Therefore, it is inevitable that there will be a large difference in the amount of messages processed by the server nodes. This may cause many IPs with high business volume to be sent to the same processing server node at the same time, causing server overload; the following is through Figure 1a To explain, Figure 1a As shown in the figure, the data traffic transmitted by Client 1 and Client 2 is 3Kb / s, but the data traffic transmitted by Client 3 and Client 4 is 1Mb / s; the load balancing scheduler allocates according to the number of connections, Server 1 and Server 2 are each allocated two connections, but the amount of messages processed by these two servers is completely not at the same level.
[0065] In related technologies, there are also mainstream solutions for load balancing based on TCP long connections. The core ideas can be referred to Figure 1b ; By introducing a reverse proxy server and establishing a connection between the reverse proxy server and each client, a TCP long connection session is maintained between the client and the server, and then a certain load balancing algorithm is used to forward the message to the back-end server cluster (server 1 to server n); here, the load balancing algorithms used are: average load, polling load, priority group, etc.
[0066] It can be seen that although the above solution can solve the server load balancing problem in the case of TCP long connection, the solution has the following disadvantages:
[0067] 1) When one of the servers is abnormal, the client needs to reconnect to the reverse proxy server, which will affect the business during the period when the client is disconnected from the server.
[0068] 2) The reverse proxy server may also have problems with network card capacity or connection limit.
[0069] 3) When the processing capacity of the reverse proxy server is insufficient, it is difficult to expand the server capacity.
[0070] It can be seen that although the introduction of a reverse proxy server can solve the problem of server load balancing in the case of a TCP long connection, the above-mentioned shortcomings make this solution somewhat difficult.
[0071] In view of the above technical problems, the following embodiments are proposed.
[0072] In some embodiments of the present application, the load balancing method can be implemented using a processor in a load balancing device, and the above-mentioned processor can be at least one of an application-specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field programmable gate array (FPGA), a central processing unit (CPU), a controller, a microcontroller, and a microprocessor.
[0073] Figure 2a is a flow chart of a load balancing method in an embodiment of the present application, such as Figure 2a As shown, the method comprises the following steps:
[0074] Step 200: After receiving a connection request sent by each of multiple clients, obtain the load value of each server in the current network; determine the server list of each client according to the load value of each server, and send the corresponding server list to each client; the server list includes at least two servers.
[0075] Exemplarily, the client is used to access specific business data and forward the business data to the backend server for subsequent further processing; the server belongs to the backend processing module and is used to process the business data forwarded by the client.
[0076] In the embodiment of the present application, the load balancing method is a method for balancing the load values of each server in the current network when a TCP persistent connection is established between a client and a server; illustratively, before each of the multiple clients establishes a TCP persistent connection with the server, the client does not know which servers are available in the current network; therefore, when each client needs to send service data to the server, it needs to first send a connection request to the scheduling module, so that the scheduling module can receive the connection request sent by each of the multiple clients. Here, by introducing the scheduling module, the complexity of connection management between each client and the server can be reduced; the following is combined with Figure 2b The scheduling module is described in detail.
[0077] Figure 2b is a structural diagram of a load balancing adjustment in an embodiment of the present application, such as Figure 2a As shown, the structure diagram includes: client 1, client 2, server 1 to server n and a scheduling module; wherein one end of the scheduling module is connected to client 1 and client 2 respectively, and is responsible for receiving connection requests sent by the two clients; the other end of the scheduling module is connected to n servers in the current network respectively, and is used to collect data related to its own load reported by each of the n servers; client 1 is connected to server 1 and server 1, and client 2 is connected to server 2 and server 3; that is, the client can connect to multiple servers at the same time.
[0078] It can be seen that compared with the need to introduce a reverse proxy server between the client and the server in the related art, the embodiment of the present application does not need to introduce a reverse proxy server, but each client is directly connected to the corresponding server, that is, there is no need to connect to each server through a reverse proxy server, thereby solving the problem of the related art that load balancing is difficult to implement due to the network card capacity or the upper limit of the number of connections of the reverse proxy server; in addition, the embodiment of the present application allows the client to connect to multiple server nodes at the same time; in this way, when one of the servers is abnormal, the client can also continue to process business through other server nodes, that is, it will not affect the business during the period when the client is disconnected from the abnormal server, thereby ensuring the high availability of the server; further, when a server is offline, upgraded, restarted or other changes or abnormalities occur, the server expansion can be quickly completed in the embodiment of the present application, thereby solving the problem of the related art that server expansion is difficult due to the limited processing capacity of the reverse proxy server.
[0079] In some embodiments, the above method may further include: before the scheduling module receives the connection request sent by each client among the multiple clients, receiving the load determination parameter reported by each server in the current network.
[0080] Exemplarily, the load determination parameters may include at least one of the number of connections of the server, the amount of messages processed by the server in the previous statistical period, and the time when the server was last assigned to a client; here, the number of connections of the server represents the number of connections between the server and the client in the previous statistical period.
[0081] Exemplarily, the statistical cycle and timing time can be pre-set in the server, so that the server can count the load determination parameters in each statistical cycle, and when the timing time arrives, report the load determination parameters in the previous statistical cycle closest to the timing time to the scheduling module.
[0082] Exemplarily, obtaining the load value of each server in the current network may include: a scheduling module determining parameters according to the load reported by each server in the current network, and determining the load value of each server in the current network in each statistical period.
[0083] In some embodiments, when the load determination parameters include the number of connections of the server, the amount of messages processed by the server in the previous statistical period, and the last time the server was assigned to a client, the load determination parameters also include a connection number weight value, a message processing weight value, and a time parameter weight value.
[0084] Here, the values of the connection number weight value, the message processing volume weight value, and the time parameter weight value can be set according to the actual scenario, and the embodiments of the present application do not limit this.
[0085] Exemplarily, determining the parameters based on the load reported by each server in the current network to determine the load value of each server in the current network may include: determining the load value of each server in the current network based on the number of connections of the server reported by each server in the current network and the weight value of the number of connections, the amount of messages processed by the server in the previous statistical period and the weight value of the amount of processed messages, and the last time the server was allocated to the client and the weight value of the time parameter.
[0086] For example, after the scheduling module receives the load determination parameters regularly reported by each server in the current network, it can obtain the load value Lr of each server in the previous statistical period according to the server load evaluation formula (1).
[0087] Lr=Abs(C-Min(C)-ΔC)*WC+Abs(M-Min(M)-ΔM)*WM+WT / (T-T1)%LMR (1)
[0088] Here, Abs represents the absolute value of the calculation; C represents the number of connections of the server; Min(C) represents the number of connections with the smallest value among all the connections of the servers in the current network; ΔC represents the tolerance value of the number of server connections. If the difference in the number of connections between the servers is less than this value, the number of connections of the servers can be considered to be balanced; WC represents the weight value of the number of connections in the server load evaluation formula, corresponding to the above-mentioned weight value of the number of connections. M represents the amount of messages processed by the server in the previous statistical period; Min(M) represents the amount of messages processed with the least amount of messages among all the servers in the previous statistical period; ΔM represents the tolerance value of the amount of processed messages. If the difference in the amount of processed messages between the servers is less than this value, the messages processed by the servers can be considered to be balanced; WM represents the weight value of the amount of processed messages in the server load evaluation formula, corresponding to the above-mentioned weight value of the amount of processed messages. T represents the current system time; T1 represents the time when the server was last assigned to a client; WT represents the weight value of the time parameter in the server load evaluation formula, corresponding to the above-mentioned weight value of the time parameter; LMR represents the maximum value allowed for the time parameter in the server load evaluation formula.
[0089] It should be noted that the embodiment of the present application does not limit the values of the above parameters included in formula (1), and can be set according to the actual scenario. It can be seen that when the server has more connections, the server load value is higher; when the server processes more messages, the server load value is higher; when the time when the server was last assigned to the client is closer to the current time, the server load value is higher.
[0090] It can be seen that the embodiment of the present application determines the parameters based on the load reported by each server in the current network, and can accurately obtain the load value of each server.
[0091] Exemplarily, after the scheduling module receives a connection request sent by each of the multiple clients, it can determine the number of servers that each client is allowed to connect to based on the importance or business volume of the business to which each client belongs, denoted as cn; here, when the importance or business volume of the business to which a certain client belongs is high, the client can be allowed to connect to a larger number of servers; when the importance or business volume of the business to which a certain client belongs is low, the client can be allowed to access a smaller number of servers.
[0092] In an embodiment of the present application, before receiving a connection request sent by each of the multiple clients, the scheduling module can obtain the load value of each server in the previous statistical period according to formula (1); illustratively, the implementation method of determining the server list of each client according to the load value of each server can be: the scheduling module selects cn servers with lower load values from each server as the server list of each client according to the load value of each server; here, the server list of each client includes at least two servers, so that when an abnormality occurs in the connection between the client and one of the servers, the high availability of the service can still be guaranteed.
[0093] Exemplarily, the server list may include multiple servers, but does not include all servers in the current network. In this way, the problem of too high number of connections to each server caused by connecting to all servers can be effectively avoided.
[0094] Exemplarily, after the scheduling module obtains the server list of each client, the corresponding server list is sent to each client; in this way, each client can establish a TCP long connection with each server in the corresponding server list.
[0095] Step 201: After determining that each client has established a TCP long connection with each server in the corresponding server list, re-obtain the load value of each server in the current network; and determine the target server that does not meet the set load balancing condition based on the re-obtained load value of each server.
[0096] Exemplarily, after determining that each client has established a TCP persistent connection with each server in the corresponding server list, each client will poll and send business data to each server with which a TCP persistent connection has been established; the following is an example of one client and two servers.
[0097] Exemplarily, when client 1 polls and sends service data to server 1 and server 2 that have established a TCP long connection, once server 1 receives the service data sent by the client, it will count the load determination parameters of the most recent statistical period, and the load determination parameters include the amount of processed messages corresponding to the server connection session, the amount of processed messages corresponding to this server, the number of connections of this server, and the time when this server is assigned to client 1; then when the timing time arrives, server 1 reports the above load determination data to the scheduling module; in this way, the scheduling module can re-acquire the load value of server 1 according to formula (1); here, the process of acquiring the load value of server 2 is similar to the above acquisition process, which will not be repeated here. In this way, the scheduling module can re-acquire the load value of each server in the current network.
[0098] It can be seen that during the data transmission between the client and each server in the corresponding server list, the load value of each server changes dynamically; each server will regularly report the load determination parameters of the most recent statistical cycle; in this way, the scheduling module can re-determine the current load value of each server. This method of dynamically obtaining load determination parameters to achieve load balancing can effectively avoid affecting the processing capacity of the entire server cluster due to the low processing capacity of a server.
[0099] In some embodiments, determining the target server that does not meet the set load balancing conditions based on the re-acquired load value of each server can include: sorting the re-acquired load value of each server to obtain a sorting result; and determining the target server that does not meet the set load balancing conditions based on the sorting result.
[0100] Exemplarily, the re-acquired load value of each server may be sorted in descending order of the load value to obtain a sorting result; and then, based on the sorting result, the target server that does not meet the set load balancing condition is determined.
[0101] It can be seen that in the embodiment of the present application, after obtaining the load value of each server and sorting by the load value of each server, the target server that does not meet the set load balancing condition can be determined more intuitively from the sorting result.
[0102] Exemplarily, one implementation method for determining a target server that does not meet the set load balancing conditions based on a sorting result may be: obtaining a server with a highest load value and a server with a lowest load value from the sorting result; when it is determined that the load difference between the server with the highest load value and the server with the lowest load value is greater than a second set threshold, determining the server with the highest load value as the target server that does not meet the set load balancing conditions.
[0103] Exemplarily, after obtaining the server with the highest load value and the server with the lowest load value from the sorting results, the load difference between the server with the highest load value and the server with the lowest load value is first calculated; then the load difference is compared with the second set threshold to obtain a comparison result; if it is determined according to the comparison result that the load difference is greater than the second set threshold, it means that there is a target server that does not meet the set load balancing condition, and the server with the highest load value is determined as the target server that does not meet the set load balancing condition; conversely, if it is determined according to the comparison result that the load difference is less than or equal to the second set threshold, it means that there is no target server that does not meet the set load balancing condition at this time, that is, all servers currently establishing TCP long connections meet the load balancing condition.
[0104] Exemplarily, another implementation method for determining the target server that does not meet the set load balancing condition based on the sorting result may be: determining any server in the sorting result whose load value is greater than a third set threshold as the target server that does not meet the set load balancing condition.
[0105] Exemplarily, assuming that the servers in the sorting results that are greater than the third set threshold include server 1 and server 2, and the load value relationship between them is server 1>server 2, then server 1 can be determined as the target server that does not meet the set load balancing conditions, and server 2 can also be determined as the target server that does not meet the set load balancing conditions.
[0106] Exemplarily, if the load values in the sorting results are all less than or equal to the third set threshold, it means that there is no target server that does not meet the set load balancing condition at this time, that is, all servers currently establishing TCP long connections meet the load balancing condition.
[0107] Here, the values of the second set threshold and the third set threshold can be determined according to actual conditions, and the embodiments of the present application do not limit this.
[0108] It can be seen that the embodiment of the present application, by determining the server with the highest load value or greater than a set threshold as the target server for subsequent load balancing adjustment, can avoid affecting the processing capacity of the entire server cluster due to the low processing capacity of the target server.
[0109] Step 202: Find a target client connected to a target server, and adjust the server list of the target client; the target client is one of the multiple clients.
[0110] In an embodiment of the present application, after obtaining the target server that does not meet the set load balancing conditions according to the above step 201, all clients that have established TCP long connections with the target server are obtained, and the target clients whose server lists need to be adjusted are searched from these clients; here, adjusting the server list means load balancing adjustment.
[0111] In some embodiments, searching for a target client connected to a target server may include: obtaining at least two clients that have established a TCP long connection with the target server; and determining the target client from the at least two clients based on the amount of messages sent by each of the at least two clients to the target server.
[0112] For example, when the target server processes the amount of messages (business data) sent by different clients, it will periodically report to the scheduling module the amount of messages processed by all connections of the target server in the most recent statistical period; that is, the amount of messages sent by each client that establishes a TCP connection with the target server. Furthermore, the scheduling module can determine the target client from multiple clients that establish a TCP connection with the target server based on the amount of messages sent by each client to the target server.
[0113] It can be understood that since the target server is a server in the current network that does not meet the set load balancing conditions, the load value of the target server needs to be adjusted to achieve a balanced state; and the load value of the target server is determined by the amount of messages sent by each client connected to it, therefore, based on the amount of messages sent by each client to the target server, the target client can be determined in a targeted manner.
[0114] In some embodiments, determining a target client from at least two clients based on the amount of messages sent by each of the at least two clients to the target server may include: determining, from at least two clients, a client with the smallest amount of messages sent as the target client based on the amount of messages sent by each of the at least two clients to the target server, or determining any client with an amount of messages sent that is less than or equal to a first set threshold as the target client.
[0115] It can be seen that in the embodiment of the present application, the client with the smallest message sending amount or less than a set threshold is selected as the target client from each client connected to the target server, which can effectively prevent jitter problems during subsequent load adjustment of the target server and ensure the stability of the system.
[0116] Exemplarily, the implementation method for determining the target client may also be: from all clients that have established connection sessions with the target server, find the client with the smallest connection session load, and determine the client as the target client; here, the connection session load Las of each client that has established a connection session with the target server can be determined by formula (2).
[0117] Las=WAT / (t-t1) + MC (2)
[0118] Here, WAT refers to the weight of the time parameter in the Client connection session load evaluation formula; t refers to the time when the client connects to the target server; t1 refers to the time when the client last adjusted the session, that is, the time when the client last connected to other target servers; MC refers to the amount of messages that need to be processed in this connection session in the most recent statistical period, that is, the amount of messages sent by the client to the target server that need to be processed by the target server.
[0119] It should be noted that the embodiment of the present application does not limit the values of the above parameters included in formula (2), and can be set according to the actual scenario. It can be seen from formula (2) that if the number of messages processed by the target server is more, the corresponding client connection session load is higher, and if the time from the most recent session adjustment is closer, the corresponding client connection session load is higher.
[0120] Exemplarily, after obtaining the connection session load of each client establishing a connection session with the target server according to formula (2), the client with the smallest connection session load is determined as the target client, or the client with a connection session load less than or equal to a set value is determined as the target client.
[0121] In an embodiment of the present application, after obtaining the target client according to the above steps, the server list of the target client is obtained, and the server list is adjusted to achieve load balancing between servers.
[0122] In some embodiments, adjusting the server list of the target client may include: removing the server with the highest load value in the server list of the target client, and adding a server with the lowest current load value to the server list of the target client.
[0123] Exemplarily, after obtaining the server list of the target client, the server with the highest load value in the server list is removed, that is, the target server in the server list is removed, and a server with the lowest current load value is added.
[0124] This is because the target server is a server with a relatively high load value in the current network and has a low data processing capability. If it is not removed and continues to process the business data sent by the target client, it is very likely that the target server will crash due to overload, affecting the processing capability of the entire server cluster. In the embodiment of the present application, by adjusting the connection between the target client and the target server to the connection between the target client and the server with the lowest current load value, the target server no longer processes the business data sent by the target client. In this way, the overload problem of the target server can be effectively solved and the possibility of the target server crashing due to overload can be reduced. In addition, since the connection session load between the target client and the target server is the smallest, this adjustment method can also effectively prevent jitter problems during the adjustment process and ensure the stability of the system.
[0125] It can be seen that the embodiment of the present application can reduce the risk of overload caused by the server continuing to process the business data of the target client by removing the server with the highest load value in the server list of the target client.
[0126] In some embodiments, the above method may also include: within the current statistical period, each time the server list is adjusted, adding 1 to the number of adjustments; calculating the ratio of the total number of adjustments to the server list within the current statistical period to the total number of connections of each server in the current network to obtain the adjustment session ratio of the current statistical period; and determining whether to continue adjusting the server list within the current statistical period based on the relationship between the adjustment session ratio and the fourth set threshold.
[0127] In the embodiment of the present application, the number of adjustments to the server list in the current statistical period is controlled by adjusting the session ratio in the current statistical period, thereby preventing the problem of poor system stability caused by large-scale server connection adjustments.
[0128] Exemplarily, each time the server list is adjusted, it means that each load balancing adjustment is completed; here, in the current statistical period, each time the server list is adjusted, the number of adjustments is increased by 1; exemplarily, the total number of adjustments of the server list in the current statistical period can be recorded as AT, and the total number of connections of each server in the current network can be recorded as CT, then the adjustment session ratio in the current statistical period is AT / CT. Then, according to the relationship between the adjustment session ratio and the fourth set threshold, it is determined whether to continue to adjust the server list in the current statistical period.
[0129] In some embodiments, determining whether to continue adjusting the server list within the current statistical period is based on the relationship between the adjusted session ratio and a fourth set threshold, which may include: when it is determined that the adjusted session ratio is greater than or equal to the fourth set threshold, waiting for the end of the current statistical period; when it is determined that the adjusted session ratio is less than the fourth set threshold and it is determined that there is a target server that does not meet the set load balancing conditions, continuing to adjust the server list within the current statistical period.
[0130] Exemplarily, when it is determined that the value of the adjusted session ratio AT / CT is greater than or equal to the fourth set threshold, wait for the current statistical period to end; that is, no load balancing adjustment is performed in this message statistical period to prevent large-scale connection jitter in the system. On the contrary, when it is determined that the value of the adjusted session ratio AT / CT is less than the fourth set threshold, evaluate again whether the loads between the servers in the current network are balanced, that is, determine whether there are target servers that do not meet the set load balancing conditions. If there is an imbalance, if so, continue with the next round of adjustments until the entire system reaches load balance again; otherwise, it means that the current statistical period has reached load balance. Here, there is no limitation on the value of the fourth set threshold, and it can be set according to the actual scenario.
[0131] It can be seen that the embodiment of the present application controls the number of adjustments to the server list in the current statistical period by adjusting the comparison between the session ratio and the fourth set threshold, thereby achieving load balancing in the current statistical period while ensuring the stability of the system.
[0132] The embodiment of the present application proposes a load balancing method, device, electronic device and computer storage medium, the method comprising: after receiving a connection request sent by each client in a plurality of clients, obtaining the load value of each server in the current network; according to the load value of each server, determining the server list of each client, and sending the corresponding server list to each client; the server list includes at least two servers; after determining that each client has established a TCP long connection with each server in the corresponding server list, re-obtaining the load value of each server in the current network; according to the load value of each server re-obtained, determining the target server that does not meet the set load balancing condition; finding the target client connected to the target server, and adjusting the server list of the target client; the target client is one of the plurality of clients. It can be seen that in the embodiment of the present application, before the client establishes a connection with the server, by obtaining the load value of each server in the current network, the server list that allows each client to connect can be determined; that is, the client can be connected to multiple servers with lower load values, so that the client's business volume is more evenly sent to different servers for processing. Furthermore, after the client establishes a connection with the server, if it is found that the target server does not meet the set load balancing conditions, the server list of the target client connected to the target server is adjusted to achieve the purpose of controlling the comprehensive load of the entire server cluster, maintaining a dynamic balance of the load value of each server, and effectively solving the problem of server overload.
[0133] In order to better reflect the purpose of the present application, further explanation is given based on the above embodiments of the present application.
[0134] Figure 2c FIG. 1 is a flow chart of another load balancing method according to an embodiment of the present application. Figure 2c As shown, the process may include:
[0135] Step A1: The server reports the load to determine the parameters.
[0136] Exemplarily, server 1 to server n respectively report the load determination parameters within the most recent statistical period to the scheduling module; the load determination parameters may include the number of connections of the server, the amount of messages processed by the server in the previous statistical period, the last time the server was assigned to the client, and the amount of messages processed corresponding to each connection session of the server.
[0137] Step A2: The client sends a connection request to the scheduling module.
[0138] Exemplarily, before the client needs to send service data to the server, it needs to first send a connection request to the scheduling module.
[0139] Step A3: The scheduling module distributes the server list to the client.
[0140] Exemplarily, the scheduling module determines parameters based on the load reported by each server to determine the load value of each server, and then, based on the load value of each server and the importance or business volume of the client's business, allocates a corresponding server list to the client, and the client sends the corresponding server list.
[0141] Step A4: The client establishes a connection with each server in the server list simultaneously.
[0142] Exemplarily, the server list of the client includes server 1 and server 2, that is, the client establishes TCP long connections with server 1 and server 2 at the same time.
[0143] Step A5: The client polls and sends service data.
[0144] For example, after determining that the client has established a TCP persistent connection with Server 1 and Server 2, the client will poll and send service data to Server 1 and Server 2 to which the TCP persistent connection has been established.
[0145] It should be noted that when any server receives the business data sent by the client, it will count the load determination parameters of the most recent statistical period and report the above load determination data to the scheduling module at a regular interval; in this way, the scheduling module can re-obtain the load value of each server in the current network based on the load determination data; and determine whether the server connected to the client meets the load balancing conditions based on the re-obtained load value. If not, the client's server list is adjusted so that each server connected to the client is in a balanced state.
[0146] For example, considering that there are many clients and servers in a large system, when the server receives the business data sent by the client, it needs to count the load of each statistical period to determine the parameters; that is, the server needs to process the business data sent by the client and also needs to count the load to determine the parameters. It can be seen that the server will bear a heavier task in the load balancing process. In order to improve the processing capacity of the server, Figure 2b On the basis of , a new monitoring module is added; Figure 2d is a structural diagram of another load balancing adjustment in an embodiment of the present application, such as Figure 2dAs shown, a newly added monitoring module is connected between the scheduling module and each server. In this way, the load determination parameters of each server can be counted and monitored through the monitoring module, and the load determination parameters of each server obtained by statistics are reported to the scheduling module; the list of servers connected to the client is then controlled through the scheduling module; that is, by completing part of the server's tasks through the monitoring module, the processing capacity of the entire server cluster can be improved.
[0147] In the embodiment of the present application, by controlling the number of servers that the client is allowed to connect to, messages with large business volume can be sent to the server in a more balanced manner, which can reduce the situation where the server crashes due to a surge in business volume caused by the promotion of a certain type of business. In addition, after the client is connected to multiple servers at the same time, changes to a server, such as offline, upgrade, restart, or abnormality in the network between the client and a server, will not affect the normal reporting of client data, thereby improving system reliability.
[0148] Figure 3 Schematic diagram of the structure of the load balancing device in the embodiment of the present application. Figure 3 As shown, the device includes a first determination module 300, a second determination module 301 and an adjustment module 302, wherein:
[0149] The first determination module 300 is used to obtain the load value of each server in the current network after receiving the connection request sent by each client among the multiple clients; determine the server list of each client according to the load value of each server, and send the corresponding server list to each client; the server list includes at least two servers;
[0150] The second determination module 301 is used to re-acquire the load value of each server in the current network after determining that each client has established a Transmission Control Protocol TCP long connection with each server in the corresponding server list; and determine the target server that does not meet the set load balancing condition according to the re-acquired load value of each server;
[0151] The adjustment module 302 is used to find a target client connected to the target server and adjust the server list of the target client; the target client is one of the multiple clients.
[0152] In some embodiments, the adjustment module 302 is used to find a target client connected to the target server, including:
[0153] Acquire at least two clients that establish a TCP persistent connection with the target server;
[0154] According to the amount of messages sent by each of the at least two clients to the target server, the client with the smallest amount of messages sent is determined as the target client from the at least two clients, or any client with an amount of messages sent that is less than or equal to a first set threshold is determined as the target client.
[0155] In some embodiments, the second determination module 301 is used to determine the target server that does not meet the set load balancing condition according to the re-acquired load value of each server, including:
[0156] Sorting the re-acquired load value of each server to obtain a sorting result;
[0157] From the sorting results, a server with the highest load value and a server with the lowest load value are obtained; when it is determined that the load difference between the server with the highest load value and the server with the lowest load value is greater than a second set threshold, the server with the highest load value is determined as a target server that does not meet the set load balancing condition; or,
[0158] Any server in the sorting result whose load value is greater than a third set threshold is determined as a target server that does not meet the set load balancing condition.
[0159] In some embodiments, the adjustment module 302 is used to adjust the server list of the target client, including:
[0160] The server with the highest load value in the server list of the target client is removed, and a server with the lowest current load value is added to the server list of the target client.
[0161] In some embodiments, the apparatus further includes a receiving module, wherein the receiving module is configured to:
[0162] Before receiving the connection request sent by each of the multiple clients, receiving a load determination parameter reported by each server in the current network; the load determination parameter includes at least one of the number of connections of the server, the amount of messages processed by the server in the previous statistical period, and the time when the server was last allocated to the client;
[0163] The first determination module 300 is used to obtain the load value of each server in the current network, including:
[0164] The load value of each server in the current network is determined according to the load determination parameter reported by each server in the current network.
[0165] In some embodiments, when the load determination parameter includes the number of connections of the server, the amount of messages processed by the server in the previous statistical period, and the time when the server was last assigned to the client, the load determination parameter also includes a weight value of the number of connections, a weight value of the amount of messages processed, and a weight value of the time parameter;
[0166] The first determination module 300 is used to determine the load value of each server in the current network according to the load determination parameter reported by each server in the current network, including:
[0167] The load value of each server in the current network is determined based on the number of connections of the server reported by each server in the current network and the weight value of the connection number, the amount of messages processed by the server in the previous statistical period and the weight value of the processed message amount, the last time the server was assigned to the client and the weight value of the time parameter.
[0168] In some embodiments, the adjustment module 302 is further configured to:
[0169] During the current statistical period, each time the server list is adjusted, the number of adjustments is incremented by 1.
[0170] Calculating the ratio of the total number of times the server list is adjusted in the current statistical period to the total number of connections of each server in the current network to obtain the adjusted session ratio in the current statistical period;
[0171] Whether to continue adjusting the server list within the current statistical period is determined according to a relationship between the adjusted session proportion and a fourth set threshold.
[0172] In some embodiments, the adjustment module 302 is used to determine whether to continue adjusting the server list within the current statistical period according to the relationship between the adjusted session proportion and the fourth set threshold, including:
[0173] When it is determined that the adjusted session proportion is greater than or equal to the fourth set threshold, waiting for the current statistical period to end;
[0174] When it is determined that the adjusted session proportion is less than the fourth set threshold and it is determined that there is a target server that does not meet the set load balancing condition, the server list in the current statistical period continues to be adjusted.
[0175] In practical applications, the first determination module 300, the second determination module 301, the adjustment module 302 and the receiving module can all be implemented by a processor located in an electronic device, and the processor can be at least one of an ASIC, a DSP, a DSPD, a PLD, a FPGA, a CPU, a controller, a microcontroller, and a microprocessor.
[0176] In addition, each functional module in this embodiment can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or software functional modules.
[0177] If the integrated unit is implemented in the form of a software function module and is not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment is essentially or the part that contributes to the relevant technology or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) or a processor to perform all or part of the steps of the method of this embodiment. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), RAM, disk or optical disk, etc. Various media that can store program codes.
[0178] Specifically, a computer program instruction corresponding to a load balancing method in this embodiment can be stored on a storage medium such as a CD, a hard disk, or a USB flash drive. When the computer program instruction corresponding to a load balancing method in the storage medium is read or executed by an electronic device, any load balancing method in the aforementioned embodiments is implemented.
[0179] Based on the same technical concept as the above embodiments, see Figure 4 , which shows an electronic device 400 provided in an embodiment of the present application, which may include: a memory 401 and a processor 402; wherein,
[0180] Memory 401, used for storing computer programs and data;
[0181] The processor 402 is used to execute the computer program stored in the memory to implement any one of the load balancing methods in the foregoing embodiments.
[0182] In practical applications, the memory 401 may be a volatile memory, such as RAM; or a non-volatile memory, such as ROM, flash memory, hard disk drive (HDD) or solid-state drive (SSD); or a combination of the above types of memory, and provide instructions and data to the processor 402.
[0183] The processor 402 may be at least one of ASIC, DSP, DSPD, PLD, FPGA, CPU, controller, microcontroller, and microprocessor. It is understandable that for different load balancing devices, the electronic device used to implement the processor function may also be other, which is not specifically limited in the embodiments of the present application.
[0184] In some embodiments, the functions or modules included in the device provided in the embodiments of the present application can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments. For the sake of brevity, it will not be repeated here.
[0185] The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.
[0186] The methods disclosed in the various method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0187] The features disclosed in the various product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0188] The features disclosed in the various method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0189] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of hardware embodiments, software embodiments, or embodiments in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) that contain computer-usable program code.
[0190] The present application is described with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, and the combination of the process and / or box in the flowchart and / or block diagram can be realized by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for realizing the function specified in one process or multiple processes in the flowchart and / or one box or multiple boxes in the block diagram.
[0191] These computer program instructions may also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0192] The above are only preferred embodiments of the present application and are not intended to limit the protection scope of the present application.
Claims
1. A load balancing method, characterized in that: The method comprises: After receiving a connection request sent by each of the multiple clients, obtain a load value of each server in the current network; determine a server list for each client according to the load value of each server, and send a corresponding server list to each client; the server list includes at least two servers; After determining that each client has established a Transmission Control Protocol (TCP) long connection with each server in the corresponding server list, re-obtaining a load value of each server in the current network; and determining a target server that does not meet the set load balancing condition according to the re-obtained load value of each server; Acquire at least two clients that establish a TCP persistent connection with the target server; According to the amount of messages sent by each of the at least two clients to the target server, a client with the smallest amount of messages sent is determined as the target client from among the at least two clients, or any client with an amount of messages sent that is less than or equal to a first set threshold is determined as the target client, and the server list of the target client is adjusted; the target client is one of the multiple clients.
2. The method according to claim 1, characterized in that The step of determining the target server that does not meet the set load balancing condition according to the re-acquired load value of each server includes: Sorting the re-acquired load value of each server to obtain a sorting result; From the sorting results, a server with the highest load value and a server with the lowest load value are obtained; when it is determined that the load difference between the server with the highest load value and the server with the lowest load value is greater than a second set threshold, the server with the highest load value is determined as a target server that does not meet the set load balancing condition; or, Any server in the sorting result whose load value is greater than a third set threshold is determined as a target server that does not meet the set load balancing condition.
3. The method according to claim 1, characterized in that The adjusting the server list of the target client includes: The server with the highest load value in the server list of the target client is removed, and a server with the lowest current load value is added to the server list of the target client.
4. The method according to claim 1, characterized in that: The method further comprises: Before receiving the connection request sent by each of the multiple clients, receiving a load determination parameter reported by each server in the current network; the load determination parameter includes at least one of the number of connections of the server, the amount of messages processed by the server in the previous statistical period, and the time when the server was last allocated to the client; The step of obtaining the load value of each server in the current network includes: The load value of each server in the current network is determined according to the load determination parameter reported by each server in the current network.
5. The method according to claim 4, characterized in that In the case where the load determination parameter includes the number of connections of the server, the amount of messages processed by the server in the previous statistical period, and the time when the server was last assigned to the client, the load determination parameter also includes a weight value of the number of connections, a weight value of the amount of messages processed, and a weight value of a time parameter; The step of determining a load value of each server in the current network according to a load determination parameter reported by each server in the current network includes: The load value of each server in the current network is determined based on the number of connections of the server reported by each server in the current network and the weight value of the connection number, the amount of messages processed by the server in the previous statistical period and the weight value of the processed message amount, the last time the server was assigned to the client and the weight value of the time parameter.
6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: During the current statistical period, each time the server list is adjusted, the number of adjustments is incremented by 1. Calculate the ratio of the total number of times the server list is adjusted in the current statistical period to the total number of connections of each server in the current network to obtain the adjusted session ratio in the current statistical period; Whether to continue adjusting the server list within the current statistical period is determined according to a relationship between the adjusted session proportion and a fourth set threshold.
7. The method according to claim 6, characterized in that The determining whether to continue adjusting the server list within the current statistical period according to the relationship between the adjusted session proportion and a fourth set threshold value includes: When it is determined that the adjusted session proportion is greater than or equal to the fourth set threshold, waiting for the current statistical period to end; When it is determined that the adjusted session proportion is less than the fourth set threshold and it is determined that there is a target server that does not meet the set load balancing condition, the server list in the current statistical period continues to be adjusted.
8. A load balancing device, characterized in that: The device comprises: A first determination module is used to obtain a load value of each server in the current network after receiving a connection request sent by each of the multiple clients; determine a server list of each client according to the load value of each server, and send a corresponding server list to each client; the server list includes at least two servers; The second determination module is used to re-acquire the load value of each server in the current network after determining that each client has established a TCP long connection with each server in the corresponding server list; and determine the target server that does not meet the set load balancing condition according to the re-acquired load value of each server; An adjustment module is used to obtain at least two clients that establish a TCP long connection with the target server; according to the amount of messages sent by each of the at least two clients to the target server, from the at least two clients, a client with the smallest amount of messages sent is determined as the target client, or any client with an amount of messages sent less than or equal to a first set threshold is determined as the target client, and a server list of the target client is adjusted; the target client is one of the multiple clients.
9. An electronic device, characterized in that: The device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the method according to any one of claims 1 to 7 is implemented when the processor executes the program.
10. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Load scheduling method and device for long connection communication, equipment and storage medium
CN112202918A