A load balancing method and system for a software switch
Patent Information
- Application Number
- CN202610766099.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-29
- Publication Date
- 2026-08-18
AI Technical Summary
[0005]为了解决现有技术中不能精准量化拥塞队列内部载荷分布,易产生额外负担,导致负载平衡不能有效控制的技术问题,本发明的目的在于提供一种软件交换机的负载均衡方法及系统,所采用的技术方案具体如下:
本发明通过对超载队列异步采样提取网络层五元组与传输协议类型,识别并剥离出拥塞队列中混杂保序敏感的特征分类数据流,在不干扰底层真实排队顺序的前提下,对积压流量成分的无损解析。进而分析不同特征分类数据流之间的载荷分布不均度,将长连接保序需求转化为可量化的集中度高低状态,进而将跨核并行的吞吐增益与报文乱序重传的惩罚代价统合为单一的收益评估值,基于该评估值的正负状态,系统在海量短报文堆积时执行跨核交织分发以快速消耗积压,而在单一长连接高度集中时执行单核算力隔离以确立排他性算力。本发明引入载荷分布不均度量化保序流量的集中程度,综合分析并行增益与重传惩罚的价值评估,实现多核资源的合理分配,稳定保障长连接业务传输质量,适配物联网边缘网关海量异构终端接入的负载平衡。
Smart Images

Figure CN122601577A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of load balancing technology, and specifically to a load balancing method and system for a software switch. Background Technology
[0002] In scenarios with massive concurrent access from heterogeneous terminals, IoT edge gateways commonly employ a multi-core processor architecture for network protocol parsing and data forwarding. The underlying network interface card (NIC) typically uses a receive-side scaling (RSS) mechanism, which calculates the hash value of the network layer 5-tuple of data packets to statically distribute network traffic to different hardware receive queues, which are then processed by the corresponding processor cores.
[0003] In scenarios with massive concurrent access from heterogeneous terminals, numerous IoT terminals such as temperature and humidity sensors frequently send stateless short-byte messages to the same service port of the gateway. This high degree of consistency between the destination address and the service port can easily lead to hash collisions. A large number of heterogeneous data packets will flood into the same receive queue, causing severe queuing backlog on a single processor core.
[0004] When typical network load balancing mechanisms detect congestion in a single queue, they often employ a forced cross-core round-robin strategy, interleaving and distributing subsequent packets from that queue to other idle cores. However, for strongly ordered long-connection packets mixed in with the congestion queue, forced cross-core distribution completely disrupts the original arrival order of the packets. When packets arrive at the receiver out of order, it triggers the protocol stack to continuously send duplicate acknowledgment commands, leading to a large number of retransmissions at the source. This retransmission not only consumes a significant amount of additional processor power but also causes a sharp drop in the available bandwidth for long-connection services. Summary of the Invention
[0005] To address the technical problem in existing technologies that cannot accurately quantify the load distribution within congestion queues, easily generating additional burdens and leading to ineffective load balancing control, the present invention aims to provide a load balancing method and system for software switches. The specific technical solution adopted is as follows: This invention provides a load balancing method for a software switch, the method comprising: Poll the dwell depth of each receive queue of the network interface card to identify the congested queues to be processed for overload; perform asynchronous sampling for each queue to obtain sampled data packets and their characteristic information; the characteristic information of the sampled data packets includes at least: network layer 5-tuple and transmission protocol type; Data packets belonging to the order-keeping protocol type are identified and classified according to the network layer five-tuple to obtain multiple sets of feature-classified data streams; the load distribution unevenness is obtained based on the degree of load distribution difference between different feature-classified data streams; and parallel gain and retransmission cost are analyzed based on the total load of sampled data packets, the total load of feature-classified data streams, and the load distribution unevenness to obtain the cross-core distribution benefit evaluation value. Based on the cross-core distribution benefit assessment value, a binary asynchronous scheduling is performed between the cross-core interleaved distribution strategy and the single-core computing power isolation strategy.
[0006] Furthermore, the calibration process of the unprocessed overload queue includes: Periodically read the real-time dwell depth of each hardware receiving queue, and mark the hardware receiving queue with a dwell depth greater than the preset backlog threshold as an overloaded queue to be processed.
[0007] Furthermore, the asynchronous sampling includes: Copy the header information of a preset number of data packets from the head of each pending overload queue and store them in a separate memory area; parse the header information and accumulate the total payload bytes of all preset number of data packets to obtain the total payload of the sampled data packets.
[0008] Furthermore, the method for acquiring the feature classification data stream includes: Data packets with the Transmission Control Protocol (TCP) type in the sampled data packets are identified as ordered data packets; ordered data packets with the same network layer quintuple are grouped into the same set of data streams; If the number of aggregated data streams exceeds the preset analysis limit, all aggregated data streams are sorted in descending order of total load, and the first preset analysis limit number of aggregated data streams are selected as feature classification data streams; otherwise, all aggregated data streams are selected as feature classification data streams.
[0009] Furthermore, the method for obtaining the load distribution non-uniformity includes: Calculate the total load difference between each pair of data streams with different feature classifications, and sum all the total load differences to obtain the flow distribution deviation. The ratio of the traffic distribution deviation to the total load of all feature-classified data streams is used as the load distribution unevenness.
[0010] Furthermore, the method for obtaining the load distribution non-uniformity also includes boundary determination logic: If the number of identified feature classification data streams is one, then the load distribution unevenness is assigned the maximum weight upper limit. If the total payload of the identified feature classification data stream is zero, then the payload distribution unevenness is assigned a value of zero.
[0011] Furthermore, the analysis of parallel gain and retransmission cost to obtain a cross-core distribution benefit assessment value includes: Configure the unit load processing weight and the unit load retransmission penalty weight; The product of the total payload of the sampled data packets and the processing weight per unit payload is used as the estimated revenue score. The estimated penalty score is the product of the total payload of all feature-classified data streams, the load distribution unevenness, and the retransmission penalty weight per unit payload. The difference between the estimated benefit score and the estimated penalty score will be used as the cross-core distribution benefit assessment value.
[0012] Furthermore, executing the cross-core interleaving distribution strategy includes: If the cross-core distribution benefit assessment value is greater than zero, modify the control mask of the received data packet corresponding to the overload queue to be processed, and then poll and deliver subsequent data packets arriving at the overload queue to the received queues of other idle processor cores for parallel processing.
[0013] Furthermore, implementing the single-core computing power isolation strategy includes: If the cross-core distribution benefit assessment value is not greater than zero, maintain the binding relationship between the corresponding unprocessed overload queue and the original processor core, and modify the CPU affinity mask of other user-mode processes currently running on the original processor core; migrate other user-mode processes to other processor cores for execution.
[0014] The present invention also provides a load balancing system for a software switch, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the load balancing method for a software switch as described above.
[0015] The present invention has the following beneficial effects: This invention extracts the network layer quintuple and transmission protocol type through asynchronous sampling of overloaded queues, identifies and extracts the mixed order-preservation sensitive feature-classified data streams in the congestion queue, and performs lossless analysis of the backlog traffic components without interfering with the underlying actual queuing order. Furthermore, it analyzes the load distribution unevenness between different feature-classified data streams, transforming the long-connection order preservation requirement into a quantifiable concentration level. It then integrates the throughput gain of cross-core parallelism and the penalty cost of out-of-order retransmission into a single benefit evaluation value. Based on the positive or negative state of this evaluation value, the system performs cross-core interleaving distribution to quickly consume the backlog when massive short packets accumulate, and performs single-core computing power isolation to establish exclusive computing power when a single long connection is highly concentrated. This invention introduces load distribution unevenness to quantify the concentration of order-preserving traffic, comprehensively analyzes the value evaluation of parallelism gain and retransmission penalty, achieves reasonable allocation of multi-core resources, stably guarantees the transmission quality of long-connection services, and adapts to load balancing of massive heterogeneous terminal access in IoT edge gateways. Attached Figure Description
[0016] To more clearly illustrate the technical solutions and advantages in the embodiments of the present invention 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 some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a flowchart of a load balancing method for a software switch provided in one embodiment of the present invention. Detailed Implementation
[0018] To further illustrate the technical means and effects adopted by the present invention to achieve its intended purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation, structure, features, and effects of a load balancing method and system for a software switch proposed according to the present invention. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.
[0019] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.
[0020] The following description, in conjunction with the accompanying drawings, details a specific scheme for a load balancing method and system for a software switch provided by the present invention.
[0021] Please see Figure 1The diagram illustrates a load balancing method for a software switch according to an embodiment of the present invention, which includes the following steps: S1: Poll the dwell depth of each receive queue of the network card to identify the congested overload queues; perform asynchronous sampling for each overload queue to obtain sampled data packets and their characteristic information; the characteristic information of the sampled data packets includes at least: network layer 5-tuple and transmission protocol type.
[0022] The system employs a periodic polling mechanism for the network interface card (NIC) hardware receive queue, monitoring the packet dwell depth in real time to determine if traffic congestion caused by hash collisions has occurred. When a large number of heterogeneous terminals send packets to the same service port, traffic accumulation is highly likely, requiring rapid and accurate location of the overloaded queue and initiation of scheduling. In this embodiment, the overloaded queue to be processed is first determined by the dwell depth. The real-time dwell depth of each hardware receive queue is periodically read. This dwell depth represents the total number of packets currently piled up in the receive queue that have not yet been extracted and processed by the processor core, accurately reflecting the congestion status of the queue.
[0023] The system compares the dwell depth of each queue with a preset backlog threshold. Hardware receive queues with dwell depths exceeding the preset backlog threshold are marked as overloaded queues, thus identifying queues experiencing computing bottlenecks. It should be noted that the preset backlog threshold can be set to 512 packets, and this value can be dynamically adjusted based on the network card's hardware buffer capacity and the processor's computing power.
[0024] To ensure that the traffic assessment process does not interfere with the underlying actual packet forwarding order and performance, this invention employs asynchronous isolated sampling and independent memory copying for feature extraction. This completely decouples the control plane from the data plane. Asynchronous sampling is a lossless feature extraction performed by a user-space asynchronous monitoring process independent of the data plane. In this embodiment, a preset number of packet headers are copied from the head of each pending overload queue and stored in a preset memory area—a pre-allocated independent feature assessment memory area. This memory area is isolated from the forwarding plane, does not occupy service processing resources, and does not change the packet order of the actual queue. By copying only the packet headers instead of moving the original packets, offline analysis of the backlog load distribution characteristics is achieved, avoiding additional queuing latency caused by the assessment logic.
[0025] The copied header information is then parsed to extract the message structure and traffic attributes. The net payload bytes of the preset number of data packets are then summed, and the sum is used as the total payload of the sampled data packets to characterize the data scale of the current micro-batch traffic, providing a basis for evaluating the benefits of subsequent parallel processing. It should be noted that the preset number can be set between 64 and 128. This range must ensure that the sample has statistically significant distributional representativeness while keeping computational costs at a low level.
[0026] Understandably, the system uses a predefined network protocol stack structure to obtain the characteristic information of each data packet, which is used to distinguish data streams and identify ordered traffic. This characteristic information includes at least a network layer 5-tuple and a transport protocol type. The network layer 5-tuple includes: source IP address, destination IP address, source port, destination port, and transport layer protocol, representing the logical connection identifier to which each data packet belongs. The transport protocol type indicates whether the data packet belongs to a transport protocol that requires strict ordering, such as Transmission Control Protocol (TCP).
[0027] S2: Identify data packets belonging to the order-keeping protocol type and classify them according to the network layer five-tuple to obtain multiple sets of feature-classified data streams; obtain the load distribution unevenness based on the degree of load distribution difference between different feature-classified data streams; analyze the parallel gain and retransmission cost based on the total load of the sampled data packets, the total load of the feature-classified data streams, and the load distribution unevenness, and obtain the cross-core distribution benefit evaluation value.
[0028] In scenarios with a massive number of IoT terminals accessing the network concurrently, gateway traffic includes both stateless short packets and TCP long connection packets that are highly sensitive to out-of-order delivery. Therefore, it is necessary to first separate out-of-order traffic to avoid blindly distributing it across cores and causing retransmission penalties.
[0029] In this embodiment of the invention, the sampled data packets are first filtered for ordered traffic. Data packets with the Transmission Control Protocol (TCP) protocol type are identified as ordered data packets. These data packets must strictly guarantee their arrival order; otherwise, retransmission will be triggered, significantly reducing transmission efficiency. Then, ordered data packets with the same network layer 5-tuple are grouped into the same set of data streams. The same 5-tuple represents the same transmission connection, and after merging, different long and short connections can be accurately distinguished. The payload volume of the set of data streams characterizes the proportion of computing power of a specific long connection in the congestion queue.
[0030] In real-world network environments, if a gateway encounters port scanning or a distributed denial-of-service (DDoS) attack, the number of concurrent TCP connections in a single sampling batch can surge to hundreds or even thousands. This can lead to an exponential increase in subsequent computation time. Therefore, a computational scale truncation mechanism is introduced before calculating the load distribution. If the number of merged aggregate data streams exceeds a preset analysis limit, to avoid excessive computational load from double loops and excessive computing power consumption, the system sorts all aggregate data streams in descending order of total load and only truncates the first preset analysis limit number of aggregate data streams as feature classification data streams. This achieves computational scale truncation protection, eliminates tiny zombie connections, and retains core high-traffic features. The preset analysis limit can be set to 32, and the Top-K truncation mechanism ensures the timeliness of the evaluation logic.
[0031] If the number of aggregated data streams does not exceed the preset analysis limit, all aggregated data streams will be directly used as feature classification data streams to ensure complete traffic feature identification.
[0032] After determining the characteristic-classified data streams, the system calculates the load distribution unevenness based on the load differences between the data streams. By measuring the volume differences between pairs of different characteristic-classified data streams, the concentration trend of order-preserving loads can be quantified. When the sizes of the various TCP data streams are very similar, it indicates that although multiple long-lived connections exist, the traffic is evenly distributed, and the risk of continuous retransmissions caused by forced cross-core distribution is relatively dispersed, with the penalty cost being relatively controllable. When the vast majority of the traffic load is concentrated in a very small number of high-volume video streams or file download streams, it indicates that the current traffic exhibits an extremely oligopolistic concentration. In this case, if cross-core distribution is implemented, the packets that are distributed across cores are highly likely to belong to these few high-volume connections, inevitably inducing catastrophic high-frequency continuous retransmissions.
[0033] In this embodiment of the invention, the difference in total load between any two groups of data streams with different feature classifications is calculated, and all differences in total load are summed to obtain the flow distribution deviation, which reflects the degree of volume disparity between different data streams. The difference is obtained through the absolute value of the numerical difference.
[0034] The ratio of traffic distribution deviation to the total load of all feature-classified data streams is then used as the load distribution unevenness. A larger ratio indicates that traffic is more concentrated on a few connections, and the risk of retransmissions across cores is higher. Conversely, a smaller ratio indicates a more uniform traffic distribution and lower traffic splitting costs.
[0035] Specifically, to handle logical stability under special boundary conditions, boundary judgment logic is introduced. In this embodiment of the invention, when the number of identified feature-classified data streams is one, it indicates that all order-keeping loads are concentrated on a single connection, and cross-core transmission will inevitably trigger retransmissions, causing severe out-of-order delivery. In this case, the load distribution unevenness is assigned the maximum weight limit of 1 to prevent cross-core distribution of this stream to the greatest extent. When the total load of the identified feature-classified data streams is zero, it indicates that the TCP packets captured in the current queue may all be pure control frames without application-layer data, such as pure ACK confirmation packets, with no risk of out-of-order delivery and no penalty risk for cross-core distribution. In this case, the load distribution unevenness is assigned the value of zero.
[0036] In multi-core scheduling decisions, there is a trade-off between the benefits of parallel throughput and the costs of out-of-order retransmission. After calculating the load unevenness, the system performs an algebraic evaluation of the multi-core parallel gain and the costs of out-of-order retransmission to determine whether cross-core distribution is suitable. In this embodiment of the invention, a unit load processing weight and a unit load retransmission penalty weight are pre-configured. For example, the base value of the unit load processing weight is 1, and the value of the unit load retransmission penalty weight is limited to an integer between 10 and 20. The specific value is calibrated based on the offline benchmark performance test results of the network protocol stack.
[0037] The unit payload processing weight represents the computational overhead of the processor in normally parsing and forwarding a unit byte of data. The unit payload retransmission penalty weight represents the additional computational overhead caused by source-end retransmissions due to out-of-order delivery, and this penalty weight should be significantly greater than the processing weight. For example, it should be guaranteed that the unit payload retransmission penalty weight is strictly greater than 10 times the unit payload processing weight. This constraint ensures that in subsequent integrated calculations, the penalty weight for out-of-order retransmissions can significantly reflect the severe cost of violating order preservation. It should be noted that both weight coefficients are empirical constants that the system has obtained in advance through offline benchmark performance tests of the network protocol stack and are fixed in the system, used to replace the absolute physical clock latency in the algorithm.
[0038] Furthermore, the product of the total payload of the sampled data packets and the processing weight per unit payload is used as the estimated benefit score. This product term represents the estimated theoretical benefit score that the system can obtain if all sampled packets in the current batch are processed across cores. The larger the estimated benefit score, the larger the total amount of data backed up in the current queue, and the more significant the queuing waiting overhead can be saved by using multi-core parallel processing.
[0039] The estimated penalty score is then calculated by multiplying the total payload of all feature-classified data streams, the load unevenness, and the retransmission penalty weight per unit payload. This product represents the estimated penalty cost of out-of-order retransmissions caused by forced cross-core distribution due to order-preserving constraints. When traffic is highly concentrated in a few long connections, i.e., when the load unevenness approaches 1, the estimated penalty score retains almost all penalty weights, which dramatically amplifies the overall penalty score, reflecting the cost of breaking up large-volume long connections. When traffic consists of a massive number of fragmented micro TCP connections, i.e., when the load unevenness approaches 0, the estimated penalty score is greatly reduced and approaches zero, indicating that the probability of large-scale retransmissions caused by breaking up into extremely uniform small-volume connections is very low. Unnecessary penalty scores are reduced by addressing the load unevenness.
[0040] By weighting the penalty base according to the load distribution unevenness, dynamic scaling of retransmission risk is achieved. Finally, the difference between the estimated benefit score and the estimated penalty score is used as the cross-core distribution benefit assessment value. As an example, the expression for the cross-core distribution benefit assessment value is: In the formula, This is expressed as an assessment value of cross-core distribution benefits; This is expressed as the total payload of the sampled data packets; It is represented as the total payload of all feature classification data streams, that is, the total number of payload bytes of data packets belonging to the Transmission Control Protocol (TCP) in the current sampling; This is expressed as load distribution non-uniformity; This is expressed as the weight per unit load. This is expressed as the retransmission penalty weight per unit load. Through integrated calculation, a dimensionless quantitative score reflecting the relative magnitude between multi-core parallel gain and out-of-order repair cost is obtained.
[0041] S3: Based on the cross-core distribution benefit assessment value, perform binary asynchronous scheduling between the cross-core interleaved distribution strategy and the single-core computing power isolation strategy.
[0042] The cross-core distribution benefit assessment value realizes a quantitative comparison between the benefits of multi-core parallelism and the cost of order preservation penalty. Based on this, the system performs binary asynchronous scheduling between cross-core interleaved distribution and single-core computing power isolation, achieving a balance between improving throughput and ensuring order preservation.
[0043] In this embodiment of the invention, if the cross-core distribution benefit assessment value is greater than zero, it indicates that the speed-up gain of multi-core parallelism exceeds the potential out-of-order repair cost, indicating that the majority of the packets in the current unprocessed overload queue are independent User Datagram Protocol (UDP) short packets that do not require order preservation, or that the Transmission Control Protocol (TCP) load distribution is extremely uniform and fragmented.
[0044] It should be noted that the feature classification data stream obtained by asynchronous sampling is used to characterize the continuous traffic connection characteristics within the current time window. Modifications to the control mask and affinity mask of the received data packets are used to guide the processing path of subsequent arriving packets with the same network layer quintuple, and do not redistribute the sampled historical packets.
[0045] Under this condition, the system invokes the operating system's underlying Receive Packet Steering (RPS) mechanism. It reads the RPS mask configuration corresponding to the overloaded queue in the operating system's network stack, modifies the RPS mask for that queue, and sets the flags of all other idle processor cores to allow reception. Through this RPS mask modification, the system extends the single-core hash distribution path of the original hardware network card at the software level. Subsequent packets arriving at this overloaded queue are then round-robin delivered to the receive queues of other idle processor cores for parallel processing, quickly clearing queue backlogs and significantly improving short message processing efficiency.
[0046] If the cross-core distribution benefit assessment value is not greater than zero, it indicates that the retransmission cost is too high. Forcing cross-core splitting will likely disrupt the order preservation of core long connections, and the resulting massive retransmission repair cost far exceeds the meager benefit of multi-core parallel processing. The overall distribution strategy exhibits a serious negative gain in terms of time consumption. This indicates that the traffic in the current queue exhibits an oligopolistic characteristic of highly concentrated single long connections, making cross-core splitting unsuitable. It is better to maintain the binding relationship between the corresponding unprocessed overload queue and the original processor core.
[0047] Specifically, to alleviate the computational pressure faced by the original processor core when handling large volumes of traffic from oligopolies, the system invokes the operating system's CPU affinity scheduling mechanism to implement a long-term computational isolation strategy. It iterates through the process identifiers of all ordinary user-mode processes currently running on the original processor core, as allocated by the operating system, and modifies the CPU affinity masks of other user-mode processes running on that core. Through this modification, other user-mode processes are migrated to other processor cores for execution. By separating irrelevant user-mode services, an exclusive physical computational environment is established for high-volume, long-lived connections on that core. This improves processing efficiency while maintaining order preservation, avoids bandwidth degradation due to computational contention, and fundamentally ensures the transmission stability of long-lived connection services.
[0048] In this embodiment of the invention, after any mask modification action is executed, the system sends a space release command to the independent feature evaluation memory region at that time. This space release command clears the asynchronous sampling data packets and simultaneously cancels all memory addresses occupied by subsequent feature classification data streams and cross-core distribution benefit evaluation values. This explicit memory space release action completes the entire load balancing asynchronous evaluation and scheduling cycle, resetting all state variables to zero and releasing occupied resources to await the underlying hardware network card triggering the queue dwell depth exceedance alarm again in the next polling cycle. Furthermore, before executing the cross-core interleaving distribution strategy or the single-core computing power isolation strategy, the system checks the time interval between the target processor core and the last mask modification or process migration. If this time interval is less than a preset scheduling cooldown period, the current binary asynchronous scheduling action is skipped, and the existing state is maintained. The scheduling cooldown period can be set to 2 seconds; the specific value can be adjusted by the implementer according to the implementation scenario and is not limited here.
[0049] In summary, this invention extracts the network layer quintuple and transmission protocol type through asynchronous sampling of overloaded queues, identifies and extracts the mixed order-sensitive feature-classified data streams in the congestion queue, and performs lossless analysis of backlogged traffic components without interfering with the underlying actual queuing order. Furthermore, it analyzes the load distribution unevenness among different feature-classified data streams, transforming the long-connection order-preserving requirement into a quantifiable concentration level. It then integrates the throughput gain of cross-core parallelism and the penalty cost of out-of-order retransmission into a single benefit evaluation value. Based on the positive or negative state of this evaluation value, the system performs cross-core interleaving distribution to quickly consume the backlog when massive short packets accumulate, and performs single-core computing power isolation to establish exclusive computing power when a single long connection is highly concentrated. This invention introduces load distribution unevenness to quantify the concentration of order-preserving traffic, comprehensively analyzes the value evaluation of parallelism gain and retransmission penalty, achieves reasonable allocation of multi-core resources, stably guarantees the transmission quality of long-connection services, and adapts to load balancing of massive heterogeneous terminal access in IoT edge gateways.
[0050] The present invention also provides a load balancing system for a software switch, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the load balancing method for a software switch as described above.
[0051] It should be noted that the order of the above embodiments of the present invention is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. The processes depicted in the accompanying drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0052] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.
Claims
1. A load balancing method for a software switch, characterized in that, The method includes: Poll the dwell depth of each receive queue of the network interface card to identify the congested queues to be processed for overload; perform asynchronous sampling for each queue to obtain sampled data packets and their characteristic information; the characteristic information of the sampled data packets includes at least: network layer 5-tuple and transmission protocol type; Data packets belonging to the order-keeping protocol type are identified and classified according to the network layer five-tuple to obtain multiple sets of feature-classified data streams; the load distribution unevenness is obtained based on the degree of load distribution difference between different feature-classified data streams; and parallel gain and retransmission cost are analyzed based on the total load of sampled data packets, the total load of feature-classified data streams, and the load distribution unevenness to obtain the cross-core distribution benefit evaluation value. Based on the cross-core distribution benefit assessment value, a binary asynchronous scheduling is performed between the cross-core interleaved distribution strategy and the single-core computing power isolation strategy.
2. The load balancing method for a software switch according to claim 1, characterized in that, The calibration process for the unprocessed overload queue includes: Periodically read the real-time dwell depth of each hardware receiving queue, and mark the hardware receiving queue with a dwell depth greater than the preset backlog threshold as an overloaded queue to be processed.
3. The load balancing method for a software switch according to claim 1, characterized in that, The asynchronous sampling includes: Copy the header information of a preset number of data packets from the head of each pending overload queue and store them in a separate memory area; parse the header information and accumulate the total payload bytes of all preset number of data packets to obtain the total payload of the sampled data packets.
4. The load balancing method for a software switch according to claim 1, characterized in that, The method for acquiring the feature classification data stream includes: Data packets with the Transmission Control Protocol (TCP) type in the sampled data packets are identified as ordered data packets; ordered data packets with the same network layer quintuple are grouped into the same set of data streams; If the number of aggregated data streams exceeds the preset analysis limit, all aggregated data streams are sorted in descending order of total load, and the first preset analysis limit number of aggregated data streams are selected as feature classification data streams; otherwise, all aggregated data streams are selected as feature classification data streams.
5. The load balancing method for a software switch according to claim 1, characterized in that, The method for obtaining the load distribution non-uniformity includes: Calculate the total load difference between each pair of data streams with different feature classifications, and sum all the total load differences to obtain the flow distribution deviation. The ratio of the traffic distribution deviation to the total load of all feature-classified data streams is used as the load distribution unevenness.
6. The load balancing method for a software switch according to claim 5, characterized in that, The method for obtaining load distribution non-uniformity also includes boundary determination logic: If the number of identified feature classification data streams is one, then the load distribution unevenness is assigned the maximum weight upper limit. If the total payload of the identified feature classification data stream is zero, then the payload distribution unevenness is assigned a value of zero.
7. The load balancing method for a software switch according to claim 1, characterized in that, The analysis of parallel gain and retransmission cost yields an evaluation value for cross-core distribution benefits, including: Configure the unit load processing weight and the unit load retransmission penalty weight; The product of the total payload of the sampled data packets and the processing weight per unit payload is used as the estimated revenue score. The estimated penalty score is the product of the total payload of all feature-classified data streams, the load distribution unevenness, and the retransmission penalty weight per unit payload. The difference between the estimated benefit score and the estimated penalty score will be used as the cross-core distribution benefit assessment value.
8. The load balancing method for a software switch according to claim 1, characterized in that, Executing the cross-core interleaving distribution strategy includes: If the cross-core distribution benefit assessment value is greater than zero, modify the control mask of the received data packet corresponding to the overload queue to be processed, and then poll and deliver subsequent data packets arriving at the overload queue to the received queues of other idle processor cores for parallel processing.
9. The load balancing method for a software switch according to claim 1, characterized in that, Implementing the single-core computing power isolation strategy includes: If the cross-core distribution benefit assessment value is not greater than zero, maintain the binding relationship between the corresponding unprocessed overload queue and the original processor core, and modify the CPU affinity mask of other user-mode processes currently running on the original processor core; migrate other user-mode processes to other processor cores for execution.
10. A load balancing system for a software switch, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the load balancing method for a software switch as described in any one of claims 1 to 9.