Switch-based cpu pressure adjustment method, electronic device, and storage medium
By analyzing the switch's historical and current CPU load, packet loss count, and packet processing rate, the packet processing rate of the target protocol was identified and adjusted, thus solving the problem of excessive CPU load on the switch and achieving adaptive adjustment of CPU load and stable service operation.
Patent Information
- Application Number
- CN202611294306.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-25
- Publication Date
- 2026-11-06
AI Technical Summary
In network switches, excessive CPU load can cause task scheduling delays and disrupt business operations. Existing technologies are insufficient to effectively adjust CPU pressure.
By analyzing the switch's historical CPU pressure, current CPU pressure, pressure threshold, packet loss count, and packet processing rate, the target protocol can be identified and its packet processing rate adjusted to achieve fine-grained control, avoiding resource waste and service interruption.
It effectively alleviates high CPU load, maintains a stable message processing rate, and achieves a balance between adaptive CPU pressure adjustment and stable business operation, avoiding resource waste or business interruption caused by continuous over-adjustment.
Smart Images

Figure CN123055562A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network communication technology, and in particular to a CPU pressure adjustment method based on a switch, an electronic device, and a storage medium. Background Technology
[0002] In a network switch, the CPU (Central Processing Unit) is responsible for processing control protocol messages of various protocols. It needs to send and receive protocol messages, perform protocol calculations, and update the forwarding table. There may be many active tasks on the CPU. If the message processing rate in the protocol queue is abnormal, a certain task may occupy the CPU for a long time. The CPU will run at high load and may not be able to schedule other tasks in time, thus causing service abnormalities.
[0003] Therefore, there is an urgent need for an effective method for adjusting CPU stress based on switches. Summary of the Invention
[0004] This application provides at least one CPU stress adjustment method, electronic device, and storage medium based on a switch, which can improve the CPU stress adjustment efficiency of the switch and thus improve the stability of the CPU.
[0005] This application provides a switch-based CPU pressure adjustment method, which includes: determining a target protocol from the preset protocols based on several historical CPU pressures, current CPU pressures, pressure thresholds, current packet loss counts of each preset protocol in the switch, and the message processing rate of each preset protocol; wherein the collection time of several historical CPU pressures is earlier than the collection time of the current CPU pressure; the pressure thresholds include a first pressure threshold and a second pressure threshold, the first pressure threshold being greater than the second pressure threshold; and the message processing rate includes the current message processing rate of the corresponding preset protocol; adjusting the current message processing rate of the target protocol to obtain a target message processing rate; and during the process of controlling the target protocol to process messages at the target message processing rate for a preset period, if it is detected that the target CPU pressure is less than the second pressure threshold and there are no target packet loss counts of each preset protocol greater than the count threshold within the preset period, the CPU pressure adjustment ends.
[0006] This application provides a CPU pressure adjustment device based on a switch, comprising: a determination module, an adjustment module, and a detection module; the determination module is used to determine a target protocol from the preset protocols based on several historical CPU pressures, current CPU pressures, pressure thresholds, current packet loss counts of each preset protocol in the switch, and the message processing rate of each preset protocol, wherein the acquisition time of several historical CPU pressures is earlier than the acquisition time of the current CPU pressure, the pressure thresholds include a first pressure threshold and a second pressure threshold, the first pressure threshold being greater than the second pressure threshold, and the message processing rate including the current message processing rate of the corresponding preset protocol; the adjustment module is used to adjust the current message processing rate of the target protocol to obtain a target message processing rate; the detection module is used to terminate the CPU pressure adjustment if, during the process of controlling the target protocol to process messages at the target message processing rate for a preset period of time, the target CPU pressure is detected to be less than the second pressure threshold and the target packet loss count of each preset protocol is not greater than the count threshold within the preset period of time.
[0007] This application provides an electronic device, including a memory and a processor, wherein the processor is used to execute program instructions stored in the memory to implement the above-described switch-based CPU stress adjustment method.
[0008] This application provides a computer-readable storage medium storing program instructions thereon, which, when executed by a processor, implement the above-described switch-based CPU stress adjustment method.
[0009] The above scheme identifies the target protocol from among the preset protocols by using historical CPU pressure, current CPU pressure, pressure threshold, current packet loss count, and packet processing rate of each preset protocol in the switch. It can accurately identify specific protocols causing CPU overload or performance bottlenecks by leveraging the relationship between historical CPU pressure, current CPU pressure, and pressure threshold. Combined with CPU pressure, packet loss count, and packet processing rate, it achieves target protocol filtering. Subsequently, it adjusts the current packet processing rate of the target protocol to achieve fine-grained control of packets within specific protocols, reducing the packet load sent to the CPU and effectively alleviating high CPU load. During the process of controlling the target protocol to process packets at the adjusted rate, if it detects that the target CPU pressure is below the second pressure threshold and no target packet loss count for any preset protocol is above the threshold, the CPU pressure adjustment ends. This ensures a stable packet processing rate after the CPU load recovers to a safe level, avoiding resource waste or service interruption caused by continuous over-adjustment of protocol packet processing rates, and achieving a balance between adaptive CPU pressure adjustment and stable service operation.
[0010] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this application. Attached Figure Description
[0011] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with this application and, together with the specification, serve to explain the technical solutions of this application.
[0012] Figure 1 This is a first flowchart illustrating an exemplary embodiment of the CPU pressure adjustment method based on a switch in this application; Figure 2 This is a schematic diagram of the second process of an exemplary embodiment of the CPU pressure adjustment method based on a switch in this application; Figure 3 This is a schematic diagram of the third process of an exemplary embodiment of the CPU pressure adjustment method based on a switch in this application; Figure 4 This is a schematic diagram of an embodiment of the CPU pressure adjustment device based on a switch in this application; Figure 5 This is a schematic diagram of the structure of an embodiment of the electronic device of this application; Figure 6 This is a schematic diagram of the structure of an embodiment of the computer-readable storage medium of this application. Detailed Implementation
[0013] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It is understood that the specific embodiments described herein are only for explaining this application and not for limiting it. Furthermore, it should be noted that, for ease of description, only the parts related to this application are shown in the accompanying drawings, not all structures. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0014] In the following description, specific details such as particular system architectures, interfaces, and technologies are presented for illustrative purposes rather than for limiting purposes, in order to provide a thorough understanding of this application.
[0015] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus. The term "and / or" is merely a description of the association of related objects, indicating that three relationships can exist; for example, A and / or B can represent: A alone, A and B simultaneously, and B alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects are in an "or" relationship. Furthermore, "many" in this document means two or more. Furthermore, the term "at least one" in this document means any combination of at least two of any one or more of a plurality of elements, for example, including at least one of A, B, and C, which can mean including any one or more elements selected from the set consisting of A, B, and C. Additionally, the term "several" in this document means one or more.
[0016] This application provides several switch-based CPU stress adjustment methods and devices. The application scenarios for these switch-based CPU stress adjustment methods include, but are not limited to, the transmission of protocol messages in network switches. The execution entity of the switch-based CPU stress adjustment method can be a switch-based CPU stress adjustment device, such as a switch or a processor within a switch. The switch-based CPU stress adjustment device can be located within a terminal device, server, or other processing device. The terminal device can be a user equipment (UE), mobile device, user terminal, terminal, cellular phone, cordless phone, personal digital assistant (PDA), handheld device, computing device, vehicle-mounted device, etc. In some possible implementations, the switch-based CPU stress adjustment method can be implemented by the processor calling computer-readable instructions stored in memory.
[0017] Please see Figure 1 , Figure 1 This is a first flowchart illustrating an exemplary embodiment of the CPU stress adjustment method based on a switch according to this application. Specifically, the CPU stress adjustment method based on a switch may include the following steps: S11: Based on the historical CPU pressure, current CPU pressure, pressure threshold, current packet loss count results of each preset protocol in the switch, and the message processing rate of each preset protocol, determine the target protocol from each preset protocol.
[0018] The historical CPU pressure data is collected earlier than the current CPU pressure data. The historical CPU pressure data includes one or more historical CPU pressure data points. Historical CPU pressure represents the CPU pressure collected by the switch during a historical time period. Current CPU pressure represents the pressure / load information of the processor in the switch during the current time period. The current time period is later than the historical time period. The CPU pressure represents the pressure information of the CPU during runtime for various preset protocols and the switch's operating system. Pressure thresholds include a second pressure threshold and a first pressure threshold. The second pressure threshold is greater than the first pressure threshold. The first and second pressure thresholds can be preset pressure values or pressure values configured based on configuration commands, and are not limited here. The preset protocols can be various control protocols handled by the CPU in the switch, including but not limited to routing protocols, Spanning Tree Protocol (STP), Address Resolution Protocol (ARP), etc. For example, routing protocols include Open Shortest Path First (OSPF) and Border Gateway Protocol (BGP). The preset protocol message is received from the network port by the switching chip (ASIC / NP) and then sent to the CPU for processing through the internal queue (i.e. the protocol queue corresponding to the preset protocol).
[0019] The current packet loss count of the preset protocol represents the number of packets dropped by the protocol queue of the preset protocol during the current time period due to insufficient protocol queue capacity or processing delays.
[0020] The message processing rate of a preset protocol includes the current message processing rate of the corresponding preset protocol. The message processing rate represents the number of messages processed by the protocol queue of the corresponding preset protocol per unit time, and the unit of message processing rate can be PPS (packets per second). Specifically, the message processing rate includes the enqueue rate and / or dequeue rate of messages in the protocol queue of the corresponding preset protocol, and the message processing rate represents the number of messages enqueued and / or dequeued in the protocol queue per unit time. The message processing rate of each preset protocol represents the message processing rate of the protocol queue of each preset protocol within at least one unit time associated with the current time period. The current time period includes multiple consecutive current unit times; at least one unit time can include one or more current unit times within the current time period. The current time period represents the current detection cycle of the switch. The detection cycle is used to represent the information acquisition cycle for stress adjustment of the switch's CPU. Specifically, the message processing rate of a preset protocol includes the current message processing rate of the corresponding preset protocol. The current message processing rate of the preset protocol is obtained based on the message processing rate within one or more current unit times within the current time period. For example, the message processing rate of the first or last current unit time within the current time period can be used as the current message processing rate of the preset protocol, or the average of the message processing rates of multiple current unit time periods within the current time period can be used as the current message processing rate.
[0021] The target protocol is at least one of the preset protocols. The target protocol is determined based on the current packet loss count of each preset protocol in the switch and / or the packet processing rate of each preset protocol. The target protocol is the object to be adjusted, and its packet processing rate needs to be adjusted.
[0022] Specifically, S11 can be: determining the target protocol from each preset protocol based on either the first comparison result between the current CPU pressure and the first pressure threshold, or the second comparison result between the current CPU pressure and the second pressure threshold, and a number of historical CPU pressures compared with the first pressure threshold, using the current packet loss count result of each preset protocol in the switch and / or the message processing rate of each preset protocol.
[0023] In some application scenarios: Responding to a first comparison result indicating that the current CPU pressure is greater than or equal to a first pressure threshold, and a third comparison result indicating that no historical CPU pressure is greater than or equal to the first pressure threshold among several historical CPU pressures, the target protocol is determined from each preset protocol based on the current packet loss count of each preset protocol in the switch and / or the message processing rate of each preset protocol. Specifically, if the first comparison result indicates that the current CPU pressure is greater than or equal to the first pressure threshold, and the third comparison result indicates that no historical CPU pressure is greater than or equal to the first pressure threshold among several historical CPU pressures, it means that the current CPU pressure is the first time the switch has detected a CPU pressure greater than or equal to the first pressure threshold. At this time, the CPU pressure / load is abnormally high. The current packet loss count of each preset protocol in the switch is used to determine whether packet loss has occurred in the protocol queue of each preset protocol in the current time period, so as to subsequently limit the message processing rate of the packet-loss protocol, and / or, the message processing rate of each preset protocol is used to determine the protocol with the fastest message processing rate and the highest CPU utilization among the preset protocols, so as to limit its message processing rate. For example, the preset protocol with the highest message processing rate can be used as the target protocol; and / or, the preset protocol with the largest current packet loss count or all preset protocols with current packet loss counts greater than the count threshold can be used as the target protocol.
[0024] In other application scenarios, in response to a second comparison result indicating that the current CPU pressure is greater than or equal to a second pressure threshold, and a third comparison result indicating that at least one historical CPU pressure is greater than or equal to a first pressure threshold, a target protocol is determined from the preset protocols based on the packet processing rate of each preset protocol. This indicates that the switch has detected that the CPU pressure is greater than or equal to the first pressure threshold during the historical period to which the historical CPU pressure belongs, and that packet processing rate adjustments have been made during the historical period. In this case, the determination of the target protocol based on the packet processing rate of each preset protocol is triggered when the current CPU pressure is greater than or equal to the second pressure threshold, and packet processing rate limiting is applied to it. That is, the protocol with the fastest packet processing rate and the highest CPU utilization among the preset protocols is determined by the packet processing rate of each preset protocol in order to limit its packet processing rate. For example, the preset protocol with the highest packet processing rate is selected as the target protocol.
[0025] In other application scenarios, in response to the current CPU pressure being less than a second pressure threshold, and a third comparison result indicating that at least one historical CPU pressure is greater than or equal to a first pressure threshold, a target protocol is determined from the preset protocols based on the current packet loss count of each preset protocol in the switch. This includes: in response to the presence of at least one preset protocol whose current packet loss count is greater than a counting threshold, selecting a target protocol from the preset protocols whose current packet loss count is greater than the counting threshold. This indicates that the switch has detected CPU pressure greater than or equal to the first pressure threshold during the historical period to which the historical CPU pressure belongs, and packet processing rate adjustments have been made during the historical period. In this case, the determination of the target protocol based on the current packet loss count of each preset protocol and the packet processing rate limiting of it are triggered by the current CPU pressure being less than the second pressure threshold and the presence of at least one preset protocol whose current packet loss count is greater than the counting threshold. This allows for subsequent packet processing rate limiting of the packet loss protocol. For example, the preset protocol with the largest current packet loss count or all preset protocols whose current packet loss count is greater than the counting threshold can be used as the target protocol.
[0026] S12: Adjust the current message processing rate of the target protocol to obtain the target message processing rate.
[0027] The target message processing rate represents the rate obtained by adjusting the current message processing rate of the target protocol.
[0028] In some application scenarios, the message processing rate includes the queuing rate of messages in the protocol queue of the corresponding preset protocol, and the current message processing rate of the target protocol includes the current queuing rate of the target protocol. The above S12 can be: decelerating the current queuing rate of the target protocol to obtain the target queuing rate of the target protocol, and using the target queuing rate as the target message processing rate of the target protocol.
[0029] In other application scenarios, the message processing rate includes the dequeue rate of messages in the protocol queue of the corresponding preset protocol, and the current message processing rate of the target protocol includes the current dequeue rate of the target protocol. The above S12 can be: decelerating the current dequeue rate of the target protocol to obtain the target dequeue rate of the target protocol, and using the target dequeue rate as the target message processing rate of the target protocol.
[0030] In some application scenarios, the message processing rate includes the enqueue rate and dequeue rate of messages in the protocol queue of the corresponding preset protocol, and the current message processing rate of the target protocol includes the current enqueue rate and current dequeue rate of the target protocol. The above S12 can be: decelerating the current enqueue rate of the target protocol to obtain the target enqueue rate of the target protocol; decelerating the current dequeue rate of the target protocol to obtain the target dequeue rate of the target protocol; and using the target enqueue rate and target dequeue rate as the target message processing rate of the target protocol.
[0031] S13: During the process of controlling the target protocol to process packets at the target packet processing rate for a preset period of time, if it is detected that the target CPU pressure is less than the second pressure threshold and there is no target packet loss count result of each preset protocol that is greater than the count threshold within the preset period of time, the CPU pressure adjustment ends.
[0032] The preset time period is the next detection cycle following the current time period. The target CPU pressure represents the CPU pressure on the switch within the preset time period. The target packet loss count represents the packet loss count of each preset protocol in the switch within the preset time period. S11 and S12 above can be steps for performing this round of CPU pressure adjustment corresponding to the current time period.
[0033] In some application scenarios, the target protocol processes packets at the target packet processing rate during a preset time period, while other preset protocols besides the target protocol process packets at the original packet processing rate within the current time period. The CPU pressure in the switch during packet processing within the preset time period is collected and used as the target CPU pressure. If the target CPU pressure is detected to be less than the second pressure threshold and the target packet loss count result of each preset protocol is not greater than the count threshold within the preset time period, the CPU pressure adjustment ends.
[0034] In other application scenarios, if a target CPU pressure greater than or equal to a second pressure threshold is detected within a preset time period, or if a target CPU pressure less than the second pressure threshold is detected within a preset time period and at least one preset protocol's target packet loss count is greater than the count threshold, then the CPU pressure adjustment step corresponding to this preset time period is initiated. This involves determining a new target protocol from among the preset protocols based on the detected target CPU pressure and the target packet loss count and / or associated packet processing rate of each preset protocol in the data collected by the switch during the preset time period. Specifically, based on the target packet loss count and / or the new packet processing rate of each preset protocol in the switch during the preset time period, a new target protocol is determined from among the preset protocols; the new packet processing rate of the new target protocol is adjusted to obtain the target packet processing rate of the new target protocol; during the process of controlling the new target protocol to process packets at the target packet processing rate for the next preset time period, if a new target CPU pressure less than the first pressure threshold is detected in the next preset time period and no preset protocol's target packet loss count is greater than the count threshold, then the CPU pressure adjustment ends.
[0035] The target packet loss count result of the preset protocol represents the number of packets dropped by the protocol queue of the preset protocol within the preset time period due to insufficient protocol queue capacity or processing delay.
[0036] The new message processing rate of a preset protocol includes the target message processing rate of the corresponding preset protocol. The new message processing rate of each preset protocol represents the message processing rate of the protocol queue of each preset protocol within at least one unit of time associated with a preset time period. The preset time period includes multiple consecutive target unit times; at least one unit of time may include one or more target unit times within the preset time period. The timescale between the current unit time and the target unit time is the same, differing only in that they are within different time periods. The preset time period represents the next detection cycle after the current detection cycle of the switch.
[0037] The new packet processing rate of the preset protocol is obtained based on the packet processing rate of one or more target units within a preset time period. For example, the packet processing rate of the first or last unit within the preset time period can be used as the new packet processing rate of the preset protocol; or, the average of the packet processing rates of multiple current units within the current time period can be used as the current packet processing rate; or, the target packet processing rate of the target protocol can be used as the new packet processing rate of the target protocol within the preset time period, and the packet processing rates of other protocols besides the target protocol in the current time period can be retained as the new packet processing rate of the corresponding preset protocol within the preset time period. The new target protocol is at least one of the preset protocols. The new target protocol is obtained based on the target packet loss count results of each preset protocol in the switch and / or the new packet processing rate of each preset protocol. The target packet processing rate of the new target protocol represents the rate obtained by adjusting the new packet processing rate of the new target protocol. The next preset time period is the next detection cycle after the preset time period. The new target CPU pressure represents the pressure of the switch CPU in the next preset time period.
[0038] Understandably, based on the CPU pressure detected in the current detection cycle and the comparison between historical CPU pressure and the pressure threshold, the packet processing rate adjustment for the current round is triggered, and packets are processed at the adjusted packet processing rate in the next detection cycle. The CPU pressure in the next detection cycle is then collected. If the CPU pressure in the next detection cycle is less than the second pressure threshold and there is no preset protocol packet loss, the packet processing rate adjustment ends, i.e., the CPU pressure adjustment ends. If the CPU pressure in the next detection cycle is greater than the second pressure threshold or preset protocol packet loss occurs, the packet processing rate adjustment for the next round is triggered. This process continues until the packet processing rate is adjusted in the last round. After this adjustment, packets are processed at the adjusted packet processing rate, and the packet processing rate in the next detection cycle of the last round is collected and found to be less than the second pressure threshold and without preset protocol packet loss. Then, the packet processing rate adjustment ends, i.e., the CPU pressure adjustment ends.
[0039] The above scheme identifies the target protocol from among the preset protocols by using historical CPU pressure, current CPU pressure, pressure threshold, current packet loss count, and packet processing rate of each preset protocol in the switch. It can accurately identify specific protocols causing CPU overload or performance bottlenecks by leveraging the relationship between historical CPU pressure, current CPU pressure, and pressure threshold. Combined with CPU pressure, packet loss count, and packet processing rate, it achieves target protocol filtering. Subsequently, it adjusts the current packet processing rate of the target protocol to achieve fine-grained control of packets within specific protocols, reducing the packet load sent to the CPU and effectively alleviating high CPU load. During the process of controlling the target protocol to process packets at the adjusted rate, if it detects that the target CPU pressure is below the second pressure threshold and no target packet loss count for any preset protocol is above the threshold, the CPU pressure adjustment ends. This ensures a stable packet processing rate after the CPU load recovers to a safe level, avoiding resource waste or service interruption caused by continuous over-adjustment of protocol packet processing rates, and achieving a balance between adaptive CPU pressure adjustment and stable service operation.
[0040] In some embodiments, S11 may include the following steps: in response to the absence of a historical CPU pressure greater than or equal to a first pressure threshold and the current CPU pressure being greater than or equal to the first pressure threshold, determining a target protocol from each preset protocol based on the message processing rate of each preset protocol in the switch; or, in response to the presence of at least one historical CPU pressure greater than or equal to the first pressure threshold and the current CPU pressure being greater than or equal to a second pressure threshold, determining a target protocol from each preset protocol based on the message processing rate of each preset protocol in the switch; or, in response to the presence of at least one historical CPU pressure greater than or equal to the first pressure threshold and the current CPU pressure being less than the second pressure threshold, and the presence of at least one preset protocol whose current packet loss count is greater than a count threshold, determining a target protocol from each preset protocol based on the current packet loss count of each preset protocol in the switch.
[0041] In some application scenarios, if there is no historical CPU pressure greater than or equal to a first pressure threshold in a given set of historical CPU pressure data, and the current CPU pressure is also greater than or equal to the first pressure threshold, it indicates that the current CPU pressure is the first time the switch has detected a CPU pressure greater than or equal to the first pressure threshold. In this case, the CPU pressure / load is abnormally high. By analyzing the packet processing rates of each preset protocol, the protocol with the fastest packet processing rate and highest CPU utilization is determined, and its packet processing rate is then rate-limited. For example, the preset protocol with the highest packet processing rate is selected as the target protocol.
[0042] In other application scenarios, if at least one historical CPU pressure is greater than or equal to a first pressure threshold and the current CPU pressure is greater than or equal to a second pressure threshold, it indicates that the switch detected a CPU pressure greater than or equal to the first pressure threshold during the historical period to which the historical CPU pressure belongs, and packet processing rate adjustments were made during that historical period. In this case, triggering the determination of a target protocol based on the packet processing rate of each preset protocol by using the current CPU pressure being greater than or equal to the second pressure threshold, and then rate limiting the packet processing rate of this target protocol, is achieved by determining the protocol with the fastest packet processing rate and highest CPU utilization among the preset protocols. For example, the preset protocol with the highest packet processing rate is selected as the target protocol.
[0043] In other application scenarios, when at least one historical CPU pressure is greater than or equal to a first pressure threshold, the current CPU pressure is less than a second pressure threshold, and at least one preset protocol has a current packet loss count greater than a counting threshold, a target protocol is determined from among the preset protocols based on their current packet loss counts. This means that during the historical period to which the historical CPU pressure occurred, the switch detected that the CPU pressure was greater than or equal to the first pressure threshold, and packet processing rate adjustments were made during that period. In this case, the current CPU pressure being less than the second pressure threshold and the existence of at least one preset protocol having a current packet loss count greater than the counting threshold triggers the determination of a target protocol from among the preset protocols based on their current packet loss counts, and its packet processing rate is then rate-limited. This allows for subsequent rate-limiting of packet loss protocols. For example, the preset protocol with the highest current packet loss count or all preset protocols with current packet loss counts greater than the counting threshold can be used as the target protocol.
[0044] In some application scenarios, the message processing rate of a preset protocol also includes the historical message processing rate of the corresponding preset protocol. The historical message processing rate is collected earlier than the current message processing rate. The historical message processing rate of the preset protocol is obtained based on the message processing rate within one or more historical units within a historical time period. For example, the message processing rate of the first or last historical unit within a historical time period can be used as the historical message processing rate of the preset protocol, or the average of the message processing rates within multiple historical units within a historical time period can be used as the historical message processing rate. The collection time of the historical message processing rate is the historical time period. The collection time of the current message processing rate is the current time period. The historical time period is a detection cycle earlier than the current time period.
[0045] The first pressure threshold is greater than the second pressure threshold. The first pressure threshold can be a preset pressure value or a pressure value configured based on configuration commands; this is not limited here. The counting threshold can be a pre-designed value or a count value configured based on configuration commands; this is not limited here either. For example, the counting threshold can be a pre-designed value such as 0 or 1. Specifically, the second pressure threshold, the first pressure threshold, and the counting threshold can be dynamically configured according to the CPU pressure adjustment precision.
[0046] In some application scenarios, the step of determining the target protocol from the preset protocols based on the message processing rate of each preset protocol in the switch includes: in the case where there is no historical CPU pressure greater than or equal to a first pressure threshold and the current CPU pressure is greater than or equal to the first pressure threshold, or in the case where there is at least one historical CPU pressure greater than or equal to the first pressure threshold and the current CPU pressure is greater than or equal to a second pressure threshold, selecting the target protocol from the preset protocols based on the current message processing rate of each preset protocol and the historical message processing rate of the corresponding preset protocol, including: taking the change relationship between the current message processing rate and the historical message processing rate of each preset protocol as the rate change relationship to which the corresponding preset protocol belongs; and taking the preset protocol to which the rate change relationship with the largest change trend belongs as the target protocol.
[0047] In other application scenarios, where at least one historical CPU pressure is greater than or equal to a first pressure threshold and the current CPU pressure is less than a second pressure threshold, and at least one preset protocol has a current packet loss count result greater than a counting threshold, a target protocol is selected from each preset protocol based on the current packet loss count result of each preset protocol, including: for each preset protocol, in response to the current packet loss count result of the preset protocol being greater than the counting threshold, the preset protocol is selected as the target protocol.
[0048] In other application scenarios, the step of determining the target protocol from the preset protocols based on the packet processing rate of each preset protocol in the switch further includes: in cases where there is no historical CPU pressure greater than or equal to a first pressure threshold and the current CPU pressure is greater than or equal to the first pressure threshold, or in cases where at least one historical CPU pressure is greater than or equal to the first pressure threshold and the current CPU pressure is greater than or equal to a second pressure threshold, determining the target protocol from the preset protocols based on the current packet loss count, the current packet processing rate of each preset protocol, and the historical packet processing rate of the corresponding preset protocol, including: setting the current packet processing rate of each preset protocol... The relationship between the rate and the historical packet processing rate is used as the rate change relationship to which the corresponding preset protocol belongs; the preset protocol to which the rate change relationship with the largest change trend belongs is selected as the first candidate protocol; for each preset protocol, in response to the current packet loss count result of the preset protocol being greater than the count threshold, the preset protocol is selected as the second candidate protocol; based on the first and second candidate protocols, the target protocol is determined, including: directly selecting the first and second candidate protocols as the target protocol; or, selecting a preset number of protocols as the target protocol from the first and second candidate protocols based on the process utilization rate of the first and second candidate protocols and / or the process utilization rate and / or queue utilization rate of the second candidate protocols. For example, selecting protocols ranked high in a preset order of process utilization rate and / or queue utilization rate from the first and second candidate protocols as the target protocols.
[0049] Please see Figure 2 , Figure 2 This is a second flowchart illustrating an exemplary embodiment of the CPU pressure adjustment method based on a switch in this application.
[0050] In some embodiments, the step of determining the target protocol from the preset protocols based on the packet processing rate of each preset protocol in the switch may include the following steps: S21: Obtaining a first relationship between the current process utilization rate and the historical process utilization rate of each preset protocol. S22: Determining a second relationship between the current packet processing rate and the historical packet processing rate of each preset protocol. S23: Selecting the target protocol from the preset protocols based on the first and second relationship corresponding to each preset protocol.
[0051] The current process utilization rate is collected at the same time as the current packet processing rate, and the information collection period between the current process utilization rate and the current packet processing rate is the same detection period. The historical process utilization rate is collected at the same time as the historical packet processing rate. The information collection period between the historical process utilization rate and the historical packet processing rate is the same detection period. The current process utilization rate is collected during the current time period. The historical process utilization rate is collected during the historical time period.
[0052] The first change relationship characterizes the trend of process utilization rate of the same preset protocol between the current time period and historical time periods. Current process utilization rate characterizes the percentage of CPU time consumed by the protocol software process corresponding to the preset protocol within the current time period. Historical process utilization rate characterizes the percentage of CPU time consumed by the protocol software process corresponding to the preset protocol within historical time periods. Current packet processing rate characterizes the number of packets uploaded and processed by the protocol queue of the corresponding preset protocol per unit time within the current time period; historical packet processing rate characterizes the number of packets uploaded and processed by the protocol queue of the corresponding preset protocol per unit time within historical time periods. The second change relationship characterizes the trend of packet processing rate of the same preset protocol between the current time period and historical time periods. For example, the second change relationship characterizes the trend of dequeue rate and / or enqueue rate of the same preset protocol between the current time period and historical time periods.
[0053] In some application scenarios, S21 above can be: retrieving the first change relationship between the current process utilization rate and the historical process utilization rate from a preset database; or, generating the first change relationship based on the change relationship between the current process utilization rate and the historical process utilization rate in the time series, including: taking the change relationship between the current process utilization rate and the historical process utilization rate in the time series as the first change relationship.
[0054] In other application scenarios, S22 above may be: retrieving a second change relationship between the current message processing rate and the historical message processing rate from a preset database; or, generating a second change relationship based on the change relationship between the current message processing rate and the historical message processing rate in the time series, including: using the change relationship between the current message processing rate and the historical message processing rate in the time series as the second change relationship.
[0055] In some application scenarios, S23 above can be: selecting the preset protocol to which the change relationship with the largest change trend among the first change relationships belongs as the third candidate protocol; selecting the preset protocol to which the change relationship with the largest change trend among the second change relationships belongs as the fourth candidate protocol; and determining the target protocol based on the third and fourth candidate protocols, including: directly selecting the third and fourth candidate protocols as the target protocol; or, selecting a preset number of protocols as the target protocol from the third and fourth candidate protocols based on the process utilization rate of the third candidate protocol and the process utilization rate and / or queue utilization rate of the fourth candidate protocol. For example, selecting protocols ranked high in a preset order of process utilization rate and / or queue utilization rate from the third and fourth candidate protocols as the target protocol.
[0056] In some embodiments, S23 may include the following steps: For each preset protocol, in response to a positive correlation between the first change relationship and the second change relationship to which the preset protocol belongs, the preset protocol is determined as a first protocol. The slope of the first change relationship to which each first protocol belongs is taken as the first slope corresponding to each protocol, and the slope of the second change relationship to which each first protocol belongs is taken as the second slope corresponding to each protocol. Based on the first slope and / or the second slope corresponding to each first protocol, at least one second protocol is determined from the first protocols. The second protocols are filtered to obtain a target protocol.
[0057] The number of first protocols is at least one. The correspondence represents the synchronous changes between the first and second change relationships of the same preset protocol. A positive correlation indicates synchronous changes between the first and second change relationships of the same preset protocol, for example, synchronous increments. When the correspondence between the first and second change relationships of a preset protocol is positively correlated, the preset protocol is designated as the first protocol. The historical time period includes multiple historical sub-time periods, each of which collects CPU pressure, process utilization of each preset protocol, and packet processing rate. The first protocol represents the preset protocol whose correspondence between the first and second change relationships is positively correlated.
[0058] The slope of the first change relationship represents the magnitude of the trend in process occupancy rate change for the same preset protocol between the current time period and historical time periods. The first change relationship is a process occupancy rate change curve for the same preset protocol across different time periods. The horizontal axis of the process occupancy rate change curve represents each time period, and the vertical axis represents the process occupancy rate of the same preset protocol in each time period. The slope of the first change relationship is obtained by the angle between the horizontal axis and the lines connecting the current process occupancy rate of the same preset protocol to the historical process occupancy rates of at least some historical sub-time periods in the process occupancy rate change curve. If at least some historical sub-time periods are a single historical sub-time period (e.g., the historical sub-time period corresponding to the previous detection cycle of the current time period, or a predetermined number of historical sub-time periods, this is not limited), or if there are multiple historical sub-time periods, the slope of the first change relationship can be obtained using statistical methods such as linear fitting to obtain the slope or the slope of the secant line between the current process occupancy rate and the historical process occupancy rates corresponding to each historical sub-time period in the process occupancy rate change curve, and then calculating the average of the slopes of each secant line. This is also not limited here.
[0059] The slope of the second variation relationship characterizes the magnitude of the trend in message processing rate changes between the current time period and historical time periods for the same preset protocol. The second variation relationship is a message processing rate change curve for the same preset protocol across different time periods, where the horizontal axis of the curve represents each time period, and the vertical axis represents the message processing rate corresponding to the same preset protocol in each time period. The slope of the second variation relationship is obtained based on the angle between the horizontal axis and the lines connecting the current message processing rate of the same preset protocol to the historical message processing rates of at least some historical sub-time periods in the message processing rate change curve. If at least some historical sub-time periods are a single historical sub-time period (e.g., the historical sub-time period corresponding to the previous detection cycle of the current time period, or a predetermined number of historical sub-time periods, this is not limited here), or if there are multiple historical sub-time periods, the slope of the second variation relationship can be obtained using statistical methods such as linear fitting to obtain the slope or the slope of the secant line between the current message processing rate and the historical message processing rate corresponding to each historical sub-time period in the message processing rate change curve, and then calculating the average of the slopes of each secant line. This is also not limited here.
[0060] In some embodiments, the step of determining at least one second protocol from the first protocols based on the first slope and / or second slope corresponding to each first protocol may include the following steps: filtering at least one first sub-protocol from the first protocols based on the comparison relationship between the first slopes corresponding to each first protocol; and / or filtering at least one second sub-protocol from the first protocols based on the comparison relationship between the second slopes corresponding to each first protocol; and obtaining at least one second protocol based on at least one first sub-protocol and / or at least one second sub-protocol.
[0061] The first sub-protocol represents the first protocol obtained by filtering through the first slope in the first change relationship of the corresponding protocol. The second sub-protocol represents the first protocol obtained by filtering through the second slope in the second change relationship of the corresponding protocol.
[0062] In some application scenarios, the comparison relationship between the first slopes corresponding to each first protocol represents the slope ranking among them. The first slopes corresponding to each first protocol are sorted from largest to smallest to obtain the first slope ranking. The first slope ranking that is higher than the preset ranking is taken as the first candidate slope, and the first protocol corresponding to the first candidate slope is taken as the first sub-protocol. Each first sub-protocol is then taken as the second protocol.
[0063] In other application scenarios, the comparison relationship between the second slopes corresponding to each first protocol represents the slope ranking among the second slopes corresponding to each first protocol. The second slopes corresponding to each first protocol are sorted from largest to smallest to obtain the second slope ranking. The second slope that ranks higher than a preset value in the second slope ranking is taken as the second candidate slope, and the first protocol corresponding to the second candidate slope is taken as the second sub-protocol. Each second sub-protocol is then taken as the respective second protocol.
[0064] In other application scenarios, second protocols are derived based on each first sub-protocol and each second sub-protocol. This includes: directly using both the first and second sub-protocols as the second protocols; or selecting a predetermined number of protocols from the first and second sub-protocols as the second protocols based on the process utilization rate of the first sub-protocol and the process utilization rate and / or queue utilization rate of the second sub-protocol. For example, protocols ranked highest in a predetermined order based on process utilization rate and / or queue utilization rate are selected as the second protocols from the first and second sub-protocols.
[0065] In other application scenarios, the first protocol with the largest and positive first slope among all first slopes is selected as the fifth candidate protocol; the first protocol with the largest and positive second slope among all second slopes is selected as the sixth candidate protocol; based on the fifth and sixth candidate protocols, a second protocol is determined, including: directly selecting the fifth and sixth candidate protocols as the second protocol; or, selecting a predetermined number of protocols from the fifth and sixth candidate protocols as the second protocol based on the process utilization rate of the fifth candidate protocol and the process utilization rate and / or queue utilization rate of the sixth candidate protocol. For example, protocols with the highest process utilization rate and / or queue utilization rate are selected from the fifth and sixth candidate protocols as the second protocol.
[0066] In some application scenarios, the above steps of filtering each second protocol to obtain the target protocol include: directly using each second protocol as the target protocol; and selecting one or more protocols from each second protocol by fixed selection, random selection, or round-robin selection as the target protocol.
[0067] In some embodiments, the current message processing rate includes the current enqueue rate and the current dequeue rate of messages in the corresponding preset protocol. The step of filtering each second protocol to obtain the target protocol includes: determining the queue backlog rate of the corresponding second protocol based on the current enqueue rate and the corresponding current dequeue rate of each second protocol; and selecting the target protocol from the second protocols according to the queue backlog rate of each second protocol.
[0068] The current enqueue rate represents the number of packets received in the protocol queue of the preset protocol within a unit of time in the current time period. The current dequeue rate represents the number of packets uploaded in the protocol queue of the preset protocol within a unit of time in the current time period. The queue backlog rate represents the packet backlog situation in the protocol queue of the corresponding protocol in the current time period.
[0069] For each second protocol, based on the current inbound and outbound rates of packets in its protocol queue, the number of cached packets in the corresponding protocol queue is obtained. The ratio between the number of cached packets and the total queue capacity of the corresponding protocol queue is used as the queue backlog rate for that second protocol. The queue backlog rates of all second protocols are sorted from largest to smallest to obtain a queue backlog rate ranking. The queue backlog rate preceding a preset ranking in the queue backlog rate ranking is taken as the target backlog rate, and the second protocol corresponding to the target backlog rate is taken as the target protocol. The preset ranking can be the ranking of the protocol with the largest queue backlog rate. The precision of the preset ranking can be adjusted according to CPU load, allowing for flexible settings.
[0070] Please see Figure 3 , Figure 3 This is a schematic diagram of the third process of an exemplary embodiment of the CPU pressure adjustment method based on a switch in this application.
[0071] In some embodiments, the current message processing rate includes the current dequeue rate of a message in a corresponding preset protocol. S12 may include the following steps: S31: Obtain the target decrement parameter to which the target protocol belongs when adjusting the current dequeue rate of the target protocol. S32: Use the product of the target decrement parameter to which the target protocol belongs and the current dequeue rate of the target protocol as the candidate dequeue rate of the target protocol. S33: Determine the target dequeue rate based on the candidate dequeue rate of the target protocol.
[0072] The current dequeue rate represents the actual average rate at which the protocol software queue of the corresponding preset protocol sends packets to the CPU process within the current time period. The target decrement parameter represents the adjustment parameter for the dequeue rate of the corresponding preset protocol, and is a proportional coefficient used to calculate the new dequeue rate. The candidate dequeue rate represents the dequeue rate obtained by adjusting the current dequeue rate.
[0073] In some application scenarios, S31 above can be: obtaining the preset decrement parameters of each preset protocol; using the preset decrement parameters of the target protocol as the target decrement parameters of the target protocol; or using the historical decrement parameters of the target protocol from the previous adjustment round as the target decrement parameters of the target protocol.
[0074] In some application scenarios, S33 above can be: directly determining the target outgoing rate from the candidate outgoing rates of the target protocol. Alternatively, in response to the candidate outgoing rates of the target protocol meeting the rate limiting protection conditions, determining the target outgoing rate from the candidate outgoing rates of the target protocol.
[0075] In some embodiments, prior to S11, the switch-based CPU stress adjustment method further includes the following steps: receiving parameter configuration instructions for the detection parameters of each preset protocol in the switch; configuring the parameters of each preset protocol according to the parameter configuration instructions to obtain the configured parameters of each preset protocol.
[0076] Parameter configuration instructions represent configuration instructions obtained from the initialization configuration operation for CPU pressure adjustment. For example, the initialization configuration operation can be triggered based on user configuration operations in the configuration interface or automatically triggered after the switch starts. In some application scenarios, parameter configuration instructions are used to configure parameters for each preset protocol to obtain the configured parameters for each preset protocol. This includes: initializing the parameters to be detected for each preset protocol based on parameter configuration instructions to obtain the configured parameters for each preset protocol. Initialization configuration may include configuring a first pressure threshold, a second pressure threshold, the total capacity of the protocol queue for each preset protocol, the duration corresponding to each time period / detection cycle, and preset decrementing parameters when adjusting the dequeue rate of each preset protocol. The configured parameters include the pressure threshold and the preset decrementing parameters when adjusting the dequeue rate of each preset protocol. In other application scenarios, the configured parameters also include the pressure threshold, the total capacity of the protocol queue for each preset protocol, and the duration corresponding to each time period / detection cycle.
[0077] In some embodiments, S31 may include the following step: determining the target decrement parameter based on the preset decrement parameter of the target protocol.
[0078] In some applications, the preset decrement parameter of the target protocol is directly used as the target decrement parameter. In other applications, the decrement parameter determination strategy is based on the adjustment round to which the current time period belongs. If the adjustment round to which the current time period belongs is less than or equal to the round threshold, the preset decrement parameter of the target protocol is used as the target decrement parameter. If the adjustment round to which the detection period belongs is greater than the round threshold, the preset decrement parameter of the target protocol is increased to obtain the target decrement parameter.
[0079] In some embodiments, S33 may include the following steps: In response to a candidate dequeue rate of the target protocol being less than or equal to a dequeue rate threshold to which the target protocol belongs, a default dequeue rate is used as the target dequeue rate of the target protocol. In response to a candidate dequeue rate of the target protocol being greater than a dequeue rate threshold to which the target protocol belongs, a candidate dequeue rate of the target protocol is used as the target dequeue rate of the target protocol.
[0080] The outbound rate threshold represents a preset lower limit for the rate by the switching system based on protocol characteristics, historical performance, and minimum service requirements. It defines the minimum acceptable processing capacity of the protocol. The default outbound rate represents the base rate to which the switch falls back when it determines that the currently calculated rate limit (i.e., the candidate outbound rate) is below the safety threshold. This rate is usually sufficient to maintain the basic communication functions of the protocol and prevent a complete protocol outage. The target outbound rate refers to the rate limit that finally takes effect and is sent to the hardware execution module.
[0081] The dequeue rate threshold is less than or equal to the default dequeue rate. The default dequeue rate can be different for different preset protocols, and this is dynamically set according to the total capacity of the protocol queue for each preset protocol.
[0082] If the candidate dequeue rate of the target protocol is less than or equal to the dequeue rate threshold of the target protocol, the default dequeue rate will be used as the target dequeue rate of the target protocol. If the candidate dequeue rate of the target protocol is greater than the dequeue rate threshold of the target protocol, the candidate dequeue rate will be used as the target dequeue rate of the target protocol.
[0083] It can be assumed that by introducing a dequeue rate threshold and a default dequeue rate, a secondary verification of the candidate dequeue rate can be performed to prevent protocol messages from becoming unprocessable due to excessive speed reduction.
[0084] For example, the switch includes a performance monitoring module, a decision analysis module, an execution module, and a monitoring module.
[0085] Specifically, the performance monitoring module processing flow includes: acquiring CPU pressure and protocol queue information of each preset protocol in real time during each detection cycle / period, and recording and caching the relevant information. The CPU pressure includes the overall CPU pressure and the CPU utilization rate of the protocol process, and the protocol queue information includes the protocol upload rate (i.e. the dequeue rate in the message processing rate) and the queue packet loss rate (i.e. the packet loss count result).
[0086] Specifically, the decision analysis module acquires the current CPU pressure for the current time period, continuously monitors CPU pressure, and when the current CPU pressure has not exceeded the first pressure threshold for several historical periods, and is detected for the first time that the current CPU pressure exceeds the preset first pressure threshold (high pressure threshold, such as 90%), or when the current CPU pressure is detected to be greater than or equal to the first pressure threshold on a subsequent basis, only if the current CPU pressure is greater than or equal to the second pressure threshold (safety threshold, such as 70%), the system enters a macro-control mode to prioritize ensuring device survival. The macro-control mode includes: the switch further analyzes the CPU utilization rate (i.e., process utilization rate) of each preset protocol service process and the enqueue rate of each protocol queue, combining historical CPU pressure and historical information of the protocol queues (including historical packet processing rates) acquired during historical detection cycles / time periods to identify hot protocols (i.e., target protocols) with high CPU utilization due to the large number of packets received by that protocol process. If the default protocol is STP, and historical STP data shows a dequeue rate of 10 PPS with only 5% process utilization, and current STP data shows a dequeue rate of 100 PPS with 40% process utilization, then this STP protocol is identified as the target protocol (i.e., the hotspot protocol) due to its excessively high packet upload rate. For this target protocol, ACL (Access Control List) rules are exchanged or other rate-limiting mechanisms are used to reduce its upload rate to the CPU, effectively slowing down its current dequeue rate to achieve the target dequeue rate. Specifically, the new rate limit is equal to the product of the current rate limit and the target reduction parameter. The current rate limit is the current dequeue rate. The target reduction parameter is the difference between 1 and the user-preset reduction ratio. For example, if the user-preset reduction ratio is 20%, the new dequeue rate (i.e., the target dequeue rate) is 80% of the current dequeue rate. The switch continuously monitors CPU pressure and repeats the above steps until the CPU pressure falls below a preset second pressure threshold (a safety threshold, such as 70%). If, after a non-first detection of CPU pressure greater than or equal to the first pressure threshold (i.e., at least one historical CPU pressure exceeds the first pressure threshold), the switch determines that the current CPU pressure is less than the second pressure threshold (a safety threshold, such as 70%) and that at least one preset protocol is experiencing packet loss. It then obtains the packet loss count for the protocol software queues of each preset protocol and enters a micro-control mode to optimize protocol processing performance. If packet loss is detected in the protocol queue during the monitoring period, it indicates that the current preset protocol process is processing too slowly, causing queue backlog and resulting in packet loss. For each preset protocol experiencing packet loss, it is designated as the target protocol for the next monitoring period or time period. The switch adjusts its corresponding ACL rules or rate limiting mechanism to appropriately reduce the rate at which it sends data to the CPU (i.e., slowing down the dequeue rate of the target protocol to obtain the target dequeue rate).In some application scenarios, the new rate limit is equal to the product of the current rate limit and the target decrement parameter. The current rate limit is the current outbound rate. The target decrement parameter is equal to the difference between 1 and the user-preset growth rate. For example, if the user-preset decrement rate is 20%, then the new rate is 80% of the current rate. The switch continuously monitors the queue packet loss and repeats the above steps until the protocol queue no longer experiences packet loss. In other application scenarios, if there is packet loss for at least one preset protocol, the estimated outbound rate of the protocol queue for that preset protocol can be re-collected / estimated and used as the current rate limit for that preset protocol. For example, the product of the target decrement parameter of the target protocol and the estimated outbound rate of the target protocol can be used as the candidate outbound rate of the target protocol. If the candidate outbound rate meets the protocol's anti-interruption protection, it can be used as the target outbound rate.
[0087] The execution module is used to issue or update ACL rules to the switching chip according to the instructions of the decision analysis module, so as to achieve precise control / rate limiting of the specified protocol message rate.
[0088] For example, if the switch detects that there is no historical CPU pressure greater than or equal to a first pressure threshold among a number of historical CPU pressures and the current CPU pressure is greater than or equal to the first pressure threshold, or if the switch detects that there is no historical CPU pressure greater than or equal to the first pressure threshold among a number of historical CPU pressures and the current CPU pressure is greater than or equal to the first pressure threshold, a target protocol is determined from each preset protocol using a first preset strategy. For this target protocol, the switch issues an ACL (Access Control List) rule or uses other rate-limiting mechanisms. The current outbound rate of the target protocol is slowed down to obtain the target outbound rate, which is then monitored by the monitoring module to execute the above-described S13. The first preset strategy can be the steps described above for determining the target protocol from each preset protocol based on the packet processing rate of each preset protocol in the switch, and their specific steps. In other application scenarios, where at least one historical CPU pressure is greater than or equal to a first pressure threshold and the current CPU pressure is less than a second pressure threshold, and at least one preset protocol has a current packet loss count greater than a count threshold, a target protocol is determined from the preset protocols using a second preset strategy. For this target protocol, an ACL (Access Control List) rule is issued by the switch or other rate-limiting mechanisms are used. The current outbound rate of the target protocol is slowed down to obtain the target outbound rate, which is then monitored by the monitoring module to execute the above-described S13. The second preset strategy can be the steps described above for determining the target protocol from the preset protocols based on their current packet loss counts, and their specific steps.
[0089] This application combines the current CPU pressure of the queuing protocol with the current and historical queue information of each preset protocol's protocol queue. By filtering out the hot protocols currently affecting CPU resource consumption—the target protocols—it precisely controls the message upload rate of the target protocols to reduce CPU consumption. Furthermore, this application introduces a dual-factor approach of CPU pressure and queue packet loss, achieving a combination of macro and micro-level control. Macro-level control can precisely limit the dequeue rate of target protocols, avoiding rate limiting for all preset protocols. Micro-level control can promptly identify target protocols that require rate limiting due to protocol process processing capacity issues, further reducing unnecessary CPU consumption.
[0090] The above scheme identifies the target protocol from among the preset protocols by using historical CPU pressure, current CPU pressure, pressure threshold, current packet loss count, and packet processing rate of each preset protocol in the switch. It can accurately identify specific protocols causing CPU overload or performance bottlenecks by leveraging the relationship between historical CPU pressure, current CPU pressure, and pressure threshold. Combined with CPU pressure, packet loss count, and packet processing rate, it achieves target protocol filtering. Subsequently, it adjusts the current packet processing rate of the target protocol to achieve fine-grained control of packets within specific protocols, reducing the packet load sent to the CPU and effectively alleviating high CPU load. During the process of controlling the target protocol to process packets at the adjusted rate, if it detects that the target CPU pressure is below the second pressure threshold and no target packet loss count for any preset protocol is above the threshold, the CPU pressure adjustment ends. This ensures a stable packet processing rate after the CPU load recovers to a safe level, avoiding resource waste or service interruption caused by continuous over-adjustment of protocol packet processing rates, and achieving a balance between adaptive CPU pressure adjustment and stable service operation.
[0091] Please see Figure 4 , Figure 4This is a schematic diagram of an embodiment of the CPU pressure adjustment device based on a switch according to this application. The CPU pressure adjustment device 40 based on a switch includes a determining module 41, an adjusting module 42, and a detecting module 43. The determining module 41 is used to determine a target protocol from the preset protocols based on several historical CPU pressures, current CPU pressures, pressure thresholds, current packet loss counts of each preset protocol in the switch, and the message processing rate of each preset protocol. The historical CPU pressures are collected earlier than the current CPU pressures. The pressure thresholds include a first pressure threshold and a second pressure threshold, the first pressure threshold being greater than the second pressure threshold. The message processing rate includes the current message processing rate of the corresponding preset protocol. The adjusting module 42 is used to adjust the current message processing rate of the target protocol to obtain a target message processing rate. The detecting module 43 is used to terminate the CPU pressure adjustment if, during the process of controlling the target protocol to process messages at the target message processing rate for a preset period, the target CPU pressure is detected to be less than the second pressure threshold and the target packet loss count of each preset protocol is not greater than the count threshold within the preset period.
[0092] For details on the functions performed by each module, please refer to the CPU stress adjustment method based on the switch; these details will not be repeated here.
[0093] The above scheme identifies the target protocol from among the preset protocols by using historical CPU pressure, current CPU pressure, pressure threshold, current packet loss count, and packet processing rate of each preset protocol in the switch. It can accurately identify specific protocols causing CPU overload or performance bottlenecks by leveraging the relationship between historical CPU pressure, current CPU pressure, and pressure threshold. Combined with CPU pressure, packet loss count, and packet processing rate, it achieves target protocol filtering. Subsequently, it adjusts the current packet processing rate of the target protocol to achieve fine-grained control of packets within specific protocols, reducing the packet load sent to the CPU and effectively alleviating high CPU load. During the process of controlling the target protocol to process packets at the adjusted rate, if it detects that the target CPU pressure is below the second pressure threshold and no target packet loss count for any preset protocol is above the threshold, the CPU pressure adjustment ends. This ensures a stable packet processing rate after the CPU load recovers to a safe level, avoiding resource waste or service interruption caused by continuous over-adjustment of protocol packet processing rates, and achieving a balance between adaptive CPU pressure adjustment and stable service operation.
[0094] Please see Figure 5 , Figure 5This is a schematic diagram of the structure of an embodiment of the electronic device of this application. The electronic device 50 includes a memory 51 and a processor 52. The processor 52 is used to execute program instructions stored in the memory 51 to implement the steps in the above-described embodiment of the CPU pressure adjustment method based on a switch. In a specific implementation scenario, the electronic device 50 may include, but is not limited to, a microcomputer or a server. In addition, the electronic device 50 may also include mobile devices such as laptops and tablets, which are not limited here.
[0095] Specifically, processor 52 controls itself and memory 51 to implement the steps in the above-described embodiment of the switch-based CPU stress adjustment method. Processor 52 can also be called a CPU (Central Processing Unit). Processor 52 may be an integrated circuit chip with signal processing capabilities. Processor 52 can also be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor. Furthermore, processor 52 can be implemented using integrated circuit chips.
[0096] The above scheme identifies the target protocol from among the preset protocols by using historical CPU pressure, current CPU pressure, pressure threshold, current packet loss count, and packet processing rate of each preset protocol in the switch. It can accurately identify specific protocols causing CPU overload or performance bottlenecks by leveraging the relationship between historical CPU pressure, current CPU pressure, and pressure threshold. Combined with CPU pressure, packet loss count, and packet processing rate, it achieves target protocol filtering. Subsequently, it adjusts the current packet processing rate of the target protocol to achieve fine-grained control of packets within specific protocols, reducing the packet load sent to the CPU and effectively alleviating high CPU load. During the process of controlling the target protocol to process packets at the adjusted rate, if it detects that the target CPU pressure is below the second pressure threshold and no target packet loss count for any preset protocol is above the threshold, the CPU pressure adjustment ends. This ensures a stable packet processing rate after the CPU load recovers to a safe level, avoiding resource waste or service interruption caused by continuous over-adjustment of protocol packet processing rates, and achieving a balance between adaptive CPU pressure adjustment and stable service operation.
[0097] Please see Figure 6 , Figure 6 This is a schematic diagram of a computer-readable storage medium according to an embodiment of the present application. The computer-readable storage medium 60 stores program instructions 601 thereon, which, when executed by a processor, implement the steps in any of the above embodiments of the switch-based CPU stress adjustment method.
[0098] The above solution determines the target protocol based on the current packet loss count and packet processing rate of each preset protocol when the current CPU pressure of the switch is greater than or equal to a first pressure threshold. It can accurately identify the specific protocol that causes CPU overload or performance bottlenecks by triggering the current CPU pressure. Subsequently, it adjusts the current packet processing rate of the target protocol to achieve fine-grained control of packets in specific protocols, thereby reducing the packet load sent to the CPU and effectively alleviating the high CPU load. During the process of controlling the target protocol to process packets at the adjusted rate, if the target CPU pressure is detected to be less than the first pressure threshold, the adjustment ends. This allows a stable packet processing rate to be maintained after the CPU load recovers to a safe level, avoiding resource waste or service interruption caused by continuous over-adjustment of the protocol's packet processing rate. It achieves a balance between adaptive CPU pressure adjustment and stable service operation.
[0099] In some embodiments, the functions or modules of the apparatus provided in this disclosure can be used to perform the methods described in the above method embodiments. The specific implementation can be referred to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0100] The description of the various embodiments above tends to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.
[0101] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus implementations described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.
[0102] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0103] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0104] If the technical solution of this application involves personal information, the product using this technical solution has clearly informed the user of the personal information processing rules and obtained the user's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using this technical solution has obtained the user's separate consent before processing the sensitive personal information, and also meets the requirement of "express consent". For example, at personal information collection devices such as cameras, clear and prominent signs are set up to inform users that they have entered the scope of personal information collection and that personal information will be collected. If an individual voluntarily enters the collection scope, it is deemed that they have agreed to the collection of their personal information; or on the personal information processing device, with clear signs / information informing users of the personal information processing rules, authorization is obtained from the individual through pop-up information or by asking the individual to upload their personal information; wherein, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the types of personal information processed.
Claims
1. A CPU stress adjustment method based on a switch, characterized in that, The method includes: Based on several historical CPU pressures, current CPU pressures, pressure thresholds, current packet loss counts of each preset protocol in the switch, and the message processing rate of each preset protocol, a target protocol is determined from the preset protocols. The historical CPU pressures are collected earlier than the current CPU pressures. The pressure thresholds include a first pressure threshold and a second pressure threshold, where the first pressure threshold is greater than the second pressure threshold. The message processing rate includes the current message processing rate of the corresponding preset protocol. The current message processing rate of the target protocol is adjusted to obtain the target message processing rate; During the process of controlling the target protocol to process packets at the target packet processing rate for a preset period of time, if it is detected that the target CPU pressure is less than the second pressure threshold and there is no target packet loss count result of each preset protocol that is greater than the count threshold within the preset period of time, the CPU pressure adjustment ends.
2. The method according to claim 1, characterized in that, The step of determining the target protocol from the preset protocols based on several historical CPU pressures, current CPU pressures, pressure thresholds, current packet loss counts of each preset protocol in the switch, and the message processing rate of each preset protocol includes: In response to the condition that none of the historical CPU pressures are greater than or equal to the first pressure threshold and the current CPU pressure is greater than or equal to the first pressure threshold, a target protocol is determined from each preset protocol based on the packet processing rate of each preset protocol in the switch; or, In response to the condition that at least one historical CPU pressure is greater than or equal to the first pressure threshold and the current CPU pressure is greater than or equal to the second pressure threshold, a target protocol is determined from each preset protocol according to the packet processing rate of each preset protocol in the switch; or, In response to the existence of at least one historical CPU pressure greater than or equal to the first pressure threshold and the current CPU pressure less than the second pressure threshold, and the existence of at least one preset protocol whose current packet loss count is greater than the count threshold, a target protocol is determined from each preset protocol based on the current packet loss count of each preset protocol in the switch.
3. The method according to claim 2, characterized in that, The message processing rate also includes the historical message processing rate corresponding to the preset protocol, and the acquisition time of the historical message processing rate is earlier than the acquisition time of the current message processing rate. The step of determining the target protocol from the preset protocols based on the message processing rate of each preset protocol in the switch includes: Obtain the first change relationship between the current process utilization rate and the historical process utilization rate of each preset protocol, wherein the current process utilization rate is collected at the same time as the current message processing rate, and the historical process utilization rate is collected at the same time as the historical message processing rate. Determine the second relationship between the current message processing rate and the historical message processing rate of each preset protocol; The target protocol is obtained by filtering from the preset protocols based on the first and second change relationships corresponding to each preset protocol.
4. The method according to claim 3, characterized in that, The step of selecting the target protocol from the preset protocols based on the first and second change relationships corresponding to each preset protocol includes: For each of the preset protocols, in response to the positive correlation between the first change relationship and the second change relationship to which the preset protocol belongs, the preset protocol is determined as a first protocol, and the number of first protocols is at least one. The slope of the first change relationship to which each first protocol belongs is taken as the first slope corresponding to each protocol, and the slope of the second change relationship to which each first protocol belongs is taken as the second slope corresponding to each protocol. Based on the first slope and / or second slope corresponding to each first protocol, at least one second protocol is determined from each first protocol; The target protocol is obtained by filtering each of the second protocols.
5. The method according to claim 4, characterized in that, The current message processing rate includes the current enqueue rate and the current dequeue rate of the message in the corresponding preset protocol; The step of filtering each second protocol to obtain the target protocol includes: Based on the current enqueue rate and the corresponding current dequeue rate of each second protocol, determine the queue backlog rate of the corresponding second protocol; The target protocol is selected from the second protocols based on the queue backlog rate of each second protocol.
6. The method according to claim 4, characterized in that, The step of determining at least one second protocol from the first protocols based on the first slope and / or second slope corresponding to each first protocol includes: Based on the comparison relationship between the first slopes corresponding to each first protocol, at least one first sub-protocol is selected from each first protocol; and / or, Based on the comparison relationship between the second slopes corresponding to each first protocol, at least one second sub-protocol is selected from each first protocol; The at least one second protocol is obtained based on the at least one first sub-protocol and / or the at least one second sub-protocol.
7. The method according to claim 1, characterized in that, The current message processing rate includes the current dequeue rate of the message in the corresponding preset protocol; The step of adjusting the current message processing rate of the target protocol to obtain the target message processing rate includes: Obtain the target decrement parameter to which the target protocol belongs when adjusting the current dequeue rate of the target protocol; The product of the target decrement parameter to which the target protocol belongs and the current dequeue rate of the target protocol is used as the candidate dequeue rate of the target protocol. The target dequeue rate is determined based on the candidate dequeue rates of the target protocol.
8. The method according to claim 7, characterized in that, The step of determining the target dequeue rate based on the candidate dequeue rates of the target protocol includes: In response to the fact that the candidate dequeue rate of the target protocol is less than or equal to the dequeue rate threshold of the target protocol, the default dequeue rate is taken as the target dequeue rate of the target protocol. In response to the fact that the candidate dequeue rate of the target protocol is greater than the dequeue rate threshold to which the target protocol belongs, the candidate dequeue rate of the target protocol is taken as the target dequeue rate of the target protocol.
9. The method according to claim 7, characterized in that, Before the step of determining the target protocol from the preset protocols based on several historical CPU pressures, current CPU pressures, pressure thresholds, current packet loss counts of each preset protocol in the switch, and the message processing rate of each preset protocol, the method further includes: Receive parameter configuration instructions for the detection parameters of each preset protocol in the switch; The parameters of each preset protocol are configured according to the parameter configuration instructions to obtain the configured parameters of each preset protocol. The configured parameters include the pressure threshold and the preset decreasing parameters when adjusting the outbound rate of each preset protocol. The step of obtaining the target decrement parameter of the target protocol when adjusting the current dequeue rate of the target protocol includes: The target decrement parameter is determined based on the preset decrement parameter of the target protocol.
10. An electronic device, characterized in that, include: A memory and a processor, wherein the memory stores program instructions, and the processor retrieves the program instructions from the memory to perform the method as claimed in any one of claims 1-9.
11. A computer-readable storage medium having program instructions stored thereon, characterized in that, When the program instructions are executed by the processor, they are used to implement the method as described in any one of claims 1-9.
