Load balancing method and device, electronic equipment and storage medium
By extracting the five-tuple information of data packets in the programmable switch of the cloud computer room to calculate the hash value, and intelligently allocating traffic with the load balancing rules, the load balancing problem of cloud computer room is solved, and efficient, dynamic and adaptive load is achieved. The balance mechanism reduces costs and improves system reliability and scalability.
Patent Information
- Application Number
- CN202411129060.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2024-11-22
AI Technical Summary
Cloud computer rooms face load balancing problems in dealing with large traffic scenarios. The existing technology is costly and insufficient resource allocation, making it difficult to meet the needs of efficient load balancing.
By obtaining the data packets to be allocated and load balancing rules in the programmable switch, extracting five-tuple information to calculate the hash value, and determining the back-end server based on the hash value and load balancing rules to achieve intelligent traffic allocation.
It improves the efficiency and accuracy of traffic allocation, optimizes resource utilization, ensures network stability and response speed in high concurrency scenarios, supports flexible load balancing strategy adjustment, and adapts to different network environments and business needs.
Smart Images

Figure CN119011594A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, specifically to technical fields such as cloud computing and network communications, and in particular to load balancing methods, devices, electronic devices, and storage media. Background Art
[0002] With the rapid development of artificial intelligence (AI) technology, the data processing needs faced by cloud computing rooms have increased dramatically, and traffic has grown from hundreds of gigabits (Gbps) to several terabits (Tbps). In this large-traffic processing scenario, whether the cloud computing room can withstand the huge impact of business traffic has not only become a key indicator for measuring the effectiveness of AI technology applications, but also is crucial to maintaining service stability and improving user experience. In order to meet this challenge, cloud computing rooms must adopt efficient traffic management and distribution mechanisms to ensure the efficiency and stability of data transmission and avoid service interruptions or performance bottlenecks caused by single-point overload. Therefore, the problem of achieving load balancing has become particularly urgent and important.
[0003] Load balancing technology can optimize resource utilization and improve system scalability and fault tolerance by intelligently distributing network traffic to multiple servers. In an AI-driven business environment, load balancing not only involves traditional network traffic distribution, but also needs to take into account the computing load of AI models, the real-time processing requirements of data, and the dependencies between different services. This requires load balancing solutions to have not only high performance and high availability, but also flexibility and intelligence to adapt to changing business needs and technological evolution. Summary of the invention
[0004] The present disclosure provides a load balancing method, device, electronic device and storage medium.
[0005] According to one aspect of the present disclosure, a load balancing method is provided, which is applied to a programmable switch, and the method includes:
[0006] Get the data packets to be distributed and the load balancing rules;
[0007] Extracting five-tuple information from the data packet to be allocated, and calculating a hash value corresponding to the data packet to be allocated according to the five-tuple information;
[0008] According to the load balancing rule and the hash value corresponding to the data packet to be distributed, a backend server corresponding to the data packet to be distributed is determined.
[0009] According to another aspect of the present disclosure, a load balancing device is provided, comprising:
[0010] An acquisition module is used to obtain data packets to be distributed and load balancing rules;
[0011] A calculation module, used for extracting five-tuple information from the data packet to be allocated, and calculating a hash value corresponding to the data packet to be allocated according to the five-tuple information;
[0012] The determination module is used to determine the backend server corresponding to the data packet to be allocated according to the load balancing rule and the hash value corresponding to the data packet to be allocated.
[0013] According to a third aspect of the present disclosure, there is provided an electronic device, including:
[0014] at least one processor; and
[0015] a memory communicatively connected to the at least one processor; wherein,
[0016] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any method in any of the above technical solutions.
[0017] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute any one of the methods described in the above technical solutions.
[0018] According to a fifth aspect of the present disclosure, a computer program product is provided, including a computer program, wherein the computer program implements any one of the methods described in the above technical solutions when executed by a processor.
[0019] The present disclosure provides a load balancing method, device, equipment and storage medium. The present disclosure first accurately extracts five-tuple information from the data packet to be allocated, and then uses the five-tuple information to calculate a corresponding hash value. Since the data packets of the same five-tuple always generate the same hash value, the continuity of the session can be maintained. Then, the corresponding back-end server is determined according to the load balancing rule and the hash value to allocate the data packet to the appropriate back-end server. This allocation method can not only improve the efficiency and accuracy of traffic distribution, but also optimize resource utilization through intelligent algorithms, ensuring network stability and response speed in high-concurrency scenarios. In addition, the method supports flexible load balancing strategy adjustment, can adapt to different network environments and business needs, and significantly improves the reliability and scalability of the system. It can be seen that the load balancing method realizes an efficient, dynamic and adaptive load balancing mechanism, providing users with a more stable and efficient network service experience.
[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0022] Figure 1 is a schematic diagram of the steps of the load balancing method in an embodiment of the present disclosure;
[0023] Figure 2 is a system schematic diagram corresponding to the load balancing method in an embodiment of the present disclosure;
[0024] Figure 3 A principle block diagram of a load balancing device in an embodiment of the present disclosure;
[0025] Figure 4 It is a block diagram of an electronic device used to implement the load balancing method of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0026] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0027] In the current network architecture of cloud computing rooms, high-traffic gateways mostly use DPDK (Data Plane Development Kit) combined with X86 servers. However, the network cards of X86 servers are generally 25G or 100G. If you want to process several TB of data, you need to continuously expand the machine horizontally.
[0028] With the continuous advancement of high-performance server technology, programmable P4 switches have emerged, which greatly enhance the ability of a single device to handle network traffic. The performance improvement of P4 switches is significant, from the traditional 25Gbps to an astonishing 64Tbps, which has brought revolutionary changes to cloud computing rooms. At present, many key gateways have begun to use P4 switches to achieve more efficient traffic management.
[0029] However, despite the huge breakthrough in performance, the P4 switch still faces the problem of limited resources. Especially in application scenarios that require the storage of a large number of session tables, such as load balancing services, the current resource configuration of the P4 switch is still difficult to meet these requirements. This limitation has led to the fact that load balancing gateways have not yet been widely used on P4 switches. In related technical solutions, in order to allow load balancing devices to also enjoy the advantages brought by P4 switches, the usual practice is to combine P4 switches with FPGA chips, that is, to store session tables through FPGA chips. However, due to the high cost of FPGA chips, this technology is difficult to implement in practice.
[0030] It can be seen that, if the load balancing gateway in the existing cloud computing network is implemented by X86 server + DPDK, it is necessary to horizontally expand the capacity of many machines for large traffic scenarios, which greatly increases the cost; if it is implemented by P4 switch + FPGA chip, the cost is also relatively high due to the expensive FPGA chip.
[0031] In order to solve the above technical problems, the present invention provides a new load balancing method. Figure 1 As shown, Figure 1 : is a schematic diagram of the steps of a load balancing method in an embodiment of the present disclosure, which is applied to a programmable switch, such as a P4 switch. The method includes:
[0032] Step S101, obtaining data packets to be distributed and load balancing rules.
[0033] Specifically, the data to be allocated refers to the data packet that is ready for routing forwarding. The data packet usually contains the source address, destination address, port number and other information required for network communication, among which the data packet to be allocated can be obtained from the client. The load balancing rule refers to the rules set in advance according to the needs and policies of network traffic management to guide how to reasonably allocate traffic to different back-end servers. Load balancing rules can be, for example, different strategies, such as polling, minimum number of connections, server weight, geographic location, etc. In this way, by first obtaining the data packet to be allocated and the load balancing rules, it can be ensured that all necessary information and instructions have been received and understood by the system before the data packet is further processed, laying the foundation for subsequent data packet classification, hash calculation and intelligent allocation to the appropriate back-end server.
[0034] Step S102, extracting five-tuple information from the data packet to be allocated, and calculating a hash value corresponding to the data packet to be allocated based on the five-tuple information.
[0035] Specifically, after obtaining the data packets to be allocated, the data packets to be allocated are received and identified, which may contain requests or responses for network communications. Then, the key five-tuple information is extracted from each data packet. The five elements include: source address, source port, protocol, destination address, and destination port. These elements together define the network path and communication endpoint of the data packet. After extracting the five-tuple information from the data packet to be allocated, a hash function can be used to calculate a hash value in numerical form using the extracted five-tuple information as input, so as to obtain a hash value corresponding to the data packet to be allocated. By obtaining the hash value, it is convenient to make subsequent load balancing decisions.
[0036] Step S103, determining the backend server corresponding to the data packet to be allocated according to the load balancing rule and the hash value corresponding to the data packet to be allocated.
[0037] Specifically, by combining load balancing rules and hash values, data packets can be intelligently directed to the most appropriate backend server, ensuring that traffic is evenly distributed to all backend servers, avoiding single-point overload and improving the overall processing capacity of the system. Secondly, through precise traffic distribution, the system can more effectively utilize server resources and avoid resource waste.
[0038] In order to facilitate understanding of the scheme of the embodiment of the present disclosure, an example is given below. For example, there is a data packet, and five-tuple information is extracted from the data packet. The five-tuple information is source IP 192.168.1.5, source port 80, destination IP 192.168.1.2, destination port 8080, and protocol TCP. After the five-tuple information is extracted, a hash function such as SHA-256 is used to process the five-tuple information, so that a hash value, such as 7c222fb..., can be obtained. This hash value will be used for subsequent load balancing decisions, and may be divided by the size of the server list through a modulo operation to obtain an index value to indicate that the data packet should be sent to a specific backend server, such as server 3. In this way, each data packet with the same five-tuple characteristics will be consistently routed to the same server, thereby achieving session retention and load balancing.
[0039] The present disclosure provides a load balancing method, device, equipment and storage medium. The present disclosure first accurately extracts five-tuple information from the data packet to be allocated, and then uses the five-tuple information to calculate a corresponding hash value. Since the data packets of the same five-tuple always generate the same hash value, the continuity of the session can be maintained. Then, the corresponding back-end server is determined according to the load balancing rule and the hash value to allocate the data packet to the appropriate back-end server. This allocation method can not only improve the efficiency and accuracy of traffic distribution, but also optimize resource utilization through intelligent algorithms, ensuring network stability and response speed in high-concurrency scenarios. In addition, the method supports flexible load balancing strategy adjustment, can adapt to different network environments and business needs, and significantly improves the reliability and scalability of the system. It can be seen that the load balancing method realizes an efficient, dynamic and adaptive load balancing mechanism, providing users with a more stable and efficient network service experience.
[0040] In some optional embodiments, extracting quintuple information from the data packet to be allocated, and calculating a hash value corresponding to the data packet to be allocated according to the quintuple information includes:
[0041] Extract five-tuple information from the data packet to be distributed;
[0042] The five-tuple information is processed using a hash function to obtain a hash value corresponding to the data packet to be allocated.
[0043] Specifically, the data packet can be captured by setting the monitoring mode on the network interface or using a network monitoring tool, and then the header information of the data packet can be analyzed to identify and extract the elements of the five-tuple from the header information of the data packet, which elements include: source address, source port, protocol, destination address, and destination port. Among them, the source address is the address of the sender, the source port is the port number of the sender, the protocol is such as TCP (Transmission Control Protocol), UDP (User Datagram Protocol), etc., the destination address is the address of the receiver, and the destination port is the port number of the receiver.
[0044] After extracting the key five-tuple information from each data packet to be distributed, the five-tuple information can be converted into a format suitable for hash function processing. For example, the IP address is converted from dotted decimal format to binary format, and the port number and protocol type are converted to network byte order. A hash function is then used to calculate and process these five-tuple information. After the hash function processing is completed, a fixed-length hash value is obtained.
[0045] In this way, by using a hash function to process the five-tuple information, a hash value corresponding to the data packet to be distributed is obtained. Since the same five-tuple always generates the same hash value, this method can maintain the continuity of the user session. Secondly, the calculation of hash values provides a fast and effective method to process and route a large amount of network traffic, enhancing the scalability and processing power of the system. In addition, since the hash function can evenly distribute the five-tuple to different hash values, this helps to achieve load balancing and avoid the situation where some servers are overloaded while other servers are idle, thereby optimizing resource utilization and improving the overall performance and response speed of the system.
[0046] In some optional embodiments, a hash function is used to process the five-tuple information to obtain a hash value corresponding to the data packet to be allocated, including:
[0047] Get the hash function;
[0048] Combine the five-tuple information into a hash key;
[0049] The hash key is input into the hash function for calculation to obtain a hash value corresponding to the data packet to be distributed.
[0050] Specifically, the hash function is used to map the five-tuple information (source address, source port, protocol, destination address, destination port) to a hash value, wherein the hash function in the embodiment of the present disclosure may be, for example, MD5, SHA-1, SHA-256, etc.
[0051] Secondly, after obtaining the five-tuple information, convert each element in the five-tuple into a unified format, for example, convert the IP address into dotted decimal form, convert the port number and protocol type into network byte order, and splice the elements of the five-tuple together in a fixed order. For example, you can first splice the source address, then the source port, then the destination address, destination port, and finally the protocol type. Finally, the spliced data string is input into the hash function as a hash key, and the hash value corresponding to the data packet to be distributed is calculated through the hash function.
[0052] In this way, by first obtaining a suitable hash function, then combining the five-tuple information including source address, source port, protocol, destination address, and destination port into a hash key, and inputting the hash key into the hash function for calculation to generate a unique hash value. This ensures the consistency and predictability of traffic distribution and improves the efficiency of load balancing.
[0053] In some optional embodiments, determining the backend server corresponding to the data packet to be allocated according to the load balancing rule and the hash value corresponding to the data packet to be allocated includes:
[0054] Get the mapping table between the hash value contained in the load balancing rule and the backend server;
[0055] Obtaining a mapping result according to a hash value corresponding to the data packet to be distributed and a mapping table between the hash value and the backend server;
[0056] The backend server corresponding to the data packet to be distributed is determined according to the mapping result.
[0057] Specifically, the load balancing rules contain a mapping table between hash values and backend servers, and the mapping table between hash values and backend servers can be constructed in the following way: first, clarify the generation method of hash values and the composition of servers according to the predefined load balancing strategy, then create a mapping logic, which may be based on simple modular operations or more complex algorithms to associate each possible hash value with a specific backend server, and then build a mapping table. Finally, configure the mapping table to the load balancer to ensure that it can intelligently distribute incoming traffic to the most appropriate server based on this table, achieving efficient and balanced traffic management.
[0058] After constructing a mapping table between hash values and backend servers, it is possible to determine to which backend server the data packet to be distributed needs to be distributed according to the hash value corresponding to the data packet to be distributed, so as to achieve load balancing.
[0059] In this way, by accurately matching the hash value with the mapping table of the backend server, the accuracy and efficiency of traffic distribution are improved, ensuring that traffic is evenly distributed among servers, and achieving highly flexible and intelligent traffic distribution, thereby optimizing resource utilization and overall system performance. In addition, by dynamically adjusting the mapping table, it can adapt to changing network conditions and business needs, effectively avoiding the risk of single point overload. In addition, this approach simplifies complex traffic management tasks, provides a fast, automated decision-making mechanism, reduces the need for manual intervention, and further improves the stability and responsiveness of the network.
[0060] In some optional embodiments, determining the backend server corresponding to the data packet to be allocated according to the mapping result includes:
[0061] If there is a backend server matching the hash value corresponding to the data packet to be distributed in the mapping table between hash values and backend servers, the data packet to be distributed is distributed to the matching backend server.
[0062] Specifically, a hash function is first used to generate a hash value of the data packet, and then a pre-built mapping table is queried, which associates the hash value with a specific server in the backend server list. If there is a backend server matching the hash value in the mapping table, the data packet is directly assigned to the server. By determining the backend server corresponding to the data packet to be assigned based on the mapping result, an efficient and accurate traffic distribution mechanism can be implemented.
[0063] In this way, by determining the backend server corresponding to the data packet to be allocated based on the mapping results, this method can optimize the utilization efficiency of server resources, reduce the risk of service delays or failures caused by server overload, and also improve the performance and stability of the entire network system. In addition, this method supports dynamic adjustment and can adapt to fluctuations in network traffic and changes in server status, thereby maintaining efficient load balancing while also improving the flexibility and scalability of the system.
[0064] In order to facilitate the overall understanding of the scheme of the embodiment of the present disclosure, an example is given as follows. It is assumed that there are three back-end servers with IP addresses of 192.168.1.2, 192.168.1.3, and 192.168.1.4, and the hash function used is the SHA-256 hash function. Assume that a data packet with a destination IP of 192.168.1.1 is received, and the five-tuple information of the data packet is extracted: source IP 10.0.0.1, source port 4500, destination IP 192.168.1.1, destination port 80, protocol TCP. Then, use SHA-256 to hash the five-tuple information to obtain the hash value hash_value. Assuming that the hash value is a large integer, an index between 0 and 2 can be obtained by taking the modulus operation index=hash_value%3. According to the calculated index index, find the corresponding server IP in the mapping table. For example, if the index is 0, 192.168.1.2 is selected as the target server, and finally, the data packet is forwarded to the determined backend server 192.168.1.2. In this way, through this process, each data packet is intelligently assigned to the most appropriate backend server according to its five-tuple information and load balancing rules, thereby achieving load balancing and efficient use of resources.
[0065] In some optional embodiments, after determining the backend server corresponding to the data packet to be allocated, the method further includes:
[0066] Get the status information of the backend server;
[0067] Dynamically adjust load balancing rules based on the status information of the backend server.
[0068] Specifically, the status information of the backend server may include, for example, performance indicators, health status, response time, error rate, resource usage, availability of dependent services, security status, and log records, etc. These status information together depict the real-time operation status of the server. The status information of the backend server may be obtained by implementing periodic health checks, collecting performance indicators using system monitoring tools, analyzing log files to identify abnormal events, obtaining configuration and status data through the configuration management database (CMDB), calling the server management API (Application Programming Interface) to obtain real-time information, checking the operation status of dependent services, setting up an alarm system to notify in time when the status is abnormal, and collecting possible user feedback.
[0069] When dynamically adjusting load balancing rules based on the status information of the backend server, for example, you can monitor the performance indicators and health status of the server in real time, such as CPU (Central Processing Unit) and memory usage, response time and error rate, and then evaluate the current load and capacity of the server based on these data points. Once a change in server status is detected, such as a long response time or an increased error rate, the system will automatically trigger a preset adjustment strategy, which may include reallocating traffic to lighter servers, increasing or decreasing the traffic share of a specific server, temporarily disabling unhealthy servers, or selecting the best server for traffic routing based on custom priority rules. This dynamic adjustment ensures that network traffic is always effectively distributed, maximizing resource utilization, while improving user experience and overall system stability.
[0070] In this way, by obtaining the status information of the backend server to dynamically adjust the load balancing rules, this method can provide a comprehensive and real-time view of the server status for load balancing decisions, ensuring that traffic is intelligently allocated to healthy and optimally performing servers. In addition, the ability to dynamically adjust load balancing rules enables the system to flexibly respond to changing network conditions and business needs, thereby ensuring service quality while also improving the elasticity and scalability of the entire network architecture.
[0071] In some optional embodiments, see Figure 2 , Figure 2It is a system diagram corresponding to the load balancing method in an embodiment of the present disclosure. The system includes a P4 switch hardware processing part (that is, a load balancing device based on a P4 switch in the corresponding figure), a load balancing instance configuration sending module, and a health check device, wherein the load balancing device based on the P4 switch is used to execute the load balancing method of the embodiment of the present disclosure, after the load balancing rules are configured at the service configuration front end, the load balancing rules are sent to the load balancing device based on the P4 switch in real time through the load balancing instance configuration sending module, and the health check device is used to check the status of each backend server, and send the inspection results to the P4 switch through the load balancing instance configuration sending module.
[0072] The specific workflow of the system is as follows: after the client sends a request, the request data flow first reaches the load balancing device based on the P4 switch; the service configuration front end receives the load balancing rules configured by the user, and sends these configuration information to the P4 switch through the control flow; at the same time, the health check module independently performs real-time health checks on the back-end servers, and feeds back the health status to the P4 switch through the control flow; the P4 switch intelligently distributes traffic to healthy back-end servers based on the polling algorithm of the five-tuple hash and the real-time health check results; for specific businesses that are not applicable to this algorithm, the P4 switch forwards the request to the X86 load balancing device for processing to ensure that all requests can be reasonably distributed and processed.
[0073] The following describes an apparatus embodiment of the present application, which can be used to execute the load balancing method in the above-mentioned embodiment of the present application. For details not disclosed in the apparatus embodiment of the present application, please refer to the above-mentioned embodiment of the load balancing method of the present application.
[0074] The present disclosure also provides a load balancing device 300, such as Figure 3 As shown, including:
[0075] An acquisition module 301 is used to acquire data packets to be distributed and load balancing rules;
[0076] The calculation module 302 is used to extract the five-tuple information from the data packet to be allocated, and calculate the hash value corresponding to the data packet to be allocated according to the five-tuple information;
[0077] The determination module 303 is used to determine the backend server corresponding to the data packet to be allocated according to the load balancing rule and the hash value corresponding to the data packet to be allocated.
[0078] In some optional embodiments, the calculation module 302 extracts the five-tuple information from the data packet to be allocated, and calculates the hash value corresponding to the data packet to be allocated according to the five-tuple information, including:
[0079] Extract five-tuple information from the data packet to be distributed;
[0080] The five-tuple information is processed using a hash function to obtain a hash value corresponding to the data packet to be allocated.
[0081] In some optional embodiments, the calculation module 302 processes the five-tuple information using a hash function to obtain a hash value corresponding to the data packet to be allocated, including:
[0082] Get the hash function;
[0083] Combine the five-tuple information into a hash key;
[0084] The hash key is input into the hash function for calculation to obtain a hash value corresponding to the data packet to be distributed.
[0085] In some optional embodiments, the determination module 303 determines the backend server corresponding to the data packet to be allocated according to the load balancing rule and the hash value corresponding to the data packet to be allocated, including:
[0086] Get the mapping table between the hash value contained in the load balancing rule and the backend server;
[0087] Obtaining a mapping result according to a hash value corresponding to the data packet to be distributed and a mapping table between the hash value and the backend server;
[0088] The backend server corresponding to the data packet to be distributed is determined according to the mapping result.
[0089] In some optional embodiments, the determination module 303 determines the backend server corresponding to the data packet to be allocated according to the mapping result, including:
[0090] If there is a backend server matching the hash value corresponding to the data packet to be distributed in the mapping table between hash values and backend servers, the data packet to be distributed is distributed to the matching backend server.
[0091] In some optional embodiments, after determining the backend server corresponding to the data packet to be allocated, the determination module 303 is further configured to:
[0092] Get the status information of the backend server;
[0093] Dynamically adjust load balancing rules based on the status information of the backend server.
[0094] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0095] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0096] Figure 4 A schematic block diagram of an example electronic device 400 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0097] like Figure 4 As shown, the electronic device 400 includes a computing unit 401, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 402 or a computer program loaded from a storage unit 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the device 400 can also be stored. The computing unit 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0098] A number of components in the device 400 are connected to the I / O interface 405, including: an input unit 406, such as a keyboard, a mouse, etc.; an output unit 407, such as various types of displays, speakers, etc.; a storage unit 408, such as a disk, an optical disk, etc.; and a communication unit 409, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 409 allows the device 400 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0099] The computing unit 401 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 401 performs the various methods and processes described above, such as a load balancing method. For example, in some embodiments, the load balancing method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 408. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 400 via ROM 402 and / or communication unit 409. When the computer program is loaded into RAM 403 and executed by the computing unit 401, one or more steps of the applet distribution described above may be performed. Alternatively, in other embodiments, the computing unit 401 may be configured to perform the load balancing method in any other appropriate manner (e.g., by means of firmware).
[0100] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0101] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0102] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0103] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0104] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0105] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0106] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0107] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A load balancing method, applied to a programmable switch, comprising: Get the data packets to be distributed and the load balancing rules; Extracting five-tuple information from the data packet to be allocated, and calculating a hash value corresponding to the data packet to be allocated according to the five-tuple information; According to the load balancing rule and the hash value corresponding to the data packet to be distributed, a backend server corresponding to the data packet to be distributed is determined.
2. The method according to claim 1, wherein: The extracting five-tuple information from the data packet to be allocated, and calculating a hash value corresponding to the data packet to be allocated according to the five-tuple information, includes: Extracting five-tuple information from the data packet to be allocated; The five-tuple information is processed using a hash function to obtain a hash value corresponding to the data packet to be distributed.
3. The method according to claim 2, wherein: The adopting a hash function to process the five-tuple information to obtain a hash value corresponding to the data packet to be allocated includes: Get the hash function; Combining the five-tuple information into a hash key; The hash key is input into the hash function for calculation to obtain a hash value corresponding to the data packet to be distributed.
4. The method according to claim 1, wherein: The step of determining the backend server corresponding to the data packet to be allocated according to the load balancing rule and the hash value corresponding to the data packet to be allocated comprises: Obtaining a mapping table between the hash value contained in the load balancing rule and the backend server; Obtaining a mapping result according to a hash value corresponding to the data packet to be distributed and a mapping table between the hash value and the backend server; A back-end server corresponding to the data packet to be distributed is determined according to the mapping result.
5. The method according to claim 4, wherein: The step of determining the back-end server corresponding to the data packet to be allocated according to the mapping result includes: If there is a backend server matching the hash value corresponding to the data packet to be distributed in the mapping table between the hash value and the backend server, the data packet to be distributed is distributed to the matching backend server.
6. The method according to any one of claims 1 to 5, wherein: After determining the back-end server corresponding to the data packet to be distributed, the method further includes: Obtaining status information of the backend server; The load balancing rules are dynamically adjusted according to the status information of the backend server.
7. A load balancing device, comprising: An acquisition module is used to obtain data packets to be distributed and load balancing rules; A calculation module, used for extracting five-tuple information from the data packet to be allocated, and calculating a hash value corresponding to the data packet to be allocated according to the five-tuple information; The determination module is used to determine the backend server corresponding to the data packet to be allocated according to the load balancing rule and the hash value corresponding to the data packet to be allocated.
8. The device according to claim 7, wherein: The calculation module extracts five-tuple information from the data packet to be allocated, and calculates a hash value corresponding to the data packet to be allocated according to the five-tuple information, including: Extracting five-tuple information from the data packet to be allocated; The five-tuple information is processed using a hash function to obtain a hash value corresponding to the data packet to be distributed.
9. The device according to claim 8, wherein: The calculation module processes the five-tuple information using a hash function to obtain a hash value corresponding to the data packet to be allocated, including: Get the hash function; Combining the five-tuple information into a hash key; The hash key is input into the hash function for calculation to obtain a hash value corresponding to the data packet to be distributed.
10. The device according to claim 8, wherein: The determining module determines the backend server corresponding to the data packet to be allocated according to the load balancing rule and the hash value corresponding to the data packet to be allocated, including: Obtaining a mapping table between the hash value contained in the load balancing rule and the backend server; Obtaining a mapping result according to a hash value corresponding to the data packet to be distributed and a mapping table between the hash value and the backend server; A back-end server corresponding to the data packet to be distributed is determined according to the mapping result.
11. The device according to claim 10, wherein: The determining module determines the back-end server corresponding to the data packet to be allocated according to the mapping result, including: If there is a backend server matching the hash value corresponding to the data packet to be distributed in the mapping table between the hash value and the backend server, the data packet to be distributed is distributed to the matching backend server.
12. The device according to any one of claims 7 to 11, wherein: After determining the back-end server corresponding to the data packet to be allocated, the determining module is further used to: Obtaining status information of the backend server; The load balancing rules are dynamically adjusted according to the status information of the backend server.
13. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.
14. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-6.
15. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 6.
Citation Information
Cited By
Data forwarding method and device of four-layer load balancer, equipment and storage medium
CN119728542A
Data forwarding method, device and equipment of four-layer load balancer and storage medium
CN119728542B
