Self-adaptive thread pool optimization method and system based on real-time task flow closed-loop control
Through the closed-loop control mechanism and dual closed-loop algorithm based on real-time task traffic, the traditional thread pool technology has solved the lack of dynamic regulation capabilities and resource efficiency, and the adaptive optimization of thread pool is realized, and the stability and response speed of the system are improved.
Patent Information
- Application Number
- CN202510634837.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-16
- Publication Date
- 2025-08-08
AI Technical Summary
Traditional thread pooling technology has shortcomings in dynamic adjustment capabilities, resource energy efficiency and adjustment accuracy, resulting in low efficiency and poor stability in the face of complex and changing task scenarios, and cannot meet the requirements of modern software systems for real-time and flexibility.
The closed-loop control mechanism based on real-time task flow is adopted, combined with the dual closed-loop control algorithm of buffer pool liquid level and core worker threads, and adaptive dynamic adjustment of thread pool is achieved through the information perception module, PID controller and lightweight task flow evaluation algorithm.
It realizes rapid and accurate dynamic adjustment of thread pools when facing frequent fluctuations in task traffic, ensures that the system is in a stable and efficient operation state, improves user experience and overall performance, and meets the requirements of modern software systems for efficiency, stability and real-time.
Smart Images

Figure CN120448127A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of thread pools, and in particular to an adaptive thread pool optimization method and system based on real-time task flow closed-loop control. Background Art
[0002] With the rapid development of information technology, the application scenarios of software systems are becoming increasingly complex and diverse, and efficient and accurate task processing has become a key requirement. Thread pool technology, as an indispensable task management tool in modern software systems, is core to its value by effectively reusing thread resources, minimizing the overhead associated with thread creation and destruction, thereby improving overall system performance and resource utilization. It plays a crucial cornerstone role in numerous software system application scenarios. However, a closer look at the current performance of thread pool technology in actual applications, especially when dealing with complex, changing, and uncertain task loads, reveals three key issues that are significant and urgently need to be addressed.
[0003] First, traditional thread pool technology is often configured at system startup, lacking the ability to dynamically adjust to changing task scenarios. The adjustment process often relies heavily on the implementer's experience and empirical formulas, significantly compromising accuracy and making it difficult to achieve optimal results. For example, when faced with a sudden increase or decrease in task traffic, the inability to accurately and dynamically adjust based on actual conditions can lead to irrational thread resource allocation, impacting the overall system's task processing efficiency and response speed, and failing to meet the real-time and flexibility requirements of modern software systems.
[0004] Secondly, while some adaptive thread pools with dynamic adjustment capabilities have emerged on the market, most of them utilize complex adjustment mechanisms such as neural networks and machine learning. While these designs achieve dynamic adjustment to a certain extent, they suffer from over-engineering and are quite cumbersome. For example, during the operation of some adaptive thread pools, simply monitoring task traffic and allocating thread resources requires continuous and complex data calculations, as well as frequent detection, recording, and prediction of system status. This resource consumption model is unsustainable for system environments with relatively limited computing and storage resources, such as small servers, mobile devices, and industrial control systems with strict real-time requirements and limited resource availability. When hosting such adaptive thread pools, these systems are easily overwhelmed by excessive resource usage, even experiencing frequent system freezes and crashes, significantly reducing system stability, reliability, and versatility. This runs counter to the original design objectives of thread pools, which were to conserve system resources and improve system responsiveness, making them unsuitable for practical applications.
[0005] Third, existing thread pool adjustment methods typically simply adjust the number of threads by comparing the difference between the ideal and actual thread counts. This crude and simplistic approach has serious deficiencies in terms of control speed, real-time performance, stability, and effectiveness. On the one hand, when faced with complex, ever-changing, and irregular task traffic patterns, the simplicity of the adjustment logic results in slow control speed and real-time performance during actual adjustments. When task traffic suddenly fluctuates significantly, this lagging adjustment mechanism is unable to capture the change signal in a timely manner and respond effectively, making it impossible to quickly and accurately increase or decrease the number of threads. This forces a large number of tasks to wait in the queue for a long time, significantly extending the average response time of tasks and severely weakening the system's response speed and overall efficiency. On the other hand, in scenarios where task traffic frequently changes, over- or under-adjustment is very likely to occur, resulting in low system stability. For example, when task traffic experiences a brief, sharp surge followed by a rapid decline, the system may blindly over-increase the number of threads due to its lack of accurate traffic perception and adaptive adjustment capabilities, leading to a serious waste of system resources. Alternatively, the system may fail to promptly and sensitively detect the change and reduce the number of threads when traffic declines, causing the system to operate under high load for extended periods, making it difficult to maintain a stable and efficient operating equilibrium and exhibiting poor stability and robustness. In contrast, thread control adjustments determined by closed-loop PID control based on real-time task traffic data can more quickly and accurately dynamically adjust the thread pool, effectively improving the system's stability and real-time performance and achieving better task processing results. However, this advanced control method has not yet been applied in existing thread pool technologies.
[0006] In summary, the current thread pool technology has obvious defects in dynamism, lightweight and efficiency, and a new solution is urgently needed. Summary of the Invention
[0007] In response to the above-mentioned problems in the prior art, the present invention provides an adaptive thread pool optimization method and system based on real-time task traffic closed-loop control, which effectively solves the problems existing in traditional thread pool technology in dynamic adjustment capability, resource energy efficiency and adjustment accuracy, and realizes efficient, stable and adaptive operation of the thread pool.
[0008] To achieve the above objectives, the present invention proposes an adaptive thread pool optimization method and system based on real-time task traffic closed-loop control, comprising:
[0009] S1. Adopt the closed-loop feedback control mechanism in control theory, form feedback variables by monitoring the key indicators of the thread pool, and dynamically adjust the thread pool;
[0010] S2. A dual closed-loop control algorithm combining the buffer pool level and the core working thread, including an outer loop - task flow level control closed loop and an inner loop - task calculation flow opening control closed loop, achieves dynamic adjustment of the working state of the adaptive thread pool object through two serial control closed loops;
[0011] S3. Use a lightweight task traffic evaluation algorithm to evaluate traffic through sampling delay calculation, consider the system's response delay and inertia to the input signal, smooth the traffic representation, and obtain the true situation of the thread pool.
[0012] Preferably, the closed-loop feedback control mechanism is specifically as follows: using an information perception module to collect key information of the thread pool, using a closed-loop controller to calculate the control quantity based on the deviation between the actual flow and the state of the thread itself, combined with a PID control algorithm, and constraining the control quantity based on specific container environment information. The controlled object thread pool adjusts the actual working state according to the control quantity calculated by the controller, and dynamically adds or destroys working threads.
[0013] Preferably, the key information of the thread pool includes task traffic, task consumption traffic, and computing container operating environment information.
[0014] Preferably, in the dual closed-loop control algorithm, the working process of the outer loop-task flow and liquid level control closed loop is to input the set task pool liquid level size, monitor the actual liquid level, the PID controller calculates the adjustment amount according to the deviation, and limits the adjustment amount threshold so that all the final task messages are consumed.
[0015] Preferably, in the dual closed-loop control algorithm, the working process of the inner loop-task calculation flow opening control closed loop is to accept the adjustment quantity instruction transmitted by the outer loop, perform PID control calculation based on the flow opening deviation, obtain the appropriate working thread number adjustment control quantity, and limit the adjustment quantity threshold so that the thread pool task consumption speed matches the task inflow speed.
[0016] Preferably, in the dual closed-loop control algorithm, the adaptive thread pool object working state change process is divided into a task inflow initial stage, a task rate adjustment period, a task inflow rate following period, a task flow rate change period and a task flow rate end stage.
[0017] Preferably, in the dual closed-loop control algorithm, dual closed-loop control is used to perform dynamic adjustment of data collection and state perception, control quantity calculation and adaptive adjustment at different stages of the working state change process of the adaptive thread pool object.
[0018] Preferably, the calculation formula for the task flow value of the flow evaluation using sampling time lag calculation is:
[0019] Y=(1-τ)*Yold+τ*Ynew;
[0020] Where Y represents the calculated flow, Yold represents the flow at the previous moment, Ynew represents the current actual task inflow speed, and τ represents the time lag coefficient.
[0021] An adaptive thread pool optimization system based on real-time task flow closed-loop control is characterized by comprising: an information perception module, a PID controller based on task flow, a controlled object thread pool, a closed-loop control module and a task flow evaluation module; the information perception module is composed of a task flow perception unit, a task consumption flow perception unit and a computing container operating environment unit; the task flow-based PID controller internally uses a task queue and a worker thread dual closed-loop control algorithm based on task flow; the controlled object thread pool adjusts the actual working state according to the control quantity calculated by the controller, and dynamically adds or destroys worker threads; the closed-loop control module is used for the control logic of the outer loop - task flow level control closed loop and the inner loop - task calculation flow opening control closed loop; the task flow evaluation module uses sampling time lag calculation to evaluate the flow, and calculates the task flow value at the current moment through a formula.
[0022] Preferably, the workflow of the system includes:
[0023] Step 1: Task entry and status update: When a task to be consumed enters the thread pool, the worker thread in the thread pool calculates the consumption of the task and updates the thread pool status information. This process calculates the inflow and outflow of task consumption data per unit time, obtains actual traffic characteristics, and perceives the key parameters of the controlled object thread pool.
[0024] Step 2: Calculation of control quantity: The closed-loop controller calculates the control quantity based on the deviation between the actual flow and the state of the thread itself, combined with the PID control algorithm, and outputs the control quantity;
[0025] Step 3: Control quantity constraint: The controller senses the container environment information of the system operation, constrains the control quantity based on the specific container environment information, and then outputs it to the controlled object;
[0026] Step 4: Thread pool state adjustment: The thread pool of the controlled object adjusts the actual working state according to the control quantity calculated by the controller, and dynamically adds or destroys working threads.
[0027] Therefore, the present invention proposes an adaptive thread pool optimization method and system based on real-time task flow closed-loop control, which has the following beneficial effects:
[0028] By innovatively applying the closed-loop feedback control mechanism and traffic-aware methods from control theory to the dynamic adjustment of thread pools, we can quickly and accurately make dynamic adjustments in the face of frequent fluctuations in task traffic, effectively preventing over-adjustment and under-adjustment, ensuring that the thread pool always maintains a stable and efficient operating state, and can closely follow the changing rhythm of task traffic in real time, providing a stable, reliable, and efficient execution environment for various tasks, greatly improving the user experience and the overall performance of the system, and fully meeting the higher requirements of modern complex software systems for thread pool technology in terms of efficiency, stability, accuracy, and real-time performance. This successfully solves the above-mentioned current problems, fills the gaps in existing technologies, and provides strong support for the efficient and stable operation of software systems.
[0029] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 It is the overall system diagram of the present invention;
[0031] Figure 2 It is a system workflow diagram of the present invention;
[0032] Figure 3 Schematic diagram of the adaptive thread pool principle and control model based on real-time task flow closed-loop control of the present invention;
[0033] Figure 4 It is a schematic diagram of the working state change process of the adaptive thread pool object of the present invention. DETAILED DESCRIPTION
[0034] To make the technical solutions, advantages, and purposes of the present invention more clear, the technical solutions of the embodiments of the present invention will be clearly and completely described below. The described embodiments are part of the embodiments of the present invention, not all of them. Based on the described embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0035] Unless otherwise defined, technical or scientific terms used in the present invention shall have the same meaning as commonly understood by one of ordinary skill in the art to which the present invention belongs.
[0036] like Figure 1 As shown, an adaptive thread pool optimization system based on real-time task flow closed-loop control includes: an information perception module, a PID controller based on task flow, a controlled object thread pool, a loop control module and a task flow evaluation module.
[0037] The information perception module is mainly responsible for collecting some key information of the thread pool controller and providing accurate control variables and perception capabilities for the entire control system. It consists of a task flow perception unit, a task consumption flow perception unit, and a computing container operating environment unit. Through the cooperation of various modules, efficient adaptive control of the thread pool and dynamic adjustment based on task flow can be achieved.
[0038] The task flow perception unit and the task consumption flow perception unit smooth the flow data within a certain time range through a first-order time lag link to remove noise interference and accurately obtain the changing trends of task flow and consumption flow.
[0039] The computing container operating environment unit mainly provides container environment information for thread pool operation, including CPU core utilization, number of CPU cores, available memory capacity, and memory pressure information. It provides the controller with adaptive capabilities that change with the operating environment and improves the robustness of thread pool operation.
[0040] The PID controller based on task flow is the core component of the adaptive thread pool that implements task flow following. It internally uses a dual closed-loop control algorithm of task queue and worker thread based on task flow.
[0041] The controlled object thread pool achieves adaptive adjustment based on task traffic by adjusting the number of active threads and the size of the cache queue. The number of active threads and the size of the cache queue are two important control variables and control indicators, which are the key to achieving adaptive thread dynamic adjustment.
[0042] The thread pool of the controlled object adjusts the actual working state according to the control quantity calculated by the controller, and dynamically adds or destroys working threads.
[0043] The thread pool object closed-loop control module is used for the control logic of the outer loop-task flow and liquid level control closed loop and the inner loop-task calculation flow opening control closed loop.
[0044] The thread pool object closed-loop control module completes the closed-loop feedback control of the thread pool object. This module uses a dual closed-loop control algorithm based on task queues and worker threads based on task flow, completing the feedback loop construction of the entire system.
[0045] At fixed time intervals (usually 1000-10000 milliseconds), the system obtains key indicator data representing the thread pool from the information perception module and the thread pool module with a cache queue, including the number of tasks in the task queue, the number of working threads, the average task consumption time, etc. This data is then input into the control algorithm of the controller module, which compares the obtained indicator data with the preset target value and calculates the control quantity to adjust the parameters of the thread pool, such as thread creation and destruction, the maximum length of the task queue, etc. The control quantity is then output under the constraints of the container operating environment. The task traffic evaluation module uses sampling time lag calculation to evaluate the traffic, and calculates the task traffic value at the current moment through a formula.
[0046] The system's workflow includes:
[0047] Step 1: Task entry and status update: When a task to be consumed enters the thread pool, the worker thread in the thread pool calculates the consumption of the task and updates the thread pool status information. This process calculates the inflow and outflow of task consumption data per unit time, obtains actual traffic characteristics, and perceives the key parameters of the controlled object thread pool.
[0048] Step 2: Calculation of control quantity: The closed-loop controller calculates the control quantity based on the deviation between the actual flow and the state of the thread itself, combined with the PID control algorithm, and outputs the control quantity;
[0049] Step 3: Control quantity constraint: The controller senses the container environment information of the system operation, constrains the control quantity based on the specific container environment information, and then outputs it to the controlled object;
[0050] Step 4: Thread pool state adjustment: The thread pool of the controlled object adjusts the actual working state according to the control quantity calculated by the controller, and dynamically adds or destroys working threads.
[0051] like Figure 3 As shown, the present invention provides an adaptive thread pool optimization method based on real-time task flow closed-loop control, comprising:
[0052] S1. Adopt the closed-loop feedback control mechanism in control theory, form feedback variables by monitoring the key indicators of the thread pool, and dynamically adjust the thread pool;
[0053] S2. A dual closed-loop control algorithm combining the buffer pool level and the core working thread, including an outer loop - task flow level control closed loop and an inner loop - task calculation flow opening control closed loop, achieves dynamic adjustment of the working state of the adaptive thread pool object through two serial control closed loops;
[0054] S3. Use a lightweight task traffic evaluation algorithm to evaluate traffic through sampling delay calculation, consider the system's response delay and inertia to the input signal, smooth the traffic representation, and obtain the true situation of the thread pool.
[0055] In S1, the closed-loop feedback control mechanism is specifically as follows: using the information perception module to collect key information of the thread pool, including task flow, task consumption flow, and computing container operating environment information, using the closed-loop controller based on the deviation between the actual flow and the thread state itself, combined with the PID control algorithm to calculate the control quantity, and constraining the control quantity according to the specific container environment information. The controlled object thread pool adjusts the actual working state according to the control quantity calculated by the controller, and dynamically adds or destroys working threads.
[0056] In S2, the task queue cache calculation task quantity of the dual closed-loop control algorithm combining the buffer pool liquid level and the core working thread is converted into the liquid level of the task buffer pool through certain operation rules, and the rate at which the core thread of the thread pool consumes tasks is converted into the task flow calculation flow opening through certain operation rules.
[0057] In the dual closed-loop control algorithm, the outer loop - task flow and level control closed loop is used to ensure that all final task messages are consumed. Its working process is as follows:
[0058] First, enter a set task pool level, usually 0, indicating that the thread pool task queue is empty and there is no task backlog in the ideal state. The actual task pool level corresponds to the number of tasks in the thread pool task queue. When tasks enter the thread pool but are not processed, the actual level will rise.
[0059] When the actual liquid level is not zero, the outer loop PID controller starts to work. The PID controller calculates the deviation between the current actual liquid level and the set liquid level (0). The PID algorithm comprehensively considers the proportional (P), integral (I) and differential (D) of the deviation to determine the adjustment amount. This adjustment amount is to make the actual liquid level return to the set value of 0;
[0060] Finally, this adjustment amount is limited by the maximum threshold and the minimum threshold.
[0061] If the calculated adjustment amount is too large, exceeding the maximum adjustment threshold, the maximum adjustment threshold is used; if it is below the minimum adjustment threshold, the minimum adjustment threshold is used. This prevents excessive system overhead caused by frequent small adjustments and avoids over-adjustment that exceeds physical limits.
[0062] The inner loop - task calculation flow opening control closed loop is used to match the thread pool task consumption speed with the task inflow speed to achieve dynamic following. Its working process is as follows:
[0063] First, the flow opening PID controller in the inner loop receives the adjustment quantity instruction transmitted by the outer loop; then, based on the flow opening deviation, PID control calculation is performed to obtain the appropriate number of working threads to adjust the control quantity; finally, the adjustment control quantity is limited by the maximum and minimum adjustment thresholds to prevent the unreasonable number of threads from causing system instability or exceeding physical limits.
[0064] At this time, the working rate of the thread pool is analogous to controlling the opening of the water outlet of a water tank. By adjusting the number of working threads in the thread pool, the task outflow rate, that is, the task consumption rate, is controlled, and ultimately the task inflow and outflow rates are matched.
[0065] like Figure 4 As shown in the figure, in the double closed-loop control algorithm, the working state change process of the adaptive thread pool object is divided into the initial stage of task inflow, the task rate adjustment period, the task inflow rate following period, the task flow rate change period and the task flow rate end period. Double closed-loop control is used to collect data and perceive the state, calculate the control quantity and dynamically adjust the adaptive adjustment at different stages of the working state change process of the adaptive thread pool object.
[0066] The process of changing the working state of the adaptive thread pool object includes:
[0067] ① Initial stage of task inflow (startup phase 0-T1)
[0068] When the thread pool object suddenly receives a task flow of n1, the worker thread pool quickly becomes saturated due to its limited number of worker threads. Initially, the task queue has a small backlog, and the thread pool adds new threads slowly. As the inflow of tasks slows down the consumption rate, tasks continue to enter the thread pool task queue, causing the number of tasks in the queue (actual level) to rise rapidly, and the outer loop controller reaches the adjustment limit. Under the control of the inner loop, the worker threads in the thread pool start at the container environment's maximum thread startup rate, and the number of worker threads increases rapidly.
[0069] ②Task rate adjustment period (adjustment phase T1-T2)
[0070] When the worker thread consumption rate first reaches the task inflow rate at time T1, due to the backlog in the task queue, the outer-loop PID controller controls the inner-loop control to continue increasing the number of worker threads to consume the backlog. When the backlog decreases significantly, the outer-loop control signal outputs a suppression signal, and the inner-loop control reduces the number of worker threads, eventually reaching steady-state at time T2. At this point, the thread pool's backlog of tasks has been consumed, and the thread pool consumption rate is balanced with the task inflow rate.
[0071] ③Task inflow rate following period (steady-state stage T2-T3)
[0072] When the thread pool matches the task inflow speed at time T2, the thread pool achieves the task inflow following state. Tasks arriving at the thread pool can be consumed in a short time. There is no performance loss caused by thread creation and destruction, and the system reaches a stable state.
[0073] ④Task flow rate change period (state following adjustment stage T3-T4)
[0074] At time T3, when the task flow rate drops to n2, the inner loop of the thread pool senses the increase in the number of idle threads. Under the control of the controller, the threads in the thread pool are destroyed at a rate allowed by the container environment. When it reaches n2 for the first time, after a slight decrease in the number of working threads, it returns to the new steady-state n2 stage under the control of the outer loop.
[0075] ⑤Task inflow rate following period (steady state stage T4-T5)
[0076] When reaching the new steady state, the thread keeps following the task inflow rate, which is the (T4-T5) stage.
[0077] ⑥Task flow end stage (T5-T6)
[0078] At this stage, the task flow ends, the tasks in the task queue decrease to a set value of 0, and the idle work increases. Under the control of the thread inner loop, threads are gradually destroyed to a set minimum active value, usually set to 1. At this point, the thread pool only occupies a small amount of computing and storage resources, providing greater performance for the system.
[0079] Finally, due to the control thresholds at each stage of the dual closed-loop control design, during actual operation, thread fine-tuning, particularly during the adjustment phase T1-T2, allows the thread state to fluctuate within ±1 during the adjustment phase T3-T4, effectively controlling the system's adjustment overhead. This enables the thread pool to quickly, stably, and effectively adjust to dynamic changes in the task flow, ensuring efficient system operation and rational resource utilization, while fully leveraging the thread pool's role in improving resource reuse and accelerating response.
[0080] In S3, the calculation formula for the task flow value is as follows:
[0081] Y=(1-τ)*Yold+τ*Ynew;
[0082] Where Y represents the calculated flow, Yold represents the flow at the previous moment, Ynew represents the current actual task inflow speed, and τ represents the time lag coefficient.
[0083] This method can suppress the disturbance and noise of flow changes, making the flow representation smoother and closer to the actual situation.
[0084] In specific applications, when encountering sudden task traffic pulses—that is, a large influx of tasks within a short period of time—the algorithm does not instantly increase the calculated traffic to a very high value. Instead, it gradually adjusts the traffic calculation results based on the time constant and the traffic situation at the previous moment to make them more reflective of the actual traffic trends of the tasks. This prevents overly aggressive adjustments to the thread pool caused by pulsed traffic changes, thereby ensuring system stability and rational resource utilization.
[0085] In specific applications, the control component of the adaptive thread pool component with dynamic adjustment capabilities can be used alone and placed in a thread pool middleware. The middleware uses this closed-loop control through a certain triggering method to quickly adjust the thread pool objects it takes over, thereby achieving dynamic adjustment.
[0086] Therefore, the present invention provides an adaptive thread pool optimization method and system based on real-time task traffic closed-loop control, which innovatively puts the closed-loop feedback control mechanism and traffic perception method in control theory into practice in the dynamic adjustment of the thread pool. When faced with frequent fluctuations in task traffic, it can perform dynamic adjustments quickly and accurately, effectively preventing over-adjustment and under-adjustment, ensuring that the thread pool always maintains a stable and efficient operating state, and can closely follow the changing rhythm of task traffic in real time.
[0087] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit the same. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that they can still modify or replace the technical solutions of the present invention with equivalents, and these modifications or equivalent replacements cannot cause the modified technical solutions to deviate from the spirit and scope of the technical solutions of the present invention.
Claims
1. An adaptive thread pool optimization method based on real-time task traffic closed-loop control, characterized in that: include: S1. Adopt the closed-loop feedback control mechanism in control theory, form feedback variables by monitoring the key indicators of the thread pool, and dynamically adjust the thread pool; S2. A dual closed-loop control algorithm combining the buffer pool level and the core working thread, including an outer loop - task flow level control closed loop and an inner loop - task calculation flow opening control closed loop, achieves dynamic adjustment of the working state of the adaptive thread pool object through two serial control closed loops; S3. Use a lightweight task traffic evaluation algorithm to evaluate traffic through sampling delay calculation, consider the system's response delay and inertia to the input signal, smooth the traffic representation, and obtain the true situation of the thread pool.
2. The method and system for adaptive thread pool optimization based on real-time task flow closed-loop control according to claim 1, characterized in that: The closed-loop feedback control mechanism is specifically as follows: using an information perception module to collect key information of the thread pool, using a closed-loop controller to calculate the control quantity based on the deviation between the actual flow and the thread state itself, combined with a PID control algorithm, and constraining the control quantity based on specific container environment information. The controlled object thread pool adjusts the actual working state according to the control quantity calculated by the controller, and dynamically adds or destroys working threads.
3. The method and system for adaptive thread pool optimization based on real-time task flow closed-loop control according to claim 2, characterized in that: The key information of the thread pool includes task traffic, task consumption traffic, and computing container operating environment information.
4. The method and system for adaptive thread pool optimization based on real-time task flow closed-loop control according to claim 1, characterized in that: In the dual closed-loop control algorithm, the working process of the outer loop - task flow and liquid level control closed loop is to input the set task pool liquid level size, monitor the actual liquid level, and the PID controller calculates the adjustment amount based on the deviation and limits the adjustment amount threshold so that all the final task messages are consumed.
5. The method and system for adaptive thread pool optimization based on real-time task flow closed-loop control according to claim 1, characterized in that: In the dual closed-loop control algorithm, the working process of the inner loop-task calculation flow opening control closed loop is to accept the adjustment quantity instruction transmitted by the outer loop, perform PID control calculation based on the flow opening deviation, obtain the appropriate working thread number adjustment control quantity, and limit the adjustment quantity threshold to match the thread pool task consumption speed with the task inflow speed.
6. The method and system for adaptive thread pool optimization based on real-time task flow closed-loop control according to claim 1, characterized in that: In the dual closed-loop control algorithm, the adaptive thread pool object working state change process is divided into the task inflow initial stage, the task rate adjustment period, the task inflow rate following period, the task flow rate change period and the task flow rate end stage.
7. The method and system for adaptive thread pool optimization based on real-time task flow closed-loop control according to claim 6, characterized in that: In the dual closed-loop control algorithm, dual closed-loop control is used to perform dynamic adjustment of data collection and state perception, control quantity calculation and adaptive adjustment at different stages of the working state change process of the adaptive thread pool object.
8. The method and system for adaptive thread pool optimization based on real-time task flow closed-loop control according to claim 1, characterized in that: The calculation formula for the task flow value of the flow evaluation task using sampling time lag calculation is: Y=(1-τ)*Yold+τ*Ynew; Where Y represents the calculated flow, Yold represents the flow at the previous moment, Ynew represents the current actual task inflow speed, and τ represents the time lag coefficient.
9. An adaptive thread pool optimization system based on real-time task flow closed-loop control according to the method according to any one of claims 1 to 8, characterized in that: include: An information perception module, a PID controller based on task flow, a controlled object thread pool, a dual closed-loop control module and a task flow evaluation module; the information perception module is composed of a task flow perception unit, a task consumption flow perception unit and a computing container operating environment unit; the task flow-based PID controller internally uses a task queue based on task flow and a dual closed-loop control algorithm of a working thread; the controlled object thread pool adjusts the actual working state according to the control quantity calculated by the controller, and dynamically adds or destroys working threads; the closed-loop control module is used for the control logic of the outer loop - task flow level control closed loop and the inner loop - task calculation flow opening control closed loop; the task flow evaluation module uses sampling time delay calculation to evaluate the flow, and calculates the task flow value at the current moment through a formula.
10. The adaptive thread pool optimization system based on real-time task flow closed-loop control according to claim 9, characterized in that: The system's workflow includes: Step 1: Task entry and status update: When a task to be consumed enters the thread pool, the worker thread in the thread pool calculates the consumption of the task and updates the thread pool status information. This process calculates the inflow and outflow of task consumption data per unit time, obtains actual traffic characteristics, and perceives the key parameters of the controlled object thread pool. Step 2: Calculation of control quantity: The closed-loop controller calculates the control quantity based on the deviation between the actual flow and the state of the thread itself, combined with the PID control algorithm, and outputs the control quantity; Step 3: Control quantity constraint: The controller senses the container environment information of the system operation, constrains the control quantity based on the specific container environment information, and then outputs it to the controlled object; Step 4: Thread pool state adjustment: The thread pool of the controlled object adjusts the actual working state according to the control quantity calculated by the controller, and dynamically adds or destroys working threads.