Load balancing method and device, electronic equipment and computer readable storage medium
By monitoring the total data traffic of the physical network card in the storage system and adjusting the communication protocol connection, load balancing between the physical network card in the storage system is achieved, the problem of uneven data traffic allocation is solved, and the utilization rate of the physical network card and the stability of the storage system are improved.
Patent Information
- Application Number
- CN202411855486.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-03-07
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the storage system, the data traffic allocation on the physical network card is uneven, resulting in a decrease in the utilization rate of the physical network card and the stability of the storage system. The existing technology can achieve data traffic rebalancing by restarting the storage side service, but this will affect the normal operation of the system business.
By obtaining the total data traffic of each physical network card, determine whether to trigger the load balancing operation. When load balancing is triggered, all communication protocol connections between the target client and the storage end are determined, the data traffic of each physical network card relative to the target client is calculated, and the communication protocol connection set of the target physical network card is adjusted to achieve load balancing.
Without affecting the normal operation of system services, load balancing between various physical network cards in the storage system is realized, utilization of physical network cards is improved, and the stability of the storage system is effectively ensured.
Smart Images

Figure CN119583455A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a load balancing method, and also to a load balancing device, an electronic device, and a computer-readable storage medium. Background Art
[0002] In the storage system, computing servers are used as clients to distribute data, and storage servers are used as servers to receive and store data. Multiple physical network cards in each client / server node are bound, and a protocol connection is established between the client service and the server gateway to achieve data transmission. However, since the various protocol connections between the client and the server are not established continuously at the same time, all protocol connections cannot be evenly distributed to each physical network card, and the business pressures carried by different protocol connections will also be different, which in turn causes the problem of uneven distribution of data traffic on each physical network card, which not only reduces the utilization rate of the physical network card, but also affects the stability of the storage system. In the related art, there is a method of restarting the storage service to achieve rebalancing of data traffic in the physical network card, but it is obvious that this implementation method will affect the normal operation of the business in the system.
[0003] Therefore, how to achieve load balancing between physical network cards in a storage system without affecting the normal operation of system services and ensure the stability of the storage system is an urgent problem to be solved by those skilled in the art. Summary of the invention
[0004] The purpose of the present application is to provide a load balancing method, which can achieve load balancing between physical network cards in a storage system without affecting the normal operation of system services, thereby ensuring the stability of the storage system; another purpose of the present application is to provide a load balancing device, an electronic device, a computer-readable storage medium, and a computer program product, all of which have the above-mentioned beneficial effects.
[0005] In a first aspect, the present application provides a load balancing method, which is applied to a storage end, wherein the storage end is connected to each client through a physical network card, and the method includes:
[0006] Obtaining the total data flow of each of the physical network cards, and determining whether to trigger a load balancing operation according to each of the total data flows;
[0007] When the load balancing operation is triggered, for any target client, all communication protocol connections between the target client and the storage end are determined;
[0008] Determine, based on all the communication protocol connections, a communication protocol connection set of each of the physical network cards relative to the target client;
[0009] Determining the data flow of each of the physical network cards relative to the target client according to the communication protocol connection set of each of the physical network cards relative to the target client;
[0010] The target physical network card is determined according to the data flow of each physical network card relative to the target client, and the communication protocol connection set of the target physical network card relative to the target client is adjusted to achieve load balancing.
[0011] Optionally, determining whether to trigger a load balancing operation according to each of the total data flows includes:
[0012] Determine the network card utilization rate of each of the physical network cards according to the total data flow of each of the physical network cards;
[0013] Determine, among all the physical network cards, a first physical network card whose network card utilization exceeds a first threshold;
[0014] When the network card utilization difference between the first physical network card and any other physical network card exceeds a second threshold, it is determined to trigger the load balancing operation.
[0015] Optionally, determining a communication protocol connection set of each of the physical network cards relative to the target client according to all the communication protocol connections includes:
[0016] For each communication protocol connection corresponding to the target client, determining source address information and destination address information of a data packet in the communication protocol connection;
[0017] The physical network card to which the corresponding communication protocol connection belongs is determined according to the source address information and the destination address information of the data packet, and a communication protocol connection set of each physical network card relative to the target client is obtained.
[0018] Optionally, determining the physical network card to which the corresponding communication protocol connection belongs according to the source address information and the destination address information of the data packet includes:
[0019] Performing a hash operation on the source address information and the destination address information of the data packet to obtain a hash value;
[0020] Obtaining a physical network card number by calculating the hash value and the number of the physical network cards;
[0021] The physical network card to which the corresponding communication protocol connection belongs is determined according to the physical network card number.
[0022] Optionally, determining a target physical network card according to data traffic of each physical network card relative to the target client, and adjusting a communication protocol connection set of the target physical network card relative to the target client to achieve load balancing includes:
[0023] Determine the maximum data flow rate according to the data flow rate of each physical network card relative to the target client, and use the physical network card corresponding to the maximum data flow rate as the target physical network card;
[0024] For each communication protocol connection in the communication protocol connection set of the target physical network card relative to the target client, obtaining data flow of the communication protocol connection within a first preset time length;
[0025] In the communication protocol connection set, the communication protocol connection whose data flow exceeds a third threshold within the first preset time period is taken as the target communication protocol connection;
[0026] Disconnecting the target communication protocol connection so that the target client initiates a reconnection request to the storage end;
[0027] Reallocate a physical network card for the target client according to the reconnection application, and establish a new communication protocol connection with the target client through the newly allocated physical network card; wherein the number of the new communication protocol connections is the same as the number of the target communication protocol connections.
[0028] Optionally, obtaining the total data flow of each of the physical network cards, and determining whether to trigger a load balancing operation according to each of the total data flows, includes:
[0029] Obtaining a binding mode between each of the clients and the physical network card;
[0030] When the binding mode is a preset binding mode, the total data flow of each physical network card is obtained, and it is determined whether to trigger the load balancing operation according to each total data flow.
[0031] Optionally, the load balancing method further includes:
[0032] When the load balancing operation is not triggered, a timer is used to count the static duration;
[0033] When the static time reaches the second preset time, return to the step of obtaining the total data flow of each physical network card, and determine whether to trigger a load balancing operation according to each total data flow.
[0034] In a second aspect, the present application further discloses a load balancing device, which is applied to a storage end, wherein the storage end is connected to each client through a physical network card, and the device comprises:
[0035] An acquisition module, used to acquire the total data flow of each physical network card, and determine whether to trigger a load balancing operation according to each total data flow;
[0036] A first determination module is used to determine, for any target client, all communication protocol connections between the target client and the storage end when the load balancing operation is triggered;
[0037] A second determination module, configured to determine a communication protocol connection set of each of the physical network cards relative to the target client according to all the communication protocol connections;
[0038] A third determination module, configured to determine the data flow of each of the physical network cards relative to the target client according to the communication protocol connection set of each of the physical network cards relative to the target client;
[0039] The adjustment module is used to determine the target physical network card according to the data flow of each physical network card relative to the target client, and adjust the communication protocol connection set of the target physical network card relative to the target client to achieve load balancing.
[0040] In a third aspect, the present application further discloses an electronic device, comprising:
[0041] Memory for storing computer programs;
[0042] A processor is used to implement the steps of any one of the load balancing methods described above when executing the computer program.
[0043] In a fourth aspect, the present application further discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of any one of the load balancing methods described above are implemented.
[0044] In a fifth aspect, the present invention further discloses a computer program product, including a computer program / instruction, which implements the steps of any one of the load balancing methods described above when executed by a processor.
[0045] The present application provides a load balancing method, which is applied to a storage end, wherein the storage end is connected to each client through a physical network card, and the method includes: obtaining the total data flow of each physical network card, and determining whether to trigger a load balancing operation according to each total data flow; when the load balancing operation is triggered, for any target client, determining all communication protocol connections between the target client and the storage end; determining a communication protocol connection set of each physical network card relative to the target client according to all the communication protocol connections; determining the data flow of each physical network card relative to the target client according to the communication protocol connection set of each physical network card relative to the target client; determining a target physical network card according to the data flow of each physical network card relative to the target client, and adjusting the communication protocol connection set of the target physical network card relative to the target client to achieve load balancing.
[0046] By applying the technical solution provided by the present application, for the storage end, it can determine whether to trigger the load balancing operation on the physical network card according to the total data flow in each physical network card. When it is determined to trigger the load balancing operation, for any client, that is, the target client, it can first determine all the communication protocol connections between it and itself, and combine the connection relationship between each communication connection and each physical network card to obtain the communication protocol connection set of each physical network card relative to the target client. Thus, the data flow of each physical network card relative to the target client can be statistically obtained, and then the target physical network card that needs to be load balanced is determined, and the communication protocol connection set of the target physical network card relative to the target client is adjusted to achieve load balancing between the physical network cards on the storage end. It can be seen that the present technical solution can achieve load balancing between the physical network cards in the storage system without affecting the normal operation of the system business, which not only greatly improves the utilization rate of the physical network card, but also effectively ensures the stability of the storage system.
[0047] In one embodiment of the present application, when determining whether to trigger a load balancing operation based on the total data traffic on each physical network card, the network card utilization of each physical network card can be first determined based on the total data traffic on each physical network card. If there is a physical network card whose network card utilization exceeds a first threshold and the difference in network card utilization between it and other physical network cards exceeds a second threshold, it can be determined that a load balancing operation is triggered. Otherwise, the load balancing operation is not triggered. That is to say, when determining whether to trigger a load balancing operation based on the total data traffic on each physical network card, the network card utilization of each physical network card and the difference in network card utilization between the physical network cards are taken into account at the same time, so that it can be more accurately determined whether the current storage end needs to trigger a load balancing operation, thereby ensuring the accuracy of the load balancing result.
[0048] The load balancing device, electronic device, computer-readable storage medium, and computer program product provided in this application also have the above-mentioned technical effects, which will not be described in detail in this application. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions in the prior art and the embodiments of the present application, the drawings required for use in the description of the prior art and the embodiments of the present application are briefly introduced below. Of course, the drawings described below in relation to the embodiments of the present application are only part of the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without creative work, and the obtained other drawings also belong to the protection scope of the present application.
[0050] Figure 1 A schematic diagram of the structure of a cluster system provided in this application;
[0051] Figure 2 A flow chart of a load balancing method provided in this application;
[0052] Figure 3 A flow chart of another load balancing method provided by this application;
[0053] Figure 4 A schematic diagram of the structure of a load balancing device provided in this application;
[0054] Figure 5 A schematic diagram of the structure of an electronic device provided in this application. DETAILED DESCRIPTION
[0055] The core of the present application is to provide a load balancing method, which can achieve load balancing between physical network cards in a storage system without affecting the normal operation of system services, thereby ensuring the stability of the storage system; another core of the present application is to provide a load balancing device, an electronic device, a computer-readable storage medium, and a computer program product, all of which have the above-mentioned beneficial effects.
[0056] In order to describe the technical solutions in the embodiments of the present application more clearly and completely, the technical solutions in the embodiments of the present application will be introduced below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0057] An embodiment of the present application provides a load balancing method.
[0058] First, please refer to Figure 1 , Figure 1 A schematic diagram of the structure of a storage system provided in the present application, the storage system includes a storage end and a client, the storage end and each client are connected through multiple physical network cards, different clients can be connected to the same or different physical network cards, and the same client can also be connected to different physical network cards. The load balancing method provided in the embodiment of the present application is implemented based on the storage system, and load balancing of the physical network card traffic on the storage end is achieved.
[0059] For further information, please refer to Figure 2 , Figure 2 A flow chart of a load balancing method provided in this application, which is applied to Figure 1 The storage end shown may include the following S101 to S105.
[0060] S101: Obtain the total data flow of each physical network card, and determine whether to trigger a load balancing operation according to each total data flow.
[0061] This step aims to achieve effective determination of whether to trigger the load balancing operation in the storage end, and this process can be implemented based on the total data flow in each physical network card on the storage end. Among them, the total data flow of each physical network card obtained refers to the sum of the communication data flow between each physical network card on the storage end and all the clients connected to it. Therefore, it can be determined whether to trigger the load balancing operation of the physical network card on the storage end based on the total data flow of each physical network card.
[0062] Among them, obtaining the total data flow of each physical network card may include: obtaining the binding mode of each client and the physical network card; when the binding mode is a preset binding mode, obtaining the total data flow of each physical network card.
[0063] The embodiment of the present application realizes load balancing processing in a specific network card binding mode. It is understandable that the binding methods between each client and the physical network card are different, and there may be multiple network card binding methods. However, only in a specific network card binding mode will there be a serious problem of unbalanced network port traffic. Therefore, the network card binding mode can be identified first, and then the network card load balancing processing in a specific network card binding mode can be realized. In a possible implementation method, the preset binding mode is mode4 layer3+4 mode, and mode4 layer3+4 mode refers to the selection of characteristic values of the third and fourth layers of the network, and the source IP and source port, destination IP address and destination port of the TCP connection to determine the connected physical network card.
[0064] In one embodiment of the present application, determining whether to trigger a load balancing operation according to each total data flow may include:
[0065] Determine the network card utilization rate of each physical network card according to the total data flow of each physical network card;
[0066] Determine, among all the physical network cards, a first physical network card whose network card utilization exceeds a first threshold;
[0067] When the network card utilization difference between the first physical network card and any other physical network card exceeds a second threshold, it is determined to trigger a load balancing operation.
[0068] The embodiment of the present application provides an implementation method for determining whether to trigger a load balancing operation based on the total data flow on each physical network card. Specifically, after obtaining the total data flow of each physical network card, the network card utilization of each physical network card can be determined based on the total data flow on each physical network card. If there is a physical network card whose network card utilization exceeds the first threshold (in this case, the physical network card is the first physical network card mentioned above) and the network card utilization difference between it and other physical network cards exceeds the second threshold, it can be determined that the load balancing operation is triggered, otherwise the load balancing operation is not triggered. It should be noted that the specific values of the first threshold and the second threshold do not affect the implementation of the present technical solution, and can be set by technical personnel according to actual conditions, and the present application does not limit this.
[0069] It can be seen that in the embodiment of the present application, when determining whether to trigger a load balancing operation based on the total data traffic on each physical network card, the network card utilization of each physical network card and the network card utilization difference between the physical network cards are taken into account at the same time, so that it can be more accurately determined whether the current storage end needs to trigger a load balancing operation, thereby ensuring the accuracy of the load balancing result.
[0070] S102: When a load balancing operation is triggered, for any target client, all communication protocol connections between the target client and the storage end are determined.
[0071] S103: Determine a communication protocol connection set of each physical network card relative to the target client according to all communication protocol connections.
[0072] S104: Determine the data flow of each physical network card relative to the target client according to the communication protocol connection set of each physical network card relative to the target client.
[0073] The above steps are intended to achieve the acquisition of communication data flow between each physical network card and any target client when load balancing is triggered. Specifically, when determining to trigger a load balancing operation, for any client in the storage system, for ease of description, hereinafter referred to as the target client, all communication protocol connections between the target client and the storage end can be determined first. Here, the communication protocol connection can be specifically TCP (Transmission Control Protocol, Transmission Control Protocol) connection; further, according to all communication protocol connections between the target client and the storage end, the communication protocol connection set of each physical network card of the storage end relative to the target client can be determined. For example, assuming that two physical network cards are deployed on the storage end, and a total of 10 communication protocol connections are established between the target client and the storage end, of which 7 communication protocol connections are mapped to physical network card 1, and 3 communication protocol connections are mapped to physical network card 2, then, the communication protocol connection set of physical network card 1 relative to the target client includes 7 communication protocol connections, and the communication protocol connection set of physical network card 2 relative to the target client includes 3 communication protocol connections; finally, according to the communication protocol connection set of each physical network card relative to the target client, the data flow of each physical network card relative to the target client can be determined. Similarly, based on the above example, the data flow of physical network card 1 relative to the target client is the sum of the data flow of 7 communication protocol connections in the communication protocol connection set of physical network card 1 relative to the target client, and the data flow of physical network card 2 relative to the target client is the sum of the data flow of 3 communication protocol connections in the communication protocol connection set of physical network card 2 relative to the target client.
[0074] In one embodiment of the present application, determining the communication protocol connection set of each physical network card relative to the target client according to all communication protocol connections may include:
[0075] For each communication protocol connection corresponding to the target client, determining source address information and destination address information of a data packet in the communication protocol connection;
[0076] The physical network card to which the corresponding communication protocol connection belongs is determined according to the source address information and the destination address information of the data packet, and a communication protocol connection set of each physical network card relative to the target client is obtained.
[0077] The embodiment of the present application provides an implementation method for determining the communication protocol connection set of each physical network card relative to the target client based on all communication protocol connections. It can be understood that this process is essentially to determine which physical network card of the storage end each communication protocol connection between the target client and the storage end is mapped to, which can be determined specifically based on the address information of the data packet in each communication protocol connection. Here, the address information of the data packet in the communication protocol connection includes the source address information and destination address information of the data packet. More specifically, the source address information may include source IP information and source port information, and the destination address information may include destination IP information and destination port information. In this way, the communication protocol connection set of each physical network card on the storage end relative to the target client can be obtained.
[0078] Wherein, determining the physical network card to which the corresponding communication protocol connection belongs according to the source address information and the destination address information of the data packet may include:
[0079] Perform hash operation on the source address information and destination address information of the data packet to obtain a hash value;
[0080] The physical network card number is calculated based on the hash value and the number of physical network cards;
[0081] Determine the physical network card to which the corresponding communication protocol connection belongs based on the physical network card number.
[0082] The embodiment of the present application provides a method for determining the physical network card to which the corresponding communication protocol connection belongs based on the source address information and destination address information of the data packet. Specifically, by performing a hash operation on the source address information and destination address information of the data packet, and combining the number of physical network cards on the storage end, the physical network card number corresponding to the communication protocol connection to which the data packet belongs can be determined, thereby determining which physical network card the communication protocol connection is mapped to.
[0083] In a possible implementation, performing a hash operation on the source address information and the destination address information of the data packet to obtain a hash value may include: performing an XOR operation on each byte in the source address information and the destination address information of the data packet to obtain a hash value;
[0084] Accordingly, calculating the physical network card number according to the hash value and the number of physical network cards may include: performing a bit operation on the hash value to obtain a change value, and performing a modulus operation on the number of physical network cards using the change value to obtain the physical network card number.
[0085] S105: Determine a target physical network card according to the data flow of each physical network card relative to the target client, and adjust the communication protocol connection set of the target physical network card relative to the target client to achieve load balancing.
[0086] Based on S102 to S105, the communication data flow between each physical network card on the storage side and the target client can be calculated, thereby further determining the physical network card that needs to be load balanced, that is, the target physical network card. For example, the physical network card with a larger communication data flow can be used as the target physical network card, and then the communication protocol connection set relative to the target client is adjusted to achieve load balancing between the physical network cards on the storage side. Among them, the adjustment of the communication protocol connection set is to disconnect and reconnect some or all of the communication protocol connections in the communication protocol connection set.
[0087] In one embodiment of the present application, determining a target physical network card according to data traffic of each physical network card relative to a target client, and adjusting a communication protocol connection set of the target physical network card relative to the target client to achieve load balancing may include:
[0088] Determine the maximum data flow rate according to the data flow rate of each physical network card relative to the target client, and use the physical network card corresponding to the maximum data flow rate as the target physical network card;
[0089] For each communication protocol connection in the communication protocol connection set of the target physical network card relative to the target client, obtaining data flow of the communication protocol connection within a first preset time period;
[0090] In the communication protocol connection set, a communication protocol connection whose data flow exceeds a third threshold within a first preset time period is taken as a target communication protocol connection;
[0091] Disconnect the target communication protocol connection so that the target client initiates a reconnection request to the storage end;
[0092] A physical network card is reallocated to the target client according to the reconnection request, and a new communication protocol connection is established with the target client through the newly allocated physical network card; wherein the number of the new communication protocol connections is the same as the number of the target communication protocol connections.
[0093] The embodiment of the present application provides a method for determining a target physical network card and an implementation method for adjusting the communication protocol connection set of the target physical network card relative to the target client. Specifically, after determining the data flow of each physical network card on the storage end relative to the target client, the maximum data flow can be determined from all data flows, then the physical network card corresponding to the maximum data volume is the target physical network card; further, for each communication protocol connection in the communication protocol connection set of the target physical network card relative to the target client, its data flow within the first preset duration can be obtained, then, when the data flow within the first preset duration exceeds the third threshold, it means that the load pressure on the corresponding communication protocol connection is too large, and it needs to be disconnected and reconnected, otherwise it does not need to be disconnected and reconnected. Obviously, the number of disconnected communication protocol connections is the number of newly connected communication protocols. Similarly, the specific values of the above-mentioned first preset duration and the third threshold do not affect the implementation of the present technical solution, and can be set by technical personnel according to actual conditions, and the present application does not limit this.
[0094] Among them, reallocating a physical network card for the target client according to the reconnection request, and establishing a new communication protocol connection with the target client through the newly allocated physical network card may include:
[0095] Determine the number of new communication protocol connections and the number of physical network cards based on the reconnection request;
[0096] The newly created communication protocol connections are evenly distributed according to the number of physical network cards to ensure that the number of newly created communication protocol connections allocated to each physical network card is the same.
[0097] It can be understood that since each disconnected communication protocol connection is reconnected and evenly distributed to each physical network card, load balancing between each physical network card can be further ensured.
[0098] It can be seen that the load balancing method provided in the embodiment of the present application can determine whether to trigger the load balancing operation on the physical network card according to the total data flow in each physical network card for the storage end. When it is determined to trigger the load balancing operation, for any client, that is, the target client, all communication protocol connections between it and itself can be determined first, and the communication protocol connection set of each physical network card relative to the target client can be obtained by combining the connection relationship between each communication connection and each physical network card. Thus, the data flow of each physical network card relative to the target client can be statistically obtained, and then the target physical network card that needs to be load balanced can be determined, and the communication protocol connection set of the target physical network card relative to the target client can be adjusted to achieve load balancing between the physical network cards on the storage end. It can be seen that the technical solution can achieve load balancing between the physical network cards in the storage system without affecting the normal operation of the system business, which not only greatly improves the utilization rate of the physical network card, but also effectively ensures the stability of the storage system.
[0099] Based on the above embodiments:
[0100] In one embodiment of the present application, the load balancing method may further include:
[0101] When the load balancing operation is not triggered, the timer is used to count the static duration;
[0102] When the static time reaches the second preset time, return to the step of obtaining the total data flow of each physical network card, and determine whether to trigger a load balancing operation according to each total data flow.
[0103] Furthermore, after determining the target physical network card based on the data flow of each physical network card relative to the target client, and adjusting the communication protocol connection set of the target physical network card relative to the target client to achieve load balancing, the above-mentioned method can also include: using a timer to count the static duration; when the static duration reaches a second preset duration, returning to obtain the total data flow of each physical network card, and determining whether to trigger a load balancing operation based on each total data flow.
[0104] The load balancing method provided in the embodiment of the present application implements a load balancing solution based on timing conditions, that is, when it is determined that the load balancing operation is not triggered, it can wait for the second preset time length to re-determine whether the load balancing operation needs to be triggered; after the load balancing operation is completed, it can also wait for the second preset time length to re-determine whether the load balancing operation needs to be triggered. In addition, the specific value of the above-mentioned second preset time length does not affect the implementation of the present technical solution, and can be set by technical personnel according to actual conditions, and this application does not limit this.
[0105] Based on the above embodiments, the embodiment of the present application provides another load balancing method.
[0106] Please refer to Figure 3 , Figure 3 A flow chart of another load balancing method provided in this application, the implementation process of which is as follows:
[0107] (1) When the client uses the mode4 layer3+4 mode to bind the physical network card, this service can be enabled to enter the subsequent process.
[0108] (2) Deploy the network card traffic monitoring script on the storage end.
[0109] (3) Schedule the script to be executed at regular intervals, and use the sar command (a system performance analysis tool on Linux) to capture the traffic data of all physical network cards and determine the network card utilization of each physical network card.
[0110] (4) Set the network card utilization difference threshold T1 (second threshold) and the network card utilization threshold T2 (first threshold). For example, if T1=10% and T2=90%, when the network card utilization exceeds T2 and the difference between the network card utilization and that of other physical network cards exceeds T2, the subsequent load balancing process is triggered.
[0111] (5) Entering the load balancing process, the storage end records the TCP connection of each client (taking the target client as an example) connected to the listening port of this storage service, and counts the data flow received from each TCP connection within a period of time (within the first preset time length).
[0112] (6) According to the target client operating system kernel version, determine the hash algorithm for assigning the physical network card to the bound network card, which is used to calculate which physical network card the data packets of each TCP connection will be assigned to. Specifically, perform an XOR operation on each byte of the source IP, source port, destination IP, and destination port of the data packet to obtain the hash value hash, shift the hash right by one bit, and then perform a modulo operation on the number of physical network cards to obtain the sequential number of the physical network cards.
[0113] (7) Based on the data flow of each TCP connection obtained in step (5), count and calculate the data flow sent by the target client to the storage end, and select which TCP connections of the physical network card with larger data flow to allocate to the physical network card with smaller data flow to achieve traffic balance.
[0114] (8) Disconnect the TCP connection of the physical network card that needs to be changed from the storage end.
[0115] (9) After the client detects that the TCP connection is disconnected, it will re-establish the connection. Generally, the kernel will reallocate port numbers that are incremented by 2 (for scenarios where TCP connections are established continuously, if a TCP connection is established and the source port number assigned by the operating system kernel is n, then the source port number assigned to the next established TCP connection will be n+2). The reconnected TCP connection will be evenly mapped to all physical network cards to achieve traffic redistribution.
[0116] (10) After completing a TCP connection reallocation, close the network card traffic monitoring script and re-execute it after a period of time (the second preset time length).
[0117] It can be seen that the load balancing method provided in the embodiment of the present application can determine whether to trigger the load balancing operation on the physical network card according to the total data flow in each physical network card for the storage end. When it is determined to trigger the load balancing operation, for any client, that is, the target client, all communication protocol connections between it and itself can be determined first, and the communication protocol connection set of each physical network card relative to the target client can be obtained by combining the connection relationship between each communication connection and each physical network card. Thus, the data flow of each physical network card relative to the target client can be statistically obtained, and then the target physical network card that needs to be load balanced can be determined, and the communication protocol connection set of the target physical network card relative to the target client can be adjusted to achieve load balancing between the physical network cards on the storage end. It can be seen that the technical solution can achieve load balancing between the physical network cards in the storage system without affecting the normal operation of the system business, which not only greatly improves the utilization rate of the physical network card, but also effectively ensures the stability of the storage system.
[0118] An embodiment of the present application provides a load balancing device.
[0119] Please refer to Figure 4 , Figure 4 This is a schematic diagram of the structure of a load balancing device provided in the present application. The load balancing device is applied to a storage end that can be communicatively connected with each client through a physical network card, and may include:
[0120] The acquisition module 1 is used to obtain the total data flow of each physical network card and determine whether to trigger a load balancing operation according to each total data flow;
[0121] A first determination module 2 is used to determine all communication protocol connections between a target client and a storage end for any target client when a load balancing operation is triggered;
[0122] A second determination module 3, used to determine a communication protocol connection set of each physical network card relative to a target client according to all communication protocol connections;
[0123] A third determination module 4 is used to determine the data flow of each physical network card relative to the target client according to the communication protocol connection set of each physical network card relative to the target client;
[0124] The adjustment module 5 is used to determine the target physical network card according to the data flow of each physical network card relative to the target client, and adjust the communication protocol connection set of the target physical network card relative to the target client to achieve load balancing.
[0125] It can be seen that the load balancing device provided in the embodiment of the present application can determine whether to trigger the load balancing operation on the physical network card according to the total data flow in each physical network card for the storage end. When it is determined to trigger the load balancing operation, for any client, that is, the target client, it can first determine all the communication protocol connections between it and itself, and combine the connection relationship between each communication connection and each physical network card to obtain the communication protocol connection set of each physical network card relative to the target client. Thus, the data flow of each physical network card relative to the target client can be statistically obtained, and then the target physical network card that needs to be load balanced is determined, and the communication protocol connection set of the target physical network card relative to the target client is adjusted to achieve load balancing between the physical network cards on the storage end. It can be seen that the technical solution can achieve load balancing between the physical network cards in the storage system without affecting the normal operation of the system business, which not only greatly improves the utilization rate of the physical network card, but also effectively ensures the stability of the storage system.
[0126] In one embodiment of the present application, the above-mentioned acquisition module 1 can be specifically used to determine the network card utilization of each physical network card based on the total data traffic of each physical network card; among all physical network cards, determine the first physical network card whose network card utilization exceeds a first threshold; when the network card utilization difference between the first physical network card and any other physical network card exceeds a second threshold, determine to trigger a load balancing operation.
[0127] In one embodiment of the present application, the second determining module 3 may include:
[0128] A first determining unit, configured to determine source address information and destination address information of a data packet in a communication protocol connection for each communication protocol connection corresponding to a target client;
[0129] The second determining unit is used to determine the physical network card to which the corresponding communication protocol connection belongs according to the source address information and the destination address information of the data packet, and obtain the communication protocol connection set of each physical network card relative to the target client.
[0130] In one embodiment of the present application, the above-mentioned first determination unit can be specifically used to perform hash operation on the source address information and destination address information of the data packet to obtain a hash value; calculate the physical network card number based on the hash value and the number of physical network cards; and determine the physical network card to which the corresponding communication protocol connection belongs based on the physical network card number.
[0131] In one embodiment of the present application, the above-mentioned adjustment module 5 can be specifically used to determine the maximum data flow based on the data flow of each physical network card relative to the target client, and use the physical network card corresponding to the maximum data flow as the target physical network card; for each communication protocol connection in the communication protocol connection set of the target physical network card relative to the target client, obtain the data flow of the communication protocol connection within a first preset time length; in the communication protocol connection set, use the communication protocol connection whose data flow exceeds a third threshold within the first preset time length as the target communication protocol connection; disconnect the target communication protocol connection so that the target client initiates a reconnection application to the storage end; reallocate the physical network card to the target client according to the reconnection application, and establish a new communication protocol connection with the target client through the newly allocated physical network card; wherein the number of new communication protocol connections is the same as the number of target communication protocol connections.
[0132] In one embodiment of the present application, the above-mentioned acquisition module 1 can be specifically used to obtain the binding mode of each client and the physical network card; when the binding mode is a preset binding mode, the total data flow of each physical network card is obtained, and whether to trigger the load balancing operation is determined based on the total data flow.
[0133] In one embodiment of the present application, the load balancing device may also include a loop module, which is used to use a timer to count the static duration when the load balancing operation is not triggered; when the static duration reaches a second preset duration, it returns to obtain the total data flow of each physical network card, and determines whether to trigger the load balancing operation based on the total data flow.
[0134] For an introduction to the device provided in the embodiments of the present application, please refer to the above method embodiments, and the present application will not elaborate on them here.
[0135] An embodiment of the present application provides an electronic device.
[0136] Please refer to Figure 5 , Figure 5 This is a schematic diagram of the structure of an electronic device provided in this application, and the electronic device may include:
[0137] A memory 11, used for storing computer programs;
[0138] The processor 10 can implement the steps of any of the above-mentioned load balancing methods when executing a computer program.
[0139] like Figure 5 , which is a schematic diagram of the composition structure of an electronic device, the electronic device may include: a processor 10, a memory 11, a communication interface 12 and a communication bus 13. The processor 10, the memory 11 and the communication interface 12 all communicate with each other through the communication bus 13.
[0140] In the embodiment of the present application, the processor 10 may be a central processing unit (CPU), an application specific integrated circuit, a digital signal processor, a field programmable gate array or other programmable logic devices, etc.
[0141] The processor 10 may call a program stored in the memory 11. Specifically, the processor 10 may execute operations in an embodiment of the load balancing method.
[0142] The memory 11 is used to store one or more programs, which may include program codes, and the program codes include computer operation instructions. In the embodiment of the present application, the memory 11 at least stores programs for implementing the following functions:
[0143] Obtain the total data flow of each physical network card, and determine whether to trigger a load balancing operation based on the total data flow;
[0144] When a load balancing operation is triggered, for any target client, all communication protocol connections between the target client and the storage end are determined;
[0145] Determine, based on all communication protocol connections, a communication protocol connection set of each physical network card relative to a target client;
[0146] Determine the data flow of each physical network card relative to the target client according to the communication protocol connection set of each physical network card relative to the target client;
[0147] The target physical network card is determined according to the data flow of each physical network card relative to the target client, and the communication protocol connection set of the target physical network card relative to the target client is adjusted to achieve load balancing.
[0148] In a possible implementation, the memory 11 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function, etc.; the data storage area may store data created during use.
[0149] In addition, the memory 11 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device or other volatile solid-state storage device.
[0150] The communication interface 12 may be an interface of a communication module, and is used to connect to other devices or systems.
[0151] Of course, it should be noted that Figure 5 The structure shown does not constitute a limitation on the electronic device in the embodiment of the present application. In actual applications, the electronic device may include Figure 5 More or fewer components than shown, or combinations of certain components.
[0152] An embodiment of the present application provides a computer-readable storage medium.
[0153] The computer-readable storage medium provided in the embodiment of the present application stores a computer program, and when the computer program is executed by a processor, the steps of any of the above-mentioned load balancing methods can be implemented.
[0154] Among them, the computer-readable storage medium can be any available medium that can be stored in a computer or a data storage device such as a server or data center that includes one or more available media integrated. For example, it can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape, etc.), an optical medium (such as a DVD) or a semiconductor medium (such as a solid-state hard disk) and other media that can store computer program codes.
[0155] For an introduction to the computer-readable storage medium provided in the embodiments of the present application, please refer to the above method embodiments, and the present application will not elaborate on them here.
[0156] An embodiment of the present application provides a computer program product.
[0157] The computer program product provided in the embodiments of the present application includes a computer program / instruction, and when the computer program / instruction is executed by a processor, the steps of any of the above-mentioned load balancing methods can be implemented.
[0158] Specifically, in the above embodiments, all or part of them can be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of them can be implemented in the form of a computer program product.
[0159] Among them, the computer program product may include one or more computer programs / instructions, and when the computer program / instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application may be generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. Computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, computer instructions may be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line, etc.) or wireless (e.g., infrared, wireless, microwave, etc.) means.
[0160] For an introduction to the computer program product provided in the embodiments of the present application, please refer to the above method embodiments, and the present application will not elaborate on them here.
[0161] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0162] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0163] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0164] The technical solution provided by the present application is described in detail above. The principle and implementation method of the present application are described in detail using specific examples herein, and the description of the above embodiments is only used to help understand the method and core idea of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the present application.
Claims
1. A load balancing method, characterized in that: Applied to a storage end, the storage end is connected to each client through a physical network card, and the method includes: Obtaining the total data flow of each physical network card, and determining whether to trigger a load balancing operation according to each total data flow; When the load balancing operation is triggered, for any target client, all communication protocol connections between the target client and the storage end are determined; Determining a communication protocol connection set of each physical network card relative to the target client based on all the communication protocol connections; Determining the data flow of each physical network card relative to the target client according to the communication protocol connection set of each physical network card relative to the target client; A target physical network card is determined according to the data traffic of each physical network card relative to the target client, and a communication protocol connection set of the target physical network card relative to the target client is adjusted to achieve load balancing.
2. The load balancing method according to claim 1, wherein: Determining whether to trigger a load balancing operation according to each of the total data flows includes: Determine the network card utilization rate of each physical network card according to the total data flow of each physical network card; Determine, among all the physical network cards, a first physical network card whose network card utilization exceeds a first threshold; When the network card utilization difference between the first physical network card and any other physical network card exceeds a second threshold, it is determined to trigger the load balancing operation.
3. The load balancing method according to claim 1, wherein: Determining a communication protocol connection set of each physical network card relative to the target client based on all the communication protocol connections includes: For each communication protocol connection corresponding to the target client, determining source address information and destination address information of a data packet in the communication protocol connection; The physical network card to which the corresponding communication protocol connection belongs is determined according to the source address information and the destination address information of the data packet, and a communication protocol connection set of each physical network card relative to the target client is obtained.
4. The load balancing method according to claim 3, wherein: Determining the physical network card to which the corresponding communication protocol connection belongs according to the source address information and the destination address information of the data packet includes: Performing a hash operation on the source address information and the destination address information of the data packet to obtain a hash value; Obtaining a physical network card number based on the hash value and the number of physical network cards; The physical network card to which the corresponding communication protocol connection belongs is determined according to the physical network card number.
5. The load balancing method according to claim 1, wherein: Determining a target physical network card according to data traffic of each physical network card relative to the target client, and adjusting a communication protocol connection set of the target physical network card relative to the target client to achieve load balancing, including: Determine a maximum data flow rate according to the data flow rate of each physical network card relative to the target client, and use the physical network card corresponding to the maximum data flow rate as the target physical network card; For each communication protocol connection in the communication protocol connection set of the target physical network card relative to the target client, obtaining data flow of the communication protocol connection within a first preset time period; In the communication protocol connection set, a communication protocol connection whose data flow exceeds a third threshold within the first preset time period is selected as a target communication protocol connection; Disconnecting the target communication protocol connection so that the target client initiates a reconnection request to the storage end; Reallocate a physical network card for the target client according to the reconnection application, and establish a new communication protocol connection with the target client through the newly allocated physical network card; wherein the number of the new communication protocol connections is the same as the number of the target communication protocol connections.
6. The load balancing method according to claim 1, wherein: Obtaining the total data flow of each physical network card, and determining whether to trigger a load balancing operation according to each total data flow, including: Obtaining a binding mode between each of the clients and the physical network card; When the binding mode is a preset binding mode, the total data flow of each physical network card is obtained, and it is determined whether to trigger the load balancing operation according to each total data flow.
7. The load balancing method according to claim 1, wherein: Also includes: When the load balancing operation is not triggered, a timer is used to count the static duration; When the static time reaches a second preset time, the process returns to the step of obtaining the total data flow of each physical network card, and determining whether to trigger a load balancing operation according to each total data flow.
8. A load balancing device, characterized in that: Applied to a storage end, the storage end is connected to each client through a physical network card, and the device includes: An acquisition module, configured to acquire the total data flow of each physical network card and determine whether to trigger a load balancing operation based on the total data flow; A first determining module is configured to, when the load balancing operation is triggered, determine, for any target client, all communication protocol connections between the target client and the storage end; A second determining module is configured to determine a communication protocol connection set of each physical network card relative to the target client based on all the communication protocol connections; A third determining module is configured to determine the data flow of each physical network card relative to the target client according to the communication protocol connection set of each physical network card relative to the target client; The adjustment module is used to determine the target physical network card according to the data flow of each physical network card relative to the target client, and adjust the communication protocol connection set of the target physical network card relative to the target client to achieve load balancing.
9. An electronic device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the load balancing method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the load balancing method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Hash-based network card soft interrupt and load balancing method
CN103049336A
Network load balancing method and device
CN107592370A
Flow moving method and network equipment
CN115987763A
Cited By
Storage and network integrated server network card and flow scheduling and processing method
CN122496503A