Intelligent network card-based load balancing method, device, equipment and system
By acquiring the bidirectional handshake signal of the TCP stream on the smart network interface card, extracting the five-tuple information, creating connection tracking records, selecting target nodes, and generating flow table rules, the problem of inconsistent TCP stream distribution is solved, achieving efficient load balancing and hardware forwarding, and avoiding service loss.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN SHENXIN INFORMATION SECURITY CO LTD
- Filing Date
- 2023-06-28
- Publication Date
- 2026-05-29
Smart Images

Figure CN116614443B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of load balancing technology, and in particular to load balancing methods, apparatus, devices and systems based on smart network interface cards (NICs). Background Technology
[0002] Load balancers can address the performance issues of Layer 7 application load balancing through horizontal scaling within a cluster. Existing solutions rely on the switch's ECMP (Equal Cost Multi-path) to distribute traffic to different nodes within the cluster. However, the same flow or related flows (such as ALG (Application Level Gateway)) cannot be distributed to the same device within the cluster. When traffic is distributed to different devices within the cluster, for load balancing services like TCP (Transmission Control Protocol) Layer 7, the lack of protocol state machine consistency among devices within the cluster leads to some packets of the same flow being dropped due to being distributed to different devices, resulting in lossy service. Summary of the Invention
[0003] In view of this, the purpose of this application is to provide a load balancing method, apparatus, device, and system based on smart network interface cards (NICs), which can ensure that packets of the same TCP stream are distributed to the same node within the cluster, avoiding service degradation. The specific solution is as follows:
[0004] In a first aspect, this application discloses a load balancing method based on a smart network interface card (NIC), applied to a central processing unit (CPU), comprising:
[0005] Obtain the bidirectional handshake signal of the TCP stream sent by the smart network card, and extract the quintuple information based on the bidirectional handshake signal;
[0006] Create a connection tracking record for the TCP stream and add the five-tuple information to the connection tracking record;
[0007] The target node is selected from the cluster based on the preset load balancing strategy, and the routing information and neighbor information corresponding to the target node are obtained.
[0008] The routing information and the neighbor information are added to the connection tracking record; the connection tracking record is used to forward the TCP stream to the target node.
[0009] Optionally, after adding the routing information and the neighbor information to the connection tracking record, the method further includes:
[0010] Flow table rules are generated based on the connection tracking records;
[0011] The flow table rules are sent to the smart network interface card (NIC); the flow table rules are used by the smart NIC to forward subsequent packets of the bidirectional handshake signal.
[0012] Optionally, after obtaining the bidirectional handshake signal of the TCP stream sent by the smart network interface card, the following steps are also included:
[0013] When the handshake signal of the TCP stream sent by the smart network card is received, the memory occupied by the connection tracking record is released.
[0014] Optionally, before releasing the memory occupied by the connection tracking record, the method further includes:
[0015] Obtain the index identifier corresponding to the TCP stream sent by the smart network card, and search for the connection tracking record in the connection tracking record table based on the index identifier;
[0016] The connection tracking record table includes connection tracking records corresponding to each TCP stream.
[0017] Optionally, after obtaining the routing information and neighbor information corresponding to the target node, the method further includes:
[0018] Based on the neighbor information, the two-way handshake signal is forwarded to the target node;
[0019] Accordingly, when the handshake signal of the TCP stream sent by the smart network card is received, the method further includes:
[0020] The handshake signal is forwarded to the target node based on the neighbor information.
[0021] Optionally, before obtaining the bidirectional handshake signal of the TCP stream sent by the smart network interface card, the following steps are also included:
[0022] Configure the queuing principles of the smart network interface card;
[0023] The queue principle is used to specify the queue used for TCP stream packet sending and receiving for each optical port. This queue is the queue of the first PF, and PF is the physical function of the network card that conforms to the PCIe specification.
[0024] Optional, also includes:
[0025] The first packet is sent to the second PF; the first packet is a packet for inserting, querying, or deleting flow table rules;
[0026] Obtain the second packet returned by the smart network card through the second PF; the second packet is the result packet of inserting, querying or deleting flow table rules; and the second PF is a different PF on PCIe than the first PF.
[0027] Optionally, sending the first packet to the second PF includes:
[0028] Send the first packet carrying the identification information of the TCP stream to the second PF;
[0029] The method further includes: when a second packet is obtained from the smart network card through the second PF, it is associated with the corresponding TCP stream based on the identification information.
[0030] Optionally, the smart network card includes at least one of FPGA network card, ASIC network card, NPU network card, and SoC network card.
[0031] Secondly, this application discloses a load balancing method based on a smart network interface card (NIC), applied to a smart NIC, comprising:
[0032] Obtain flow table rules issued by the central processing unit; wherein, the flow table rules are flow table rules generated based on connection tracking records, the connection tracking records include routing information of the target node, neighbor information, and five-tuple information extracted from the two-way handshake signal of the TCP stream; the target node is a node selected from the cluster based on a preset load balancing strategy;
[0033] Based on the flow table rules, subsequent packets of the bidirectional handshake signal of the TCP stream are forwarded.
[0034] Thirdly, this application discloses a load balancing device based on a smart network interface card (NIC), applied to a central processing unit (CPU), comprising:
[0035] The handshake signal acquisition module is used to acquire the bidirectional handshake signals of the TCP stream sent by the smart network card;
[0036] The quintuple information extraction module is used to extract quintuple information based on the bidirectional handshake signal;
[0037] A connection tracking record creation module is used to create a connection tracking record for the TCP stream and add the five-tuple information to the connection tracking record;
[0038] The target node selection module is used to select target nodes from the cluster based on a preset load balancing strategy.
[0039] The routing and neighbor information acquisition module is used to acquire the routing information and neighbor information corresponding to the target node;
[0040] The routing and neighbor information adding module is used to add the routing information and neighbor information to the connection tracking record; the connection tracking record is used to forward the TCP stream to the target node.
[0041] Fourthly, this application discloses a load balancing device based on a smart network interface card (NIC), applied to a smart NIC, comprising:
[0042] The flow table rule acquisition module is used to acquire flow table rules issued by the central processing unit; wherein, the flow table rules are flow table rules generated based on connection tracking records, and the connection tracking records include routing information of the target node, neighbor information, and five-tuple information extracted from the two-way handshake signal of the TCP stream; the target node is a node selected from the cluster based on a preset load balancing strategy;
[0043] A TCP stream forwarding module is used to forward subsequent packets of the bidirectional handshake signal of a TCP stream based on the flow table rules. Fifthly, this application discloses an electronic device, including a central memory and a processor, wherein:
[0044] The memory is used to store computer programs;
[0045] The central processing unit is used to execute the computer program to implement the aforementioned load balancing method based on a smart network interface card applied to the central processing unit.
[0046] Sixthly, this application discloses a smart network interface card (NIC) for implementing the aforementioned load balancing method based on the smart NIC.
[0047] In a seventh aspect, this application discloses a load balancing system, including one or more central processing units and one or more smart network interface cards;
[0048] The central processing unit is used to implement the aforementioned load balancing method based on a smart network interface card (NIC) applied to the central processing unit, and the smart NIC is used to implement the aforementioned load balancing method based on a smart NIC applied to the smart NIC.
[0049] Eighthly, this application discloses a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the aforementioned load balancing method based on a smart network interface card applied to a central processing unit.
[0050] Ninthly, this application discloses a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements a load balancing method applied to a smart network interface card (NIC).
[0051] As can be seen, this application first obtains the bidirectional handshake signal of the TCP stream sent by the smart network interface card (NIC), extracts the five-tuple information based on the bidirectional handshake signal, then creates a connection tracking record for the TCP stream, adds the five-tuple information to the connection tracking record, selects a target node from the cluster based on a preset load balancing strategy, and obtains the routing information and neighbor information corresponding to the target node. Then, the routing information and neighbor information are added to the connection tracking record, which is used to forward the TCP stream to the target node. In this way, the central processing unit obtains the bidirectional handshake signal sent by the smart NIC, creates the connection tracking record, and performs load balancing. Since the connection tracking record contains the five-tuple information, routing information, and neighbor information, using this connection tracking record to forward the TCP stream to the target node ensures that packets of the same TCP stream are distributed to the same node within the cluster, avoiding service degradation. Attached Figure Description
[0052] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0053] Figure 1 This is a flowchart of a load balancing method based on a smart network interface card (NIC) disclosed in an embodiment of this application;
[0054] Figure 2 This is a schematic diagram illustrating the generation of a connection tracking record table as disclosed in an embodiment of this application;
[0055] Figure 3 This is a schematic diagram illustrating a specific interaction between an FPGA and a CPU as disclosed in an embodiment of this application.
[0056] Figure 4 This is a specific PCIe load balancing diagram disclosed in an embodiment of this application;
[0057] Figure 5 This is a flowchart of another load balancing method based on a smart network interface card disclosed in an embodiment of this application;
[0058] Figure 6 This is a schematic diagram of a load balancing device based on a smart network interface card disclosed in an embodiment of this application;
[0059] Figure 7 This is a schematic diagram of another load balancing device based on a smart network interface card disclosed in an embodiment of this application;
[0060] Figure 8This is a schematic diagram of an electronic device disclosed in an embodiment of this application;
[0061] Figure 9 This is a structural diagram of a smart network interface card (NIC) disclosed in an embodiment of this application;
[0062] Figure 10 This is a schematic diagram of a load balancing system structure disclosed in an embodiment of this application. Detailed Implementation
[0063] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0064] See Figure 1 As shown in the figure, this application discloses a load balancing method based on a smart network interface card (NIC), applied to a central processing unit (CPU), including:
[0065] Step S11: Obtain the bidirectional handshake signal of the TCP stream sent by the smart network card, and extract the quintuple information based on the bidirectional handshake signal.
[0066] The smart network interface card (NIC) includes an FPGA (Field Programmable Gate Array) NIC. This embodiment of the application acquires the bidirectional handshake signal transmitted by the FPGA via PCIe (Peripheral Component Interconnect Express, a high-speed serial computer expansion bus standard). It can be understood that bidirectional 5-tuple information can be extracted based on the bidirectional handshake signal. The 5-tuple information refers to five key pieces of information used to identify and recognize data flows during data transmission in network communication, including the source IP address, destination IP address, source port number, destination port number, and transport protocol. These information, when combined, can identify each network data flow, thereby helping network devices and applications to correctly route and process data on the network.
[0067] Furthermore, smart network interface cards (NICs) can also include ASIC (Application-Specific Integrated Circuit) NICs, NPU (Network Processing Unit) NICs, and SoC (System-on-Chip) NICs. ASICs are typically customized integrated circuits for specific application areas or customers according to specific application requirements and design specifications. An NPU is a high-performance chip specifically designed for network data traffic processing and forwarding. An SoC is an integrated circuit that integrates multiple functional modules such as processor, memory, and input / output on a single chip.
[0068] Step S12: Create a connection tracking record for the TCP stream and add the 5-tuple information to the connection tracking record.
[0069] In a specific implementation, a unique connection tracking record can be created for each TCP stream, and the connection tracking records constitute a connection tracking record table.
[0070] Step S13: Select a target node from the cluster based on a preset load balancing strategy, and obtain the routing information and neighbor information corresponding to the target node.
[0071] A load balancing strategy is an algorithm used to distribute network traffic to target nodes (or servers) during the load balancing process. Load balancing strategies typically select the optimal distribution scheme based on various factors, such as server load status, traffic type, and network latency. This application does not limit the specific load balancing algorithm. Routing information includes the next-hop IP address and outgoing interface; neighbor information includes the MAC address of the next-hop IP.
[0072] In a specific implementation, the two-way handshake signal can be forwarded to the target node based on the neighbor information.
[0073] Step S14: Add the routing information and the neighbor information to the connection tracking record.
[0074] For example, see Figure 2 As shown, Figure 2This is a schematic diagram illustrating the generation of a connection tracking record table as disclosed in an embodiment of this application. For SYN (Synchronize Sequence Numbers) packets in both directions of the TCP flow, the FPGA sends them to the CPU via PCIe. The CPU extracts the 5-tuple information as a connection tracking record. Then, the CPU selects a node in the cluster as the target node according to the load balancing strategy, looks up the route, obtains the neighbors, and forwards the SYN packet to the target node. At the same time, the routing information and neighbor information are cached in the connection tracking record. Thus, the bidirectional data path is established. Because the connection tracking record contains the original bidirectional information of the flow (i.e., bidirectional 5-tuple information) and forwarding information (i.e., routing information), PCC (i.e., maintaining connection consistency and load balancing to the same node) consistency can be ensured.
[0075] As can be seen, this embodiment first obtains the bidirectional handshake signal of the TCP stream sent by the smart network interface card (NIC), extracts the five-tuple information based on the bidirectional handshake signal, then creates a connection tracking record for the TCP stream, adds the five-tuple information to the connection tracking record, selects a target node from the cluster based on a preset load balancing strategy, and obtains the routing information and neighbor information corresponding to the target node, then adds the routing information and neighbor information to the connection tracking record. In this way, the central processing unit obtains the bidirectional handshake signal sent by the smart NIC, creates the connection tracking record, and performs load balancing. Because the connection tracking record contains the five-tuple information, routing information, and neighbor information, it can ensure that packets of the same TCP stream are distributed to the same node in the cluster, avoiding service degradation.
[0076] Furthermore, in this embodiment, flow table rules can be generated based on the connection tracking records. These flow table rules are then distributed to the smart network interface card (NIC). The flow table rules are used by the smart NIC to forward subsequent packets of the bidirectional handshake signal; that is, the smart NIC directly forwards subsequent packets of the bidirectional handshake signal based on the flow table rules, without uploading them to the CPU. Specifically, the bidirectional 5-tuple information and neighbor information are converted into two general match-action flow table rules and distributed to the FPGA. Thus, subsequent packets of a flow do not need to be sent to the CPU; they can be directly forwarded within the FPGA according to the flow table, i.e., hardware offloading is performed. In this way, for each TCP flow, this embodiment supports hardware offloading while maintaining connection tracking PCC consistency. This improves flow forwarding performance while avoiding service degradation.
[0077] In other words, this application embodiment replaces the existing switch with the aforementioned smart network interface card. By sending the SYN packet of a flow to the CPU software, the CPU software is responsible for supporting load balancing with connection tracking and session persistence. As for the forwarding part, based on the high performance provided by the chip, high-performance packet forwarding of subsequent packets of a flow is achieved through hardware offloading.
[0078] Furthermore, in this embodiment, upon receiving the handshake signal for the TCP stream sent by the smart network interface card (NIC), the memory occupied by the connection tracking record is released. Before releasing the memory occupied by the connection tracking record, this embodiment can obtain the index identifier corresponding to the TCP stream sent by the smart NIC, and search for the connection tracking record in the connection tracking record table based on the index identifier; wherein the connection tracking record table includes each connection tracking record corresponding to each TCP stream. The index identifier can be the SESSION ID corresponding to the TCP stream, and the index identifier can be carried when sending the handshake signal.
[0079] It is understood that in this embodiment, the FPGA sends the handshake signal FIN / RST to the CPU, which facilitates the lifecycle management of the connection tracking record. When a flow ends, the memory used for the connection tracking record is reclaimed. FIN / RST consists of several packets at the end of a flow (3-4 packets when not retransmitted), and the connection tracking table can be directly indexed by the session ID carried in the packets sent by the FPGA, eliminating the need for the CPU to calculate a hash for indexing, thus improving indexing speed.
[0080] Furthermore, in this embodiment, the handshake signal can also be forwarded to the target node based on the neighbor information. That is, subsequent packets offloaded to the smart network interface card do not contain the handshake signal.
[0081] Furthermore, embodiments of this application can also configure the queuing principle of the smart network card. The queuing principle is used by the smart network card to load balance TCP stream transmission and reception packets across multiple PCIe groups. That is, the smart network card can load balance TCP stream transmission and reception packets across multiple PCIe groups based on the queuing principle. Specifically, the queuing principle is used to specify the queue used for TCP stream transmission and reception packets corresponding to each optical port. This queue is the queue of the first PF (Physical Function), where PF is a network card physical function conforming to the PCIe specification. Specifically, the queuing principle is used to specify the PCIe used for the corresponding TCP stream transmission and reception packets, the PF used on that PCIe, and the queue used by that PF.
[0082] Furthermore, in this embodiment, the first packet can be sent to the second PF; the first packet is a packet for inserting, querying, or deleting flow table rules; the second packet returned by the smart network card through the second PF is obtained; the second packet is a result packet for inserting, querying, or deleting flow table rules; and the second PF and the first PF are different PFs on the PCIe network. That is, this embodiment performs load balancing for TCP flow and flow table rule-related packets. For example, each PCIe network has four PFs, two of which are used for sending and receiving TCP flows, and the other two are used for sending and receiving flow table rule-related packets.
[0083] In one implementation, a first packet carrying TCP stream identification information can be sent to a second PF, so that the smart network interface card (NIC) adds the identification information to the second packet. Correspondingly, when a second packet returned by the smart NIC through the second PF is received, the corresponding TCP stream is associated with the identification information. The identification information can be a session ID. That is, this embodiment can asynchronously obtain the results of inserted, queried, or deleted events, carrying the session ID of the stream during sending and returning the ID when returning the event result. The CPU associates with the stream through this ID, thereby obtaining the event result of the stream, decoupling the FPGA and CPU in time.
[0084] In addition, the FPGA uses multiple high-speed DDR (Double Data Rat) parallel to process messages related to flow table rules issued by the CPU, and the DDR uses a single-level hash. This allows for lock-free operation and prevents the overhead caused by DDR bandwidth contention.
[0085] Furthermore, in one implementation, both the smart network card and the aforementioned CPU are mounted on a preset server, and the preset server operates in TCP layer 4 mode, while each load server in the cluster operates in TCP layer 7 mode.
[0086] For example, see Figure 3 As shown, Figure 3 This is a specific FPGA and CPU interaction diagram disclosed in an embodiment of this application. When a TCP stream enters the FPGA, the packet is parsed and the flow table is checked. If the flow table is matched, it is checked whether it is a FIN / RST / SYN packet. If it is a FIN / RST / SYN packet, it is sent to the CPU. If it is not a FIN / RST / SYN packet, it is encapsulated and forwarded directly via a fast path. If the flow table is not matched, the packet is sent to the CPU for forwarding. In addition, the CPU sends packets to the FPGA to insert / query / delete flow table rules, so that the FPGA can perform corresponding insertion / query / deletion operations on the flow table. Furthermore, the CPU maintains a connection tracking record table locally.
[0087] For example, see Figure 4 As shown, Figure 4 This is a schematic diagram of a specific PCIe load balancing embodiment disclosed in this application. This embodiment can perform PCIe load balancing through hardware and software collaboration, solving the single point of failure problem in PCIe transmission. The SS.MR.AD400 card is a smart network card. Taking two groups of PCIe as an example, namely PCIe0 and PCIe1, PCIe0 / PCIe1 in the diagram is a group of x8; in other embodiments, it can also be a group of x16. Each group of PCIe has 4 PFs, namely PF0, PF1, PF2, and PF3. Each PF has 512 queues. For example, Q0 to Q511 of PF0 in PCIe0 represent queues 0 to 511. The smart network card includes 4 optical ports, namely optical port 0, optical port 1, optical port 2, and optical port 3. Service processing module 0 and service processing module 1 are modules in FAGA that execute corresponding service processing logic. DPDK ports 0 to 3 are DPDK ports for data packets, and DPDK ports 4 to 7 are DPDK ports for rule management. DPDK: a software library for high-performance packet processing acceleration. QDMA: Commercial DMA IP, a packet sending and receiving engine. PCIe load balancing for service packets (i.e., TCP streams) is as follows: Packets received by the optical port are evenly distributed to two PCIe groups according to the initial configured queue principle. Taking optical port 0 / 1 as an example, the packets received are evenly distributed to PF0 on PCIe0 or PF0 on PCIe1. When the CPU reads the first half of the queue of PF0 on PCIe0, it receives packets from optical port 0, and the second half from optical port 1. Similarly, when the CPU reads the first half of the queue of PF0 on PCIe1, it receives packets from optical port 0, and the second half from optical port 1. Packet transmission also follows PCIe load balancing. To avoid single-point bottlenecks, taking optical port 0 as an example, packets can be sent using both the first half of the queue of PF0 on PCIe0 and the first half of the queue of PF0 on PCIe1. Similarly, taking optical port 1 as an example, packets can be sent using both the second half of the queue of PF0 on PCIe0 and the second half of the queue of PF0 on PCIe1. PCIe load balancing for flow table rule messages: In each group of PCIes, 2 PFs are used for sending and receiving service messages, and the other 2 PFs are used for sending flow tables and the return status of the sent flow tables. Rules can be sent through either PCIe0 or PCIe1.
[0088] Furthermore, it should be noted that programmable switches typically have 50-100MB of storage, while each entry is 128B (IPv6). A 10M concurrent flow requires 1280MB, meaning the storage capacity for each entry is small. Moreover, their flow table entry insertion speed is only 10-100k / s, making it unable to dynamically adapt to millions of new entries. In contrast, FPGAs, equipped with gigabyte high-bandwidth memory, can store a large number of concurrent flows. The hardware platform in this embodiment supports over 130M flow table entries. For high entry insertion speeds, this solution utilizes the following techniques to achieve an insertion rate of 4.4M+ / s, resulting in outstanding flow table delivery performance capable of handling millions of new entries (CPS): Flow table rule delivery still uses the DPDK-QDMA sending interface; the FPGA distinguishes between service packets and flow table rules based on the queue number. The results of insert / query / delete events returned by the FPGA are returned in packet form and still use the DPDK-QDMA receiving interface. By using different queues for delivery, it naturally supports lock-free delivery. The DDR uses a single-level hash instead of a multi-level hash. The FPGA uses four high-speed DDR groups for parallel insertion / lookup / deletion events instead of a single serial DDR group. Serial queuing of requests on the same DDR channel avoids both lock-free processing and the overhead caused by DDR bandwidth contention; different DDR channels are processed in parallel by the FPGA. An asynchronous approach is used to obtain the results of the inserted / query / delete events. Specifically, the session ID of the stream is carried when the event is sent, and the ID is returned intact when the event result is returned. The CPU uses this ID to associate with the stream and obtain the event result for that stream, thus decoupling the FPGA and CPU in time. This enables a single-card throughput of 400Gbps and a flow table sending speed of 4.4M+ / s. When multiple FPGA smart network cards are stacked, a throughput of Tbps can be achieved, effectively solving the service loss problem caused by the switch's ECMP traffic offloading not supporting connection tracking and session persistence during cluster expansion.
[0089] Further, see Figure 5 As shown, Figure 5 This application discloses a load balancing method based on a smart network interface card (NIC), applied to a smart NIC, comprising:
[0090] Step S21: Obtain the flow table rules issued by the central processing unit; wherein, the flow table rules are flow table rules generated based on connection tracking records, the connection tracking records include the routing information of the target node, neighbor information, and five-tuple information extracted from the two-way handshake signal of the TCP flow; the target node is a node selected from the cluster based on a preset load balancing strategy;
[0091] Step S22: Forward subsequent packets of the bidirectional handshake signal of the TCP stream based on the flow table rules.
[0092] As can be seen, this embodiment first obtains the flow table rules issued by the central processing unit. These flow table rules are generated based on connection tracking records. The connection tracking records include routing information of the target node, neighbor information, and five-tuple information extracted from the bidirectional handshake signal of the TCP flow. The target node is a node selected from the cluster based on a preset load balancing strategy. Then, based on the flow table rules, subsequent packets of the bidirectional handshake signal of the TCP flow are forwarded. Thus, for each TCP flow, this embodiment supports hardware offloading while maintaining connection tracking PCC consistency. This improves flow forwarding performance while avoiding service degradation.
[0093] See Figure 6 As shown, this application discloses a load balancing device applied to a central processing unit, comprising:
[0094] The handshake signal acquisition module 11 is used to acquire the bidirectional handshake signal of the TCP stream sent by the smart network card;
[0095] The quintuple information extraction module 12 is used to extract quintuple information based on the bidirectional handshake signal;
[0096] The connection tracking record creation module 13 is used to create a connection tracking record for the TCP stream and add the five-tuple information to the connection tracking record;
[0097] The target node selection module 14 is used to select target nodes from the cluster based on a preset load balancing strategy;
[0098] The routing and neighbor information acquisition module 15 is used to acquire the routing information and neighbor information corresponding to the target node;
[0099] The routing and neighbor information adding module 16 is used to add the routing information and neighbor information to the connection tracking record; the connection tracking record is used to forward the TCP stream to the target node.
[0100] As can be seen, this embodiment first obtains the bidirectional handshake signal of the TCP stream sent by the smart network interface card (NIC), extracts the five-tuple information based on the bidirectional handshake signal, then creates a connection tracking record for the TCP stream, adds the five-tuple information to the connection tracking record, selects a target node from the cluster based on a preset load balancing strategy, and obtains the routing information and neighbor information corresponding to the target node. Then, the routing information and neighbor information are added to the connection tracking record. This connection tracking record is used to forward the TCP stream to the target node. In this way, the central processing unit obtains the bidirectional handshake signal sent by the smart NIC, creates the connection tracking record, and performs load balancing. Since the connection tracking record contains the five-tuple information, routing information, and neighbor information, using this connection tracking record to forward the TCP stream to the target node ensures that packets of the same TCP stream are distributed to the same node within the cluster, avoiding service degradation.
[0101] Furthermore, the device also includes:
[0102] The flow table rule generation module is used to generate flow table rules based on the connection tracking records.
[0103] The flow table rule distribution module distributes the flow table rules to the smart network interface card (NIC); the flow table rules are used by the smart NIC to forward subsequent packets of the bidirectional handshake signal. The handshake signal acquisition module acquires the handshake signal of the TCP flow sent by the smart NIC.
[0104] The memory release module is used to release the memory occupied by the connection tracking record when the handshake signal acquisition module obtains the handshake signal of the TCP stream sent by the smart network card.
[0105] An index identifier acquisition module is used to acquire the index identifier corresponding to the TCP stream sent by the smart network card before the memory release module releases the memory occupied by the connection tracking record. Correspondingly, the device also includes a connection tracking record lookup module, used to look up the connection tracking record from the connection tracking record table based on the index identifier; wherein, the connection tracking record table includes each connection tracking record corresponding to each TCP stream.
[0106] Furthermore, the device includes:
[0107] A two-way handshake signal forwarding module is used to forward the two-way handshake signal to the target node based on the neighbor information;
[0108] The handshake signal forwarding module is used to forward the handshake signal to the target node based on the neighbor information.
[0109] Furthermore, the device also includes:
[0110] The queue principle configuration module is used to configure the queue principle of the smart network card; wherein, the queue principle is used to specify the queue used for TCP stream packet sending and receiving for each optical port, and the queue is the queue of the first PF; PF is the physical function of the network card that conforms to the PCIE specification.
[0111] Furthermore, it also includes:
[0112] The first packet delivery module is used to deliver the first packet to the second PF; the first packet is a packet for inserting, querying, or deleting flow table rules;
[0113] The second packet acquisition module is used to acquire the second packet returned by the smart network card through the second PF; the second packet is the result packet of inserting, querying or deleting flow table rules; and the second PF is a different PF on PCIe from the first PF.
[0114] The first packet sending module is specifically used to: send a first packet carrying the identification information of the TCP stream to the second PF;
[0115] Correspondingly, the second packet acquisition module is also used to associate the second packet returned by the smart network card through the second PF with the corresponding TCP stream based on the identification information when the second packet is acquired.
[0116] The smart network card includes at least one of FPGA network card, ASIC network card, NPU network card, and SoC network card.
[0117] See Figure 7 As shown in the figure, this application discloses another load balancing device based on a smart network interface card (NIC), applied to a smart NIC, including:
[0118] The flow table rule acquisition module 21 is used to acquire flow table rules issued by the central processing unit; wherein, the flow table rules are flow table rules generated based on connection tracking records, and the connection tracking records include routing information of the target node, neighbor information, and five-tuple information extracted from the two-way handshake signal of the TCP flow; the target node is a node selected from the cluster based on a preset load balancing strategy;
[0119] TCP stream forwarding module 22 is used to forward subsequent packets of the bidirectional handshake signal of the TCP stream based on the flow table rules.
[0120] As can be seen, this embodiment first obtains the flow table rules issued by the central processing unit. These flow table rules are generated based on connection tracking records. The connection tracking records include routing information of the target node, neighbor information, and five-tuple information extracted from the bidirectional handshake signal of the TCP flow. The target node is a node selected from the cluster based on a preset load balancing strategy. Then, based on the flow table rules, subsequent packets of the bidirectional handshake signal of the TCP flow are forwarded. Thus, for each TCP flow, this embodiment supports hardware offloading while maintaining connection tracking PCC consistency. This improves flow forwarding performance while avoiding service degradation.
[0121] See Figure 8 As shown in the illustration, this application discloses an electronic device 30, including a central processing unit 31 and a memory 32; wherein, the memory 32 is used to store computer programs; the central processing unit 31 is a central processing unit used to execute the computer programs to achieve the following steps:
[0122] The system acquires the bidirectional handshake signal of the TCP stream sent by the smart network interface card (NIC) and extracts the 5-tuple information based on the bidirectional handshake signal; it creates a connection tracking record for the TCP stream and adds the 5-tuple information to the connection tracking record; it selects a target node from the cluster based on a preset load balancing strategy and acquires the routing information and neighbor information corresponding to the target node; it adds the routing information and neighbor information to the connection tracking record; the connection tracking record is used to forward the TCP stream to the target node.
[0123] As can be seen, this embodiment first obtains the bidirectional handshake signal of the TCP stream sent by the smart network interface card (NIC), extracts the five-tuple information based on the bidirectional handshake signal, then creates a connection tracking record for the TCP stream, adds the five-tuple information to the connection tracking record, selects a target node from the cluster based on a preset load balancing strategy, and obtains the routing information and neighbor information corresponding to the target node. Then, the routing information and neighbor information are added to the connection tracking record. This connection tracking record is used to forward the TCP stream to the target node. In this way, the central processing unit obtains the bidirectional handshake signal sent by the smart NIC, creates the connection tracking record, and performs load balancing. Since the connection tracking record contains the five-tuple information, routing information, and neighbor information, using this connection tracking record to forward the TCP stream to the target node ensures that packets of the same TCP stream are distributed to the same node within the cluster, avoiding service degradation.
[0124] In this embodiment, when the central processing unit 31 executes the computer subroutine stored in the memory 32, it can specifically implement the following steps: after adding the routing information and the neighbor information to the connection tracking record, it generates flow table rules based on the connection tracking record; it sends the flow table rules to the smart network card; the flow table rules are used by the smart network card to forward subsequent packets of the bidirectional handshake signal.
[0125] In this embodiment, when the central processing unit 31 executes the computer subroutine stored in the memory 32, it can specifically implement the following steps: after obtaining the bidirectional handshake signal of the TCP stream sent by the smart network card, when obtaining the handshake signal of the TCP stream sent by the smart network card, the memory occupied by the connection tracking record is released.
[0126] In this embodiment, when the central processing unit 31 executes the computer subroutine stored in the memory 32, it can specifically implement the following steps: before releasing the memory occupied by the connection tracking record, it obtains the index identifier corresponding to the TCP stream sent by the smart network card, and searches for the connection tracking record in the connection tracking record table based on the index identifier; wherein, the connection tracking record table includes each connection tracking record corresponding to each TCP stream.
[0127] In this embodiment, when the central processing unit 31 executes the computer subroutine stored in the memory 32, it can specifically implement the following steps: after obtaining the routing information and neighbor information corresponding to the target node, it further includes: forwarding the bidirectional handshake signal to the target node based on the neighbor information;
[0128] In this embodiment, when the central processing unit 31 executes the computer subroutine stored in the memory 32, it can specifically implement the following steps: when the handshake signal of the TCP stream sent by the smart network card is obtained, the handshake signal is forwarded to the target node based on the neighbor information.
[0129] In this embodiment, when the central processing unit 31 executes the computer subroutine stored in the memory 32, it can specifically implement the following steps: before obtaining the bidirectional handshake signal of the TCP stream sent by the smart network card, configure the queuing principle of the smart network card; wherein, the queuing principle is used to specify the queue used by the TCP stream sending and receiving packets corresponding to each optical port, and the queue is the queue of the first PF, where PF is the physical function of the network card that conforms to the PCIE specification.
[0130] In this embodiment, when the central processing unit 31 executes the computer subroutine stored in the memory 32, it can specifically implement the following steps: sending a first packet to the second PF; the first packet is a packet for inserting, querying, or deleting flow table rules; obtaining the second packet returned by the smart network card through the second PF; the second packet is a result packet for inserting, querying, or deleting flow table rules; and the second PF and the first PF are different PFs on PCIe.
[0131] In this embodiment, when the central processing unit 31 executes the computer subroutine stored in the memory 32, it can specifically implement the following steps: sending the first packet to the second PF includes: sending the first packet carrying the identification information of the TCP stream to the second PF; when the second packet returned by the smart network card through the second PF is obtained, the corresponding TCP stream is associated based on the identification information.
[0132] In this embodiment, the smart network interface card (NIC) includes at least one of FPGA NIC, ASIC NIC, NPU NIC, and SoC NIC. Furthermore, the memory 32, as a resource storage carrier, can be a read-only memory, random access memory, disk, or optical disk, and the storage method can be temporary or permanent storage.
[0133] In addition, the electronic device 30 also includes a power supply 33, a communication interface 34, an input / output interface 35, and a communication bus 36; wherein, the power supply 33 is used to provide operating voltage for the various hardware devices on the electronic device 30; the communication interface 34 can create a data transmission channel between the electronic device 30 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 35 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0134] Additionally, see Figure 9 As shown in the figure, this application discloses a smart network card, which includes an FPGA, four QSFP28 optical interface channels (100G per channel), four DDR channels (72-bit (64-bit + 8-bit ECC) per channel, and two PCIe Gen3 x8 channels for connecting to the CPU.
[0135] The smart network interface card is used to implement the following steps:
[0136] The process involves obtaining flow table rules issued by the central processing unit (CPU). These flow table rules are generated based on connection tracking records, which include routing information of the target node, neighbor information, and 5-tuple information extracted from the bidirectional handshake signal of the TCP flow. The target node is selected from the cluster based on a preset load balancing strategy. Subsequent packets of the bidirectional handshake signal of the TCP flow are then forwarded based on the flow table rules. In this embodiment, for each TCP flow, the process first obtains the flow table rules issued by the CPU. These rules are generated based on connection tracking records, which include routing information of the target node, neighbor information, and 5-tuple information extracted from the bidirectional handshake signal of the TCP flow. The target node is selected from the cluster based on a preset load balancing strategy. Then, subsequent packets of the bidirectional handshake signal of the TCP flow are forwarded based on the flow table rules. Thus, for each TCP flow, this embodiment supports hardware offloading while maintaining connection tracking PCC consistency. This improves flow forwarding performance while avoiding service degradation.
[0137] See Figure 10 As shown in the figure, this application discloses a load balancing system, including one or more central processing units and one or more smart network interface cards;
[0138] The central processing unit is used to implement the following steps: acquiring the bidirectional handshake signal of the TCP stream sent by the smart network card, and extracting the five-tuple information based on the bidirectional handshake signal; creating a connection tracking record for the TCP stream, and adding the five-tuple information to the connection tracking record; selecting a target node from the cluster based on a preset load balancing strategy, and acquiring the routing information and neighbor information corresponding to the target node; adding the routing information and the neighbor information to the connection tracking record; the connection tracking record is used to forward the TCP stream to the target node.
[0139] The smart network interface card (NIC) performs the following steps: obtaining flow table rules issued by the central processing unit (CPU); wherein the flow table rules are flow table rules generated based on connection tracking records, and the connection tracking records include routing information of the target node, neighbor information, and five-tuple information extracted from the bidirectional handshake signal of the TCP flow; the target node is a node selected from the cluster based on a preset load balancing strategy; and forwarding subsequent packets of the bidirectional handshake signal of the TCP flow based on the flow table rules.
[0140] Furthermore, embodiments of this application also disclose a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the load balancing method based on a smart network interface card (NIC) applied to a central processing unit disclosed in the foregoing embodiments.
[0141] The specific process of the above-mentioned load balancing method based on smart network interface cards applied to the central processing unit can be found in the relevant content disclosed in the foregoing embodiments, and will not be repeated here.
[0142] Furthermore, embodiments of this application also disclose a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the smart network card-based load balancing method disclosed in the foregoing embodiments.
[0143] The specific process of the smart network card-based load balancing method described above can be found in the relevant content disclosed in the foregoing embodiments, and will not be repeated here.
[0144] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0145] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0146] The above provides a detailed description of the load balancing method, apparatus, device, and system based on smart network interface cards (NICs) provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A load balancing method based on a smart network interface card (NIC), characterized in that, Applied to central processing units, including: Obtain the bidirectional handshake signal of the TCP stream sent by the smart network card, and extract the quintuple information based on the bidirectional handshake signal; Create a connection tracking record for the TCP stream and add the five-tuple information to the connection tracking record; wherein each TCP stream has a unique corresponding connection tracking record; The target node is selected from the cluster based on the preset load balancing strategy, and the routing information and neighbor information corresponding to the target node are obtained. The routing information and the neighbor information are added to the connection tracking record; the connection tracking record is used to forward the TCP stream to the target node.
2. The load balancing method based on a smart network interface card according to claim 1, characterized in that, After adding the routing information and the neighbor information to the connection tracking record, the method further includes: Flow table rules are generated based on the connection tracking records; The flow table rules are sent to the smart network interface card (NIC); the flow table rules are used by the smart NIC to forward subsequent packets of the bidirectional handshake signal.
3. The load balancing method based on a smart network interface card according to claim 1, characterized in that, After receiving the two-way handshake signal of the TCP stream sent by the smart network interface card, the process also includes: When the handshake signal of the TCP stream sent by the smart network card is received, the memory occupied by the connection tracking record is released.
4. The load balancing method based on a smart network interface card according to claim 3, characterized in that, Before releasing the memory occupied by the connection tracking record, the method further includes: Obtain the index identifier corresponding to the TCP stream sent by the smart network card, and search for the connection tracking record in the connection tracking record table based on the index identifier; The connection tracking record table includes connection tracking records corresponding to each TCP stream.
5. The load balancing method based on a smart network interface card according to claim 3, characterized in that, After obtaining the routing information and neighbor information corresponding to the target node, the process further includes: Based on the neighbor information, the two-way handshake signal is forwarded to the target node; Accordingly, when the handshake signal of the TCP stream sent by the smart network card is received, the method further includes: The handshake signal is forwarded to the target node based on the neighbor information.
6. The load balancing method based on a smart network interface card according to any one of claims 1 to 5, characterized in that, Before receiving the two-way handshake signal for the TCP stream sent by the smart network interface card, the process also includes: Configure the queuing principles of the smart network interface card; The queue principle is used to specify the queue used for TCP stream packet sending and receiving for each optical port. This queue is the queue of the first PF, and PF is the physical function of the network card that conforms to the PCIe specification.
7. The load balancing method based on a smart network interface card according to claim 6, characterized in that, Also includes: The first packet is sent to the second PF; the first packet is a packet for inserting, querying, or deleting flow table rules; The second packet returned by the smart network card through the second PF is obtained; the second packet is the result packet of inserting, querying or deleting flow table rules; and the second PF and the first PF are different physical functions on PCIe.
8. The load balancing method based on a smart network interface card according to claim 7, characterized in that, Sending the first packet to the second PF includes: Send the first packet carrying the identification information of the TCP stream to the second PF; The method further includes: When the smart network card receives the second packet returned by the second PF, it is associated with the corresponding TCP stream based on the identification information.
9. The load balancing method based on a smart network interface card according to any one of claims 1 to 5, characterized in that, The smart network card includes at least one of FPGA network card, ASIC network card, NPU network card, and SoC network card.
10. A load balancing method based on a smart network interface card (NIC), characterized in that, Applications in smart network interface cards (NICs) include: Obtain flow table rules issued by the central processing unit; wherein, the flow table rules are flow table rules generated based on connection tracking records, and the connection tracking records include routing information of the target node, neighbor information, and five-tuple information extracted from the two-way handshake signal of the TCP flow; the target node is a node selected from the cluster based on a preset load balancing strategy; wherein, each TCP flow has a unique corresponding connection tracking record; Based on the flow table rules, subsequent packets of the bidirectional handshake signal of the TCP stream are forwarded.
11. A load balancing device based on a smart network interface card (NIC), characterized in that, Applied to central processing units, including: The handshake signal acquisition module is used to acquire the bidirectional handshake signals of the TCP stream sent by the smart network card; The quintuple information extraction module is used to extract quintuple information based on the bidirectional handshake signal; A connection tracking record creation module is used to create connection tracking records for the TCP streams and add the five-tuple information to the connection tracking records; wherein, each TCP stream has a unique corresponding connection tracking record; The target node selection module is used to select target nodes from the cluster based on a preset load balancing strategy. The routing and neighbor information acquisition module is used to acquire the routing information and neighbor information corresponding to the target node; The routing and neighbor information adding module is used to add the routing information and neighbor information to the connection tracking record; the connection tracking record is used to forward the TCP stream to the target node.
12. A load balancing device based on a smart network interface card (NIC), characterized in that, Applications in smart network interface cards (NICs) include: The flow table rule acquisition module is used to acquire flow table rules issued by the central processing unit; wherein, the flow table rules are flow table rules generated based on connection tracking records, and the connection tracking records include routing information of the target node, neighbor information, and five-tuple information extracted from the two-way handshake signal of the TCP flow; the target node is a node selected from the cluster based on a preset load balancing strategy; wherein, each TCP flow has a unique corresponding connection tracking record; The TCP stream forwarding module is used to forward subsequent packets of the bidirectional handshake signal of the TCP stream based on the flow table rules.
13. An electronic device, characterized in that, Includes memory and a central processing unit, wherein: The memory is used to store computer programs; The central processing unit is used to execute the computer program to implement the load balancing method based on a smart network interface card as described in any one of claims 1 to 9.
14. A smart network interface card (NIC), characterized in that, The smart network interface card (NIC) is used to implement the load balancing method based on the smart NIC as described in claim 10.
15. A load balancing system, characterized in that, Includes one or more central processing units and one or more smart network interface cards; The central processing unit is used to implement the load balancing method based on a smart network interface card as described in any one of claims 1 to 9, and the smart network interface card is used to implement the load balancing method based on a smart network interface card as described in claim 10.