Thread pool parameter adjusting method and device and electronic equipment

By acquiring the current running and changing metrics of the thread pool, and combining real-time status and trend analysis, the thread pool parameters are dynamically adjusted, which solves the problem of the thread pool becoming rigid under dynamic load and improves the system's response speed and resource utilization.

CN121542037APending Publication Date: 2026-02-17AGRICULTURAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511685157.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-17
Publication Date
2026-02-17

AI Technical Summary

Technical Problem

When thread pool parameters are configured rigidly to cope with dynamically changing workloads, it leads to improper resource allocation, an inability to respond to high or low loads in a timely manner, and affects system response speed and resource utilization.

Method used

By acquiring the current and changing metrics of the thread pool, and combining real-time status and trend analysis, the parameters of the thread pool, including the core thread count, maximum thread count, and queue size, are dynamically adjusted to achieve intelligent resource allocation.

Benefits of technology

It improves the system's response speed and resource utilization efficiency in high-concurrency scenarios, ensures system stability and performance optimization, and avoids problems caused by rigid thread pool parameters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121542037A_ABST
    Figure CN121542037A_ABST
Patent Text Reader

Abstract

The invention discloses a thread pool parameter adjusting method and device and electronic equipment. Relates to the technical field of computer software, and the method comprises the steps that current operation indexes of a thread pool and operation change indexes of the thread pool are obtained, the current operation indexes comprise the task queue length, the number of active threads, the average task time consumption, the job failure rate and the CPU utilization rate of the thread pool at the current sampling moment, and the operation change indexes of the thread pool are obtained; the operation change index is used for indicating operation change characteristics of the thread pool in the target time period; determining a first parameter adjustment strategy of the thread pool based on the current operation index; determining a second parameter adjustment strategy of the thread pool based on the operation change index; and obtaining a target parameter adjustment strategy of the thread pool according to the first parameter adjustment strategy and the second parameter adjustment strategy. According to the method and the device, the technical problem of rigid configuration of the thread pool when facing the dynamically changing workload in the prior art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer software, in particular to a thread pool parameter adjustment method and device and electronic equipment. BACKGROUND

[0002] In modern Internet and enterprise-level applications, high-concurrency job scheduling systems face growing data processing demands and changing workloads. Thread pool technology, as a basic component for optimizing system concurrency processing capability, the reasonable configuration of its core thread number, maximum thread number, and queue size and other parameters is crucial for improving system response speed, reducing latency, and improving resource utilization. However, in related technologies, thread pool parameters are often statically set at system startup, which to some extent leads to rigid resource allocation. When the system load changes dramatically, fixed parameter configuration may cause the thread pool to be unable to adapt in time, thereby causing problems such as excessive use of threads or resource waste. For example, during a business peak period, the thread pool may be unable to quickly process the incoming tasks due to insufficient resources, resulting in task queue backlog and response delay; while in the low peak period, the pre-set large number of threads may be in an idle state, causing unnecessary energy consumption and resource occupation. In addition, with the popularity of micro-service architecture and containerization, the system environment is more dynamic and complex, and a single parameter configuration cannot meet the needs of diverse business scenarios.

[0003] In view of the problem in the above related technology that the thread pool is rigidly configured when facing dynamically changing workloads, no effective solution has been proposed so far. SUMMARY

[0004] Embodiments of the present application provide a thread pool parameter adjustment method, device and electronic equipment to at least solve the technical problem that the thread pool in related technologies is rigidly configured when facing dynamically changing workloads.

[0005] According to an aspect of an embodiment of the present application, a thread pool parameter adjustment method is provided, comprising: obtaining a current running index of a thread pool and a running change index of the thread pool, wherein the current running index comprises a task queue length, an active thread number, an average task time consumption, a job failure rate, and a CPU usage rate of the thread pool at a current sampling time, and the running change index is used to indicate a running change feature of the thread pool in a target period; determining a first parameter adjustment strategy of the thread pool based on the current running index; determining a second parameter adjustment strategy of the thread pool based on the running change index; and obtaining a target parameter adjustment strategy of the thread pool according to the first parameter adjustment strategy and the second parameter adjustment strategy.

[0006] According to another aspect of the embodiments of the present application, a thread pool parameter adjustment apparatus is also provided, comprising: an index obtaining module, configured to obtain a current running index of a thread pool, and a running change index of the thread pool, wherein the current running index comprises a task queue length, an active thread number, an average task time consumption, a job failure rate, and a CPU usage rate of the thread pool at a current sampling moment, and the running change index is used to indicate a running change feature of the thread pool in a target period; a first strategy determining module, configured to determine a first parameter adjustment strategy of the thread pool based on the current running index; a second strategy determining module, configured to determine a second parameter adjustment strategy of the thread pool based on the running change index; and a target strategy determining module, configured to obtain a target parameter adjustment strategy of the thread pool according to the first parameter adjustment strategy and the second parameter adjustment strategy.

[0007] According to another aspect of the embodiments of the present application, a non-volatile storage medium is also provided, which stores a plurality of instructions, and the instructions are adapted to be loaded and executed by a processor to implement any one of the thread pool parameter adjustment methods.

[0008] According to another aspect of the embodiments of the present application, an electronic device is also provided, which comprises one or more processors and a memory, and the memory is configured to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement any one of the thread pool parameter adjustment methods.

[0009] According to another aspect of the embodiments of the present application, a computer program product is also provided, which comprises a computer program, and when the computer program is executed by a processor, the steps of any one of the thread pool parameter adjustment methods are implemented.

[0010] In the embodiment of the present application, the current running index of the thread pool is acquired, and the running change index of the thread pool is acquired, wherein the current running index includes the task queue length, the number of active threads, the average task time consumption, the job failure rate, and the CPU usage rate of the thread pool at the current sampling moment, and the running change index is used to indicate the running change characteristics of the thread pool in a target period; based on the current running index, the first parameter adjustment strategy of the thread pool is determined; based on the running change index, the second parameter adjustment strategy of the thread pool is determined; and according to the first parameter adjustment strategy and the second parameter adjustment strategy, the target parameter adjustment strategy of the thread pool is obtained, so that the current running index and the running change index of the thread pool are analyzed in real time, the first parameter adjustment strategy (rule matching based on the instant state) and the second parameter adjustment strategy (experience model based on the change trend) are combined, and the intelligent dynamic adjustment of the thread pool parameters is achieved, so that the intelligent dynamic adjustment of the thread pool parameters is achieved, the response speed and the resource utilization efficiency of the system in a high concurrency scenario are improved, the system stability and the optimization of the performance are ensured, and the technical problem that the thread pool is configured rigidly when facing a dynamically changing workload in the related art is solved. BRIEF DESCRIPTION OF DRAWINGS

[0011] The accompanying drawings, which are included to provide a further understanding of the present application and are incorporated in and constitute a part of this application, illustrate embodiments of the present application and serve to explain the present application. In the drawings:

[0012] Figure 1 is a flowchart of a thread pool parameter adjustment method according to an embodiment of the present application;

[0013] Figure 2 is a flowchart of an optional thread pool parameter adjustment method according to an embodiment of the present application;

[0014] Figure 3 is a schematic diagram of a thread pool parameter adjustment device according to an embodiment of the present application. DETAILED DESCRIPTION

[0015] In order to enable persons skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings of the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by persons skilled in the art without creative labor should fall within the protection scope of the present application.

[0016] It should be noted that the terms "first", "second", and the like in the description and in the claims of the present application and in the above-described drawings are intended to distinguish similar objects and not necessarily describe a particular chronological or sequential order. It should be understood that the data used in this way can be interchanged under appropriate circumstances so that the embodiments of the application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or apparatus that includes a list of steps or units is not necessarily limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to such processes, methods, products or apparatus.

[0017] According to an embodiment of the present application, a thread pool parameter adjustment method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described herein can be executed in an order different from that shown herein.

[0018] Figure 1 is a flowchart of a thread pool parameter adjustment method according to an embodiment of the present application, as shown in Figure 1 the method comprises the following steps:

[0019] Step S102, obtaining the current running index of the thread pool and the running change index of the thread pool, wherein the current running index includes the task queue length, the number of active threads, the average task time consumption, the job failure rate and the CPU usage of the thread pool at the current sampling time, and the running change index is used to indicate the running change characteristics of the thread pool in the target period.

[0020] Optionally, a thread pool is a technique that pre-creates multiple threads and manages their lifecycles with a unified scheduler to improve a system's ability to handle concurrent tasks. Task queue length measures the number of tasks waiting to be processed; an increase in queue length indicates a backlog of tasks. The number of active threads represents the number of threads currently processing tasks, reflecting the thread pool's workload. Average task execution time is used to calculate the average processing time for each task, helping to evaluate the thread pool's efficiency. Job failure rate reflects the proportion of failed jobs within a certain period; a high failure rate may indicate improper resource allocation or system anomalies. CPU utilization monitors the system's processor usage; excessive utilization may affect the normal operation of the thread pool. Performance metrics primarily focus on the thread pool's performance trends over a specified target time period. Examples include the rate of change of task queue length over time (i.e., the rate of increase in the task queue per unit time) and the trend of change in average task execution time (i.e., the change in average task execution time). These metrics can help predict future load conditions, allowing for proactive adjustments to resource allocation.

[0021] In one optional embodiment, obtaining the current running metrics and the running change metrics of the thread pool includes: detecting whether the thread pool meets preset conditions, wherein the preset conditions include thread pool saturation, or task queue length greater than a preset length, or task processing delay greater than a preset duration; and if the thread pool meets the preset conditions, obtaining the current running metrics and the running change metrics.

[0022] Optionally, before executing step S102, the thread pool status is continuously monitored to promptly identify signals requiring adjustment. The preset conditions mainly include the following three aspects: 1. Thread pool saturation: When all threads in the thread pool are executing tasks and the task queue is full and cannot accept new task requests, the system considers the thread pool to be saturated. This is a typical high-load signal, indicating that current thread resources have reached their limit and urgent adjustments are needed to increase processing capacity. 2. Task queue length exceeding a preset length: Even if the thread pool is not completely saturated, if the task queue length exceeds a preset threshold, the data collection process will still be triggered. This indicates that although some threads are still idle, potential high load pressure has already appeared, requiring advance resource planning to prevent delays in task processing. 3. Task processing latency exceeding a preset duration: Task processing latency refers to the time difference between a task entering the queue and starting execution. If this time difference exceeds a preset threshold, it means that the current resource configuration is insufficient to quickly respond to task demands, and the system needs to adjust parameters to shorten processing latency and improve response speed. When the thread pool meets the preset conditions, a data collection mechanism will automatically be started to obtain current operating metrics and operating change metrics. Current operational metrics include, but are not limited to, CPU utilization, task queue length, number of active threads, average task execution time, and job failure rate, used to assess the current working status of the system. Operational change metrics focus on historical data and trend analysis, such as the growth rate of the task queue per unit time and the change in average task execution time, used to predict future load changes in the system.

[0023] By employing the above methods, the system can intelligently identify when to initiate the parameter adjustment process, avoiding unnecessary resource consumption and excessive monitoring. Data collection is only triggered when the thread pool faces genuine workload or potential bottlenecks, ensuring that each adjustment is based on actual needs rather than blind execution. This approach not only improves the targeted nature of parameter adjustments but also reduces interference with the daily operation of the thread pool.

[0024] Step S104: Based on the current operating metrics, determine the first parameter adjustment strategy for the thread pool.

[0025] Optionally, this step relies on the analysis of current operational metrics to quickly reflect the immediate state of the thread pool. For example, by comparing set thresholds with actual performance metrics, it identifies whether thread pool parameters need to be adjusted (such as increasing or decreasing the number of core threads) to cope with current business pressure. The first parameter adjustment strategy emphasizes immediacy and specificity; it focuses on the current system state and provides initial guidance for parameter adjustments.

[0026] In one optional embodiment, determining a first parameter adjustment strategy for the thread pool based on current operating metrics includes: determining a first parameter adjustment strategy based on current operating metrics and preset matching rules, wherein the preset matching rules are used to indicate the correspondence between the value conditions of the current operating metrics and the parameter adjustment strategy.

[0027] Optionally, a series of predefined rules can be designed, which are associated with the current operating metrics and parameter adjustment strategies of the thread pool. The design of the preset matching rules considers multiple possible combinations of system states, each corresponding to a specific parameter adjustment strategy. The aim is to respond quickly and accurately under different workload conditions. Based on the collected current operating metrics, these metric values ​​are compared with the preset matching rules. Once a matching metric combination is found, the corresponding parameter adjustment strategy is immediately returned. The preset matching rules act as a "decision tree," and they can be predefined by experts and system administrators, based on historical data and lessons learned, effectively guiding parameter adjustments. The rules can cover various workload scenarios, such as high load, task backlog, and CPU bottlenecks, ensuring appropriate parameter adjustments are made under various conditions, thereby maintaining the system's high performance and stability. Through the first parameter adjustment strategy determination method in this embodiment, the optimal resource allocation strategy can be quickly identified in a rapidly changing working environment, avoiding the rigidity and inefficiency caused by fixed configurations. This approach not only improves the system's adaptability but also reduces the need for manual intervention, enhancing the system's automation level, and has significant practical value for ensuring the smooth operation of high-concurrency job scheduling systems.

[0028] In one optional embodiment, a first parameter adjustment strategy is determined based on current operating metrics and preset matching rules, including: if the current operating metrics meet a first value condition, the first parameter adjustment strategy is determined to be: increasing the core thread count of the thread pool by a first amount and increasing the maximum thread count by a second amount, wherein the first value condition is that the CPU utilization rate is greater than a first preset ratio, the task queue length is greater than a first preset length, and the average task execution time is greater than a first preset duration; or if the current operating metrics meet a second value condition, the first parameter adjustment strategy is determined to be: increasing the core thread count of the thread pool by a third amount and starting a backup thread pool, wherein the second value condition is the task queue length. If the current operating metrics meet the third condition, the first parameter adjustment strategy is determined as follows: the number of core threads is reduced by the fourth condition, and idle threads are closed. The third condition includes: CPU utilization is less than the second preset ratio, the task queue length is less than the second preset length, the number of active threads is less than the preset number, the second preset ratio is less than the first preset ratio, and the second preset length is less than the first preset length. Alternatively, if the current operating metrics do not meet the first, second, and third conditions, the first parameter adjustment strategy is determined as follows: the current thread pool parameters remain unchanged.

[0029] Optionally, when the CPU utilization exceeds a first preset percentage (e.g., 85%), the task queue length exceeds a first preset length (e.g., 500 tasks), and the average task execution time exceeds a first preset duration (e.g., 1.5 seconds), the thread pool faces high load pressure. In this case, the first parameter adjustment strategy is triggered, increasing the core thread count by a first amount and the maximum thread count by a second amount (usually the second amount is greater than the first) to meet current processing demands and reduce task backlog and processing latency. The second condition is more stringent than the first, requiring not only that the task queue length exceeds a preset length but also adding an additional condition—that the job failure rate exceeds a preset percentage. This indicates that the thread pool not only has task backlog but also serious processing problems, potentially leading to service unavailability. In this case, the first parameter adjustment strategy not only increases the core thread count (a third amount, usually exceeding the first) but also activates a backup thread pool to maximize processing capacity and fault tolerance, ensuring stable system operation and service quality. Compared to the first two cases, the third condition describes the adjustment of thread pool parameters under low load conditions. When CPU utilization is below the second preset percentage (usually lower than the first preset percentage, such as 30%), task queue length is below the second preset length (lower than the first preset length), and the number of active threads is less than a preset number, the thread pool is in a state of resource surplus. In this case, the first parameter adjustment strategy will guide the reduction of the number of core threads (the fourth quantity) and the shutdown of some idle threads to reduce energy consumption and resource waste, while maintaining system responsiveness. If the current operating metrics do not meet the three value conditions, the system will consider the current parameter configuration sufficient to handle the current workload and no adjustment is needed. Therefore, the determined first parameter adjustment strategy is to maintain the current thread pool parameters unchanged to avoid unnecessary system disturbances and maintain operational continuity and stability. Table 1 shows the correspondence between the optional value conditions and the adjustment strategy.

[0030] Table 1

[0031]

[0032] By introducing these three value conditions and their corresponding parameter adjustment strategies, the system can more accurately adapt to the needs of different workloads, achieving efficient resource utilization and adaptive system adjustment. It can not only quickly respond to high loads and extreme task backlogs, but also reasonably reduce resource consumption during low load periods, thereby improving the overall system performance, stability, and energy efficiency.

[0033] As an optional implementation, if the current operating indicator value satisfies multiple of the first, second, and third value conditions, the priority of each of the multiple value conditions is determined, and the adjustment strategy corresponding to the highest priority among the multiple value conditions is determined as the first parameter adjustment strategy.

[0034] Step S106: Based on the operational change indicators, determine the second parameter adjustment strategy for the thread pool.

[0035] Optionally, compared to the first strategy, the second parameter adjustment strategy places greater emphasis on historical data and predictive analysis. This step can utilize runtime change metrics to identify load trends and patterns. For example, if the task queue length is observed to be continuously increasing over a period of time, even if the current queue length has not yet reached a threshold, it may be necessary to increase the number of threads in advance to prevent future backlogs. The second strategy provides a proactive perspective, helping the system to anticipate and adjust before load changes occur, thereby avoiding potential performance bottlenecks.

[0036] In an optional embodiment, when the operational change indicators include the unit time growth rate of the task queue and the change in average task time, a second parameter adjustment strategy for the thread pool is determined based on the operational change indicators. This includes: determining the weight values ​​corresponding to the unit time growth rate of the task queue, the change in average task time, the job failure rate, and the CPU utilization; and obtaining the second parameter adjustment strategy based on the unit time growth rate of the task queue, the change in average task time, the job failure rate, the CPU utilization, and their respective weight values.

[0037] Optionally, the unit-time growth rate of the task queue and the change in average task execution time can be obtained by comparing the trends of indicators in adjacent time periods over the past 15 minutes. Before determining the second parameter adjustment strategy, it is necessary to first determine the weight values ​​corresponding to the unit-time growth rate of the task queue, the change in average task execution time, the job failure rate, and the CPU utilization. These weight values ​​reflect the relative importance of different operational change indicators to the thread pool parameter adjustment decision. For example, if historical data shows that an increase in the job failure rate has a more significant impact on system stability than a change in CPU utilization, then the system will assign a higher weight value to the job failure rate. Once the weight values ​​of the above indicators are determined, the second parameter adjustment strategy can be calculated using formulas or algorithms based on these operational change indicators and weight values. The second parameter adjustment strategy can be obtained, but is not limited to, through the following methods: Where Δcore(model) represents the core thread count adjustment amount in the second parameter adjustment strategy (i.e., the core thread count that should be increased or decreased), ΔQ / ΔT represents the task queue growth rate per unit time, ΔTavg represents the change in average task execution time, Tavg represents the average task execution time corresponding to the current sampling time, FailRate represents the job failure rate in the last 5 minutes, and CPUload represents the CPU utilization rate corresponding to the current sampling time. , , , The weights are, in order, the unit time growth rate of the task queue, the change in average task time, the job failure rate, and the CPU utilization rate. These weights can be empirical weights derived by the system based on training data.

[0038] By employing the above methods, future workloads can be predicted to some extent, allowing for proactive adjustments to thread pool parameters and preventing performance bottlenecks caused by improper resource allocation. This approach improves system responsiveness and flexibility, helping to maintain service quality and system stability, especially when handling dynamic and unpredictable high-concurrency scenarios. The introduction of weight values ​​makes the adjustment strategy more scientific and personalized. The system can automatically optimize weight allocation based on specific business scenarios and historical performance data, thus making the most appropriate parameter adjustment decisions under different conditions. In determining the second parameter adjustment strategy, this embodiment not only considers the current system state but also predicts potential future load changes through historical data and operational trend analysis, making thread pool parameter adjustments more proactive and precise. This approach significantly enhances the thread pool's adaptability in high-concurrency job scheduling, reduces the need for manual intervention, and improves operational efficiency and overall system performance.

[0039] Step S108: Based on the first parameter adjustment strategy and the second parameter adjustment strategy, the target parameter adjustment strategy of the thread pool is obtained.

[0040] Optionally, both immediate and trend-based parameter tuning strategies can be combined to form a comprehensive target parameter tuning strategy. This step considers the balance between immediate needs and forward-looking planning, ensuring that adjustments address both the current system state and potential future load changes. For example, if the first strategy recommends increasing the number of threads to handle the current high load, while the second strategy predicts a continued increase in load based on historical data, the target strategy might adopt bolder parameter adjustments to ensure the system continues to operate efficiently in the future. The entire strategy formulation process reflects the system's intelligence and adaptability, significantly improving the flexibility and efficiency of thread pool management, thereby enhancing the overall system stability and performance.

[0041] Optionally, the target parameter adjustment strategy may include, but is not limited to, the adjustment direction and adjustment range of the thread pool parameters, wherein the thread pool parameters include at least the core thread count and the maximum thread count.

[0042] In one optional embodiment, the target parameter adjustment strategy of the thread pool is obtained according to the first parameter adjustment strategy and the second parameter adjustment strategy, including: obtaining the adjustment direction corresponding to the first parameter adjustment strategy and the second parameter adjustment strategy respectively; and determining the target parameter adjustment strategy based on the first parameter adjustment strategy, the second parameter adjustment strategy and their respective adjustment directions.

[0043] Optionally, firstly, extract the adjustment directions from the first and second parameter adjustment strategies respectively. The adjustment direction refers to the trend of parameter adjustment, such as increasing the number of core threads, decreasing the maximum number of threads, or expanding the task queue capacity. This is the basis for merging the two strategies, because only by understanding the intent of each strategy can reasonable decisions be made. This mechanism is particularly effective when handling complex and variable workloads. It ensures that adjustments consider both the immediate needs of the current system state and the anticipation of potential future load changes, thereby improving the overall system response speed, stability, and resource utilization efficiency. Furthermore, accurate determination of the adjustment direction can avoid ineffective adjustments due to strategy conflicts, improving the accuracy and effectiveness of thread pool parameter adjustment.

[0044] In one optional embodiment, a target parameter adjustment strategy is determined based on a first parameter adjustment strategy and a second parameter adjustment strategy, and their respective adjustment directions. This includes: when their respective adjustment directions are the same, selecting the parameter adjustment strategy with the largest adjustment magnitude from the first and second parameter adjustment strategies as the target parameter adjustment strategy; or when their respective adjustment directions are opposite, selecting the first parameter adjustment strategy as the target parameter adjustment strategy; or when the first parameter adjustment strategy is to maintain the current thread pool parameters unchanged, selecting the second parameter adjustment strategy as the target parameter adjustment strategy.

[0045] Optionally, if the first and second parameter adjustment strategies have the same adjustment direction, and both strategies recommend increasing or decreasing the number of threads, then the adjustment magnitude of the two strategies should be compared. A strategy with a larger adjustment magnitude means a more significant change in the thread pool parameters, and can respond more quickly to current or anticipated load changes in the system. Therefore, the parameter adjustment strategy with the largest adjustment magnitude will be selected as the target parameter adjustment strategy, and implementing this strategy can more effectively handle immediate or future load conditions. If the first and second parameter adjustment strategies have opposite adjustment directions—that is, one strategy recommends increasing the number of threads while the other recommends decreasing the number of threads—the first parameter adjustment strategy will be preferred. The first parameter adjustment strategy is based on the immediate state of current operating metrics and can more directly reflect the current pressure or resource surplus faced by the system. Prioritizing the first parameter adjustment strategy ensures that the system can quickly respond to immediate demands and avoid performance degradation or resource waste caused by waiting for prediction results. If the first parameter adjustment strategy is to maintain the current thread pool parameters unchanged, this indicates that the current operating state of the system does not match the preset adjustment threshold, meaning that the system does not need to make immediate adjustments at the current moment. At this point, the second parameter adjustment strategy will be directly adopted as the target parameter adjustment strategy. Based on historical data and operational change indicators, the second parameter adjustment strategy provides predictive adjustment suggestions for future load changes. While keeping the first parameter adjustment strategy unchanged, adopting the second parameter adjustment strategy can prevent potential resource bottlenecks and ensure that the system can maintain good performance under future high load conditions.

[0046] The above approach achieves a balance between immediate state response and future predictive adjustments through clearly defined rules, ensuring the rationality and effectiveness of thread pool parameter adjustments. In practical applications, this mechanism helps automated operation and maintenance platforms respond to complex and ever-changing workloads, enabling them to both respond promptly to unexpected situations and plan future resource allocation in advance, thereby improving overall system stability and processing efficiency. It also avoids resource waste caused by policy conflicts, enhancing the intelligence level of thread pool management.

[0047] Through steps S102 to S108, the current operating metrics and changing metrics of the thread pool can be analyzed in real time. By combining the first parameter adjustment strategy (rule matching based on the real-time state) and the second parameter adjustment strategy (empirical model based on the changing trend), the goal of intelligent dynamic adjustment of thread pool parameters can be achieved. This intelligent dynamic adjustment of thread pool parameters improves the system's response speed and resource utilization efficiency in high-concurrency scenarios, ensuring the optimal technical effect of system stability and performance. In turn, it solves the technical problem of rigid configuration of thread pools when facing dynamically changing workloads in related technologies.

[0048] As enterprise IT systems become increasingly large and complex, automated operations and maintenance platforms commonly face challenges such as rigid thread resource allocation, frequent thread blocking, and high system processing latency when performing tasks like scheduling large numbers of concurrent jobs, processing logs, and reporting status. Thread pool parameters in related technologies, such as the number of core threads, the maximum number of threads, and queue capacity, are mostly statically configured and cannot be adaptively adjusted based on real-time job traffic, system load, message backlog, and other operational states, leading to wasted system resources or bottlenecks. With the widespread adoption of microservices and distributed system architectures, backend servers need to handle massive concurrent requests and complex business logic. In this context, thread pools effectively reduce the system overhead of frequent thread creation and destruction by reusing thread resources, thereby improving the system's concurrent processing capabilities and response efficiency. In practical applications, thread pools are typically configured with preset parameters based on experience during system startup. However, this static configuration fails to adequately consider the dynamic changes in business load, leading to numerous problems during operation. For example, during peak request periods, the thread pool may trigger a task rejection policy due to insufficient thread count or task queue overflow, causing request failures or delays. During off-peak periods, idle threads still consume resources, reducing overall system efficiency. In related thread pool management methods, thread pool parameters are usually statically set during system initialization, lacking the ability to dynamically adjust during runtime. This static configuration method cannot dynamically schedule thread resources according to changes in actual business pressure, affecting both the system's concurrent processing efficiency and reducing the overall rationality of resource utilization.

[0049] To address the aforementioned issues, and in conjunction with the above embodiments and optional embodiments, this invention proposes an optional implementation method. This method is applied to a system including a strategy decision module, a scenario scheduling engine, a data service center, an execution scheduler, and execution target nodes. The strategy decision module is used to formulate the most suitable thread pool adjustment strategy for the current system state and scenario based on acquired real-time and historical data. The scenario scheduling engine is used to analyze the task scenario of the currently scheduled tasks, providing a basis for subsequent strategy decisions. The data service center provides real-time and historical data support for the strategy decision module to generate corresponding parameter adjustment schemes. The execution scheduler is used to modify the parameters of the target thread pool instance online and write back the status to the data service center after adjustment. The execution target node is the actual deployment location of the thread pool, ultimately completing the parameter adjustment and its effectiveness.

[0050] Figure 2 This is a flowchart illustrating an optional thread pool parameter adjustment method according to an embodiment of the present invention, as shown below. Figure 2 As shown, the method includes:

[0051] S1, the triggering and initiation of thread pool adjustment, specifically includes: the scheduling system continuously monitors each module in the system, and when a triggering event occurs (such as thread pool saturation, excessive task backlog, or continuous increase in processing latency), the thread pool dynamic adjustment process is automatically triggered.

[0052] S2, the scenario scheduling engine performs scenario identification. Specifically, after obtaining the trigger event, the scheduling engine first obtains the current scheduling context information, analyzes the job type, business priority and queue backlog source, determines the scheduling load scenario to which the current system belongs, and sends an execution strategy request to the strategy decision module.

[0053] S3, Data interaction between the strategy decision-making module and the data service center. Specifically, the strategy decision-making module then sends bidirectional data requests to the data service center. On the one hand, it requests predefined thread pool adjustment rules that match the current job type and scenario, as well as historical performance data; on the other hand, it requests real-time running status data of the thread pools corresponding to each execution module in the current system to support parameter determination.

[0054] S4, the strategy decision module generates a parameter adjustment plan. After obtaining the relevant data from the data service center, it combines real-time collected data indicators and historical performance data as input, derives the most suitable thread pool adjustment parameters based on built-in rules, strategies, and empirical models, and generates structured adjustment instructions in real time. In the dynamic thread pool parameter adjustment mechanism of this embodiment, the generation of parameter strategies is the core step in the system's response to changing resources. The specific rules, strategies, and empirical models are as follows:

[0055] S41, Metrics Collection and Data Preparation: The strategy module continuously acquires metrics from the following two data sources: Real-time metrics: current task queue length, number of active threads, average task execution time, job failure rate, and system CPU utilization; Historical data: compare the metric trends of adjacent time periods within the past 15 minutes to calculate the unit time growth rate of the task queue and the change in average task execution time.

[0056] S42, a fixed built-in matching strategy. The system has a set of thread pool adjustment strategies, maintained by the administrator through a configuration file. Specific rules are shown in Table 1 above. All rules are executed in parallel. If only one rule is matched, the adjustment amount of the corresponding rule's parameters is used as the adjustment amount of the matching strategy; if multiple rules are matched, the adjustment amount of the rule with the highest priority is used as the adjustment amount of the matching strategy. The adjustment amount obtained based on the matching strategy is denoted as... The first parameter adjustment strategy is obtained.

[0057] S43, Empirical Model Calculation: To improve sensitivity to sudden traffic surges, the system introduces a lightweight empirical prediction model to calculate the recommended adjustment amount, denoted as... The second parameter adjustment strategy is obtained, where, The specific acquisition process is the same as in the aforementioned embodiments, and will not be repeated here.

[0058] S44, Parameter Decision Mechanism: For adjusting thread pool parameters obtained from the two methods described above, a unified decision priority mechanism is adopted, as follows:

[0059] S441, if the rule matching condition is triggered, the thread count adjustment value determined by the rule shall prevail, and the parameter adjustment amount obtained by the rule matching strategy shall be recorded as: .

[0060] S442, Perform empirical model calculations to obtain the adjustment amount of the recommended parameters based on the empirical model calculations, denoted as: .

[0061] S443, if the two adjustments are in the same direction, then the one with the larger absolute value is used as the final target parameter adjustment strategy, and the corresponding adjustment instruction is generated.

[0062] S444, if the two adjustments are in opposite directions, then the result obtained using the matching strategy ( This serves as the final target parameter adjustment strategy, and generates corresponding adjustment instructions.

[0063] S445, if no rule is hit (i.e., none) If so, the parameter adjustment amount calculated based on the empirical model will be used directly. This serves as the final target parameter adjustment strategy, and generates corresponding adjustment instructions.

[0064] S5, scheduling instructions are issued by the scheduler: After the adjustment instruction is generated, it is pushed to the scene scheduling engine, which then issues the execution instruction to the data service center. The center then initiates an operation with the execution scheduler to dynamically adjust the corresponding thread pool parameters. The execution scheduler is responsible for thread pool lifecycle management and performs hot updates on the parameters of currently executing thread pools to ensure a smooth, uninterrupted transition.

[0065] S6, Target Node Parameter Adjustment and Scheduling Feedback: After the execution scheduler completes the adjustments, each execution module applies the new thread pool parameter configuration. Once these adjustments take effect, the corresponding task processing capabilities of the modules are improved. Furthermore, the execution scheduler reports the performance status before and after the adjustments to the data service center to accumulate historical performance data and build optimization experience for future performance improvements.

[0066] It should be noted that the method in this embodiment enables dynamic adjustment of thread pool configuration. The system can adaptively adjust multiple key parameters of the thread pool by combining real-time and historical data. This method replaces the traditional fixed thread count configuration, improving the scheduling system's adaptability and response efficiency under different loads. Simultaneously, this embodiment method also enhances system stability and scalability. With the dynamic parameter adjustment method, the system can flexibly respond to business growth or sudden traffic surges, maintaining stable operation under different environments and scales, facilitating subsequent horizontal scaling, service replication, and multi-instance deployment.

[0067] This embodiment also provides a thread pool parameter adjustment device, which is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the terms "module" and "device" can refer to a combination of software and / or hardware that performs a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, hardware implementations, or a combination of software and hardware, are also possible and contemplated.

[0068] According to an embodiment of the present invention, an apparatus embodiment for implementing the above-described thread pool parameter adjustment method is also provided. Figure 3 This is a schematic diagram of a thread pool parameter adjustment device according to an embodiment of the present invention, as shown below. Figure 3 As shown, the above-mentioned thread pool parameter adjustment device includes: an indicator acquisition module 300, a first strategy determination module 302, a second strategy determination module 304, and a target strategy determination module 306, wherein:

[0069] The metric acquisition module 300 is used to acquire the current running metrics of the thread pool and the running change metrics of the thread pool. The current running metrics include the task queue length, number of active threads, average task time, job failure rate, and CPU utilization of the thread pool at the current sampling time. The running change metrics are used to indicate the running change characteristics of the thread pool during the target period.

[0070] The first strategy determination module 302 is connected to the indicator acquisition module 300 and is used to determine the first parameter adjustment strategy of the thread pool based on the current running indicators.

[0071] The second strategy determination module 304, connected to the first strategy determination module 302, is used to determine the second parameter adjustment strategy of the thread pool based on the running change indicators.

[0072] The target strategy determination module 306 is connected to the second strategy determination module 304 and is used to adjust the strategy according to the first parameter and the second parameter to obtain the target parameter adjustment strategy of the thread pool.

[0073] It should be noted that the above modules can be implemented by software or hardware. For example, for the latter, it can be implemented in the following ways: the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.

[0074] It should be noted that the aforementioned indicator acquisition module 300, first strategy determination module 302, second strategy determination module 304, and target strategy determination module 306 correspond to steps S102 to S108 in the embodiments. The instances and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the content disclosed in the above embodiments. It should be noted that the above modules, as part of the device, can run in a computer terminal.

[0075] It should be noted that the optional or preferred implementation methods of this embodiment can be found in the relevant descriptions in the embodiments, and will not be repeated here.

[0076] The aforementioned thread pool parameter adjustment device may also include a processor and a memory. The aforementioned indicator acquisition module 300, first strategy determination module 302, second strategy determination module 304, target strategy determination module 306, etc., are all stored in the memory as program modules, and the processor executes the aforementioned program modules stored in the memory to realize the corresponding functions.

[0077] The processor contains a core that retrieves the corresponding program modules from memory. One or more cores may be configured. Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory includes at least one memory chip.

[0078] According to an embodiment of this application, an embodiment of a non-volatile storage medium is also provided. Optionally, in this embodiment, the non-volatile storage medium includes a stored program, wherein, when the program runs, it controls the device where the non-volatile storage medium is located to execute any of the thread pool parameter adjustment methods described above.

[0079] Optionally, in this embodiment, the non-volatile storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals, and the non-volatile storage medium includes stored programs.

[0080] Optionally, a program that controls the device containing the non-volatile storage medium to execute any of the above thread pool parameter adjustment method steps during program execution.

[0081] According to an embodiment of this application, an embodiment of a processor is also provided. Optionally, in this embodiment, the processor is used to run a program, wherein the program executes any of the thread pool parameter adjustment methods described above.

[0082] According to an embodiment of this application, an embodiment of a computer program product is also provided, which, when executed on a data processing device, is adapted to execute a program that initializes a thread pool parameter adjustment method step that includes any of the above-described steps.

[0083] This invention provides an electronic device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it implements the thread pool parameter adjustment method steps described above.

[0084] The order of the above embodiments of the present invention is merely for description and does not represent the superiority or inferiority of the embodiments.

[0085] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0086] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of modules described above can be a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, or indirect coupling or communication connection between modules, and may be electrical or other forms.

[0087] The modules described above as separate components may or may not be physically separate. Similarly, the components shown as modules may or may not be physical modules; they may be located in one place or distributed across multiple modules. Some or all of the modules can be selected to achieve the purpose of this embodiment, depending on actual needs.

[0088] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.

[0089] If the aforementioned integrated modules are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable non-volatile storage medium. Based on this understanding, the technical solution of this invention, 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 non-volatile storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned non-volatile storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0090] The above are merely preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A method for adjusting thread pool parameters, characterized in that, include: Obtain the current running metrics of the thread pool, as well as the running change metrics of the thread pool. The current running metrics include the task queue length, number of active threads, average task time, job failure rate, and CPU utilization of the thread pool at the current sampling time. The running change metrics are used to indicate the running change characteristics of the thread pool during the target time period. Based on the current operating metrics, determine the first parameter adjustment strategy for the thread pool; Based on the aforementioned operational change indicators, a second parameter adjustment strategy for the thread pool is determined; Based on the first parameter adjustment strategy and the second parameter adjustment strategy, the target parameter adjustment strategy of the thread pool is obtained.

2. The method according to claim 1, characterized in that, The step of determining the first parameter adjustment strategy for the thread pool based on the current operating metrics includes: Based on the current operating indicators and the preset matching rules, the first parameter adjustment strategy is determined, wherein the preset matching rules are used to indicate the correspondence between the value conditions of the current operating indicators and the parameter adjustment strategy.

3. The method according to claim 2, characterized in that, The step of determining the first parameter adjustment strategy based on the current operating indicators and preset matching rules includes: If the current operating metric meets the first value condition, the first parameter adjustment strategy is determined to be: increasing the core thread count of the thread pool by a first amount and increasing the maximum thread count by a second amount, wherein the first value condition is that the CPU utilization rate is greater than a first preset ratio, the task queue length is greater than a first preset length, and the average task consumption time is greater than a first preset duration; or If the current operating metric meets the second value condition, the first parameter adjustment strategy is determined to be: increasing the core thread count of the thread pool by a third number and enabling the backup thread pool, wherein the second value condition is that the task queue length is greater than the first preset length, the job failure rate is greater than a preset ratio, and the third number is greater than the first number; or If the current operating metric meets the third condition, the first parameter adjustment strategy is determined to be: controlling the core thread count to decrease by a fourth amount and closing idle threads, wherein the third condition includes the CPU utilization rate being less than a second preset ratio, the task queue length being less than a second preset length, the number of active threads being less than a preset number, the second preset ratio being less than the first preset ratio, and the second preset length being less than the first preset length; or If the current operating metric does not meet the first value condition, the second value condition, and the third value condition, the first parameter adjustment strategy is determined to be: maintain the current thread pool parameter unchanged.

4. The method according to claim 1, characterized in that, When the operational change indicators include the task queue's growth rate per unit time and the change in average task execution time, the step of determining the second parameter adjustment strategy for the thread pool based on the operational change indicators includes: Determine the weight values ​​for the unit time growth rate of the task queue, the change in average task time, the job failure rate, and the CPU utilization rate. The second parameter adjustment strategy is obtained based on the unit time growth rate of the task queue, the average task time change, the job failure rate, the CPU utilization, and their respective weight values.

5. The method according to claim 1, characterized in that, The step of obtaining the target parameter adjustment strategy for the thread pool based on the first parameter adjustment strategy and the second parameter adjustment strategy includes: Obtain the adjustment direction corresponding to the first parameter adjustment strategy and the second parameter adjustment strategy, respectively; Based on the first parameter adjustment strategy and the second parameter adjustment strategy, and their respective adjustment directions, the target parameter adjustment strategy is determined.

6. The method according to claim 5, characterized in that, The step of determining the target parameter adjustment strategy based on the first parameter adjustment strategy, the second parameter adjustment strategy, and their respective adjustment directions includes: When the corresponding adjustment directions are the same, the parameter adjustment strategy with the largest adjustment magnitude among the first parameter adjustment strategy and the second parameter adjustment strategy shall be taken as the target parameter adjustment strategy; or When the respective adjustment directions are opposite, the first parameter adjustment strategy is used as the target parameter adjustment strategy; or If the first parameter adjustment strategy is to keep the current thread pool parameters unchanged, the second parameter adjustment strategy will be used as the target parameter adjustment strategy.

7. The method according to any one of claims 1 to 6, characterized in that, The acquisition of the current running metrics of the thread pool, and the running change metrics of the thread pool, includes: Detect whether the thread pool meets preset conditions, wherein the preset conditions include the thread pool being saturated, or the task queue length being greater than a preset length, or the task processing delay being greater than a preset duration; If the thread pool meets the preset conditions, obtain the current running metrics and the running change metrics.

8. A thread pool parameter adjustment device, characterized in that, include: The metric acquisition module is used to acquire the current running metrics of the thread pool and the running change metrics of the thread pool. The current running metrics include the task queue length, number of active threads, average task time, job failure rate, and CPU utilization of the thread pool at the current sampling time. The running change metrics are used to indicate the running change characteristics of the thread pool during the target time period. The first strategy determination module is used to determine the first parameter adjustment strategy of the thread pool based on the current operating metrics. The second strategy determination module is used to determine the second parameter adjustment strategy of the thread pool based on the operation change indicators. The target strategy determination module is used to obtain the target parameter adjustment strategy of the thread pool based on the first parameter adjustment strategy and the second parameter adjustment strategy.

9. A non-volatile storage medium, characterized in that, The non-volatile storage medium stores multiple instructions, which are adapted to be loaded by a processor and executed by the thread pool parameter adjustment method according to any one of claims 1 to 7.

10. An electronic device, characterized in that, It includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the thread pool parameter adjustment method according to any one of claims 1 to 7.