Method, system and equipment for dynamically regulating and controlling thread pool parameters and medium
By pre-building a parameter configuration center and dynamically listening for thread pool parameter change events, generating runtime status reports, and dynamically adjusting thread pool parameters, the problem of task backlog and resource waste caused by fixed thread pool parameters is solved, achieving efficient thread pool management and resource utilization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN LEXIN INFORMATION SERVICE CO LTD
- Filing Date
- 2025-12-10
- Publication Date
- 2026-05-15
AI Technical Summary
The existing thread pool parameters are fixed after initialization, which lacks flexibility and makes it difficult to respond quickly to changes in business traffic, resulting in task backlog or resource waste. It is impossible to achieve efficient resource management and task scheduling in complex and ever-changing business scenarios.
By building a pre-configured parameter center, we can dynamically monitor thread pool parameter change events, collect thread-related, task-related, and status data to generate runtime status reports, generate control operations based on the reports, and dynamically adjust thread pool parameters to optimize system performance and resource utilization.
It enables flexible adjustment of thread pool parameters, can respond promptly to changes in task configuration, avoid task backlog, and optimize system performance and resource utilization.
Smart Images

Figure CN122044818A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of thread pool control technology, and in particular to a method, system, device and medium for dynamic control of thread pool parameters. Background Technology
[0002] Thread pools are a common solution for Java applications handling high concurrency and large tasks. They are primarily based on core implementation classes within the Java Development Kit (JDK) and initialized with fixed parameters. Their operating mechanism is as follows: when a task is submitted, core threads are created first for processing; once the core threads are full, the task is queued; once the queue is full, non-core threads are created (up to the maximum number of threads); when both the number of threads and the queue are full, a rejection policy is triggered.
[0003] However, existing thread pool creation methods have significant shortcomings in practical applications. On the one hand, key parameters such as the core number of threads, the maximum number of threads, and the queue capacity are fixed after initialization, lacking flexibility. When business traffic suddenly increases, the thread pool struggles to respond quickly, easily leading to task backlogs and potentially thread exhaustion, affecting service stability. Conversely, during periods of low traffic, idle threads in the thread pool waste resources. On the other hand, the thread pool cannot automatically scale up or down based on real-time metrics (such as queue backlog, task rejection counts, and thread activity) and server load, resulting in severe inflexibility when facing complex and ever-changing business scenarios, making it difficult to meet the needs of efficient resource management and task scheduling.
[0004] Therefore, how to more efficiently regulate thread pool parameters has become an urgent problem to be solved. Summary of the Invention
[0005] This invention provides a method, system, computer device, and medium for dynamically adjusting thread pool parameters in artificial intelligence, in order to solve the problem of poor diversity and flexibility in the existing dynamic adjustment of thread pool parameters.
[0006] Firstly, a method for dynamically adjusting thread pool parameters is provided, including: Obtain the initial thread pool, and schedule the threads in the initial thread pool to the update thread pool corresponding to the pre-built parameter configuration center to obtain the configuration thread pool; Listen for thread pool parameter change events in the parameter configuration center, update the parameter configuration of the configured thread pool according to the thread pool parameter change events, and obtain the target thread pool; Collect thread-related data, task-related data, and thread pool status data of the target thread pool, and generate a thread pool running status report based on the thread-related data, task-related data, and thread pool status data; Based on the thread pool running status report, generate thread pool parameter adjustment operations for the target thread pool; The target thread pool parameter adjustment value is calculated using the thread pool parameter adjustment operation, and the target thread pool is adjusted according to the parameter adjustment value.
[0007] Secondly, a dynamic parameter control system for thread pools is provided, including: The parameter configuration module is used to obtain the initial thread pool and schedule the threads in the initial thread pool to the update thread pool corresponding to the pre-built parameter configuration center to obtain the configuration thread pool. The parameter configuration update module is used to listen for thread pool parameter change events of the configured thread pool in the parameter configuration center, and update the parameter configuration of the configured thread pool according to the thread pool parameter change events to obtain the target thread pool. The report generation module is used to collect thread-related data, task-related data and thread pool status data of the target thread pool, and generate a thread pool running status report based on the thread-related data, task-related data and thread pool status data; The parameter adjustment action generation module is used to generate thread pool parameter adjustment operations for the target thread pool based on the thread pool running status report. The parameter control module is used to calculate the target thread pool parameter control value using the thread pool parameter control operation, and to control the parameters of the target thread pool according to the parameter control value.
[0008] Thirdly, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described dynamic adjustment method for thread pool parameters.
[0009] Fourthly, a computer-readable storage medium is provided, which stores a computer program that, when executed by a processor, implements the steps of the above-described method for dynamically adjusting thread pool parameters.
[0010] The aforementioned scheme, implemented by the dynamic thread pool parameter control method, system, computer device, and storage medium, obtains a configured thread pool by scheduling threads from the initial thread pool to the update thread pool corresponding to the pre-built parameter configuration center. It then listens for thread pool parameter change events in the parameter configuration center and updates the parameter configuration of the configured thread pool based on these events to obtain the target thread pool. This allows for dynamic responses to changes in task configurations within the application, enabling flexible thread pool updates. Furthermore, it collects thread-related data, task-related data, and thread pool status data from the target thread pool and generates a thread pool runtime status report. This report provides data support for subsequent thread pool parameter control operations, enabling timely detection of abnormal behavior and more precise parameter control. Finally, it generates thread pool parameter control operations for the target thread pool based on the runtime status report. These operations allow for dynamic adjustment of thread pool parameter configurations to optimize system performance and resource utilization. Simultaneously, the operation determines the parameter values to be controlled, achieving efficient thread pool parameter control. Attached Figure Description
[0011] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a schematic diagram of an application environment for a thread pool parameter dynamic adjustment method according to an embodiment of the present invention; Figure 2 This is a flowchart illustrating a method for dynamically adjusting thread pool parameters in one embodiment of the present invention; Figure 3 This is a schematic diagram of a thread pool parameter dynamic control system in one embodiment of the present invention; Figure 4 This is a schematic diagram of the structure of a computer device according to an embodiment of the present invention; Figure 5 This is another structural schematic diagram of a computer device according to one embodiment of the present invention. Detailed Implementation
[0013] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0014] The thread pool parameter dynamic adjustment method provided in this embodiment of the invention can be applied to, for example... Figure 1 In this application environment, the client communicates with the server via a network. The server can obtain an initial thread pool from the client, schedule the threads in the initial thread pool to the update thread pool corresponding to a pre-built parameter configuration center to obtain a configuration thread pool; listen for thread pool parameter change events of the configuration thread pool in the parameter configuration center, update the parameter configuration of the configuration thread pool according to the thread pool parameter change events, and obtain a target thread pool; collect thread-related data, task-related data, and thread pool status data of the target thread pool, generate a thread pool running status report based on the thread-related data, task-related data, and thread pool status data; generate thread pool parameter adjustment operations for the target thread pool based on the thread pool running status report; calculate the target thread pool parameter adjustment value using the thread pool parameter adjustment operation, and adjust the parameters of the target thread pool according to the parameter adjustment value. Thread pool parameter adjustment can be performed dynamically in real time based on thread pool parameter change events and thread pool running status data, thereby achieving real-time and precise thread pool parameter adjustment. The client can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented using a standalone server or a server cluster consisting of multiple servers. The invention will be described in detail below through specific embodiments.
[0015] Please see Figure 2 As shown, Figure 2 A flowchart illustrating the dynamic adjustment method for thread pool parameters provided in this embodiment of the invention includes the following steps: S1. Obtain the initial thread pool, and schedule the threads in the initial thread pool to the update thread pool corresponding to the pre-built parameter configuration center to obtain the configuration thread pool.
[0016] In this embodiment of the invention, the initial thread pool is a solution for Java applications to handle high concurrency and large tasks. The thread pool pre-creates a certain number of threads and keeps them in an idle state.
[0017] An initial thread pool can be created using the `Executors.newFixedThreadPool(int nThreads)` method, for example: `ExecutorService executorService = Executors.newFixedThreadPool(3);` where 3 indicates that there are 3 threads in the thread pool. When a task is submitted, the thread pool will allocate the task based on the availability of these 3 threads. If there are idle threads, the task will be assigned to an idle thread for execution; otherwise, the task will wait in the queue.
[0018] Specifically, the preset parameter configuration center is a configuration platform used to store the core parameters of the thread pool. It can configure parameters such as the core number of threads, the maximum number of threads, and the queue capacity, thereby generating and updating the thread pool for thread scheduling and obtaining the configured thread pool.
[0019] For example, the configuration center can be Apollo (A Config Service for Distributed Systems), Nacos (Dynamic service discovery, configuration and service management platform), Eureka service components, etc. The configuration center contains multiple pre-built configuration files for configuring thread pools.
[0020] Specifically, the step of scheduling threads from the initial thread pool to the update thread pool corresponding to the pre-built parameter configuration center to obtain the configuration thread pool includes: The configuration file is extracted from the parameter configuration center based on the business identifier of the initial thread pool; Determine the thread pool configuration parameters based on the configuration file, and build and update the thread pool based on the configuration parameters. The threads in the initial thread pool are scheduled to the updated thread pool to obtain the configured thread pool.
[0021] In this embodiment of the invention, the business identifier of the initial thread pool is a unique identifier when the thread pool processes business tasks. This business identifier distinguishes thread pool tasks under different business scenarios, facilitating rapid problem identification and performance tuning. Specifically, the business identifier can be identified based on the business identifier field (businessId) in the Java application task object, and then the configuration file corresponding to the business processed by the initial thread pool can be extracted from the parameter configuration center.
[0022] Specifically, the configuration file defines the thread pool's parameters, such as the core number of threads, the maximum number of threads, the thread idle time, and the capacity of the task queue. Then, the configuration information is retrieved from the configuration center through annotations or ConfigurableMapBinder to obtain the thread pool configuration parameters. Based on the thread pool configuration parameters, the thread pool builder class builds and updates the thread pool.
[0023] Furthermore, all threads in the initial thread pool can be directly scheduled to the new thread pool, or only the subsequent execution threads in the initial thread pool can be called to obtain the configured thread pool. By configuring the thread pool, the initial thread pool configuration can be updated without recompiling the thread pool constructor class, avoiding the overhead of frequently creating and destroying threads. This improves the efficiency of updating the initial thread pool parameter configuration and the throughput of task processing.
[0024] S2. Listen for thread pool parameter change events in the parameter configuration center, update the parameter configuration of the configured thread pool according to the thread pool parameter change events, and obtain the target thread pool.
[0025] In this embodiment of the invention, a thread pool parameter change event refers to an event triggered by the configuration center or client framework when the value of the thread pool configuration parameter in the parameter configuration center changes. By notifying the application of the configuration change through the thread pool parameter change event, the application can dynamically respond to these changes without restarting the application. The thread pool parameter change event is a key mechanism for achieving dynamic parameter control of the thread pool.
[0026] Specifically, the step of listening to thread pool parameter change events of the configured thread pool in the parameter configuration center includes: Create a configuration object in the parameter configuration center; Add an event listener to the parameter configuration center according to the method in the configuration object; The event listener is used to listen for thread pool parameter change events in the parameter configuration center.
[0027] In detail, an event listener class is a task class used to listen for thread pool parameter change events and respond based on time. Different event listener classes can be created depending on the parameter configuration center. For example, they can be created using the ConfigChangeListener interface, configuration message middleware, etc., and then a Config object can be injected using annotations. An event listener can be added using the methods in the injected Config object to listen for thread pool parameter change events in the configuration center.
[0028] Event listeners are a common pattern in software development used to execute corresponding processing logic when specific events occur. For example, when a thread pool parameter change event occurs, an event object can be created and the corresponding method of the listener can be called to listen for parameter configuration update events in the configuration center.
[0029] In this embodiment of the invention, updating the configuration parameters of the configured thread pool according to the thread pool parameter change event to obtain the target thread pool includes: Extract the thread pool change parameter value of the configured thread pool from the thread pool parameter change event; Calculate the thread pool change value of the configured thread pool based on the thread pool change parameter value; Determine the thread pool update method based on the thread pool change value; The parameter configuration of the configured thread pool is updated using the thread pool update method to obtain the target thread pool.
[0030] Specifically, new thread pool parameter configuration values, such as core thread count, maximum thread count, thread idle time, and queue capacity, are obtained from thread pool parameter change events. The thread pool change parameter values that have changed are obtained, and the difference between the thread pool change parameter values and the parameters in the configured thread pool is calculated to obtain the thread pool change value for each parameter. The thread pool update method is determined based on whether the queue capacity needs to be changed in the changed parameter values. If the queue capacity needs to be changed, the thread pool update method is to recreate the thread pool. If the queue capacity does not need to be changed, the thread pool update method is to update and replace the parameter values corresponding to the changed parameter values in the configured thread pool to obtain the target thread pool.
[0031] In this embodiment of the invention, by monitoring thread pool parameter change events in the parameter configuration center and updating the configuration thread pool parameters, the system can dynamically respond to changes in task configuration in the application, thereby flexibly adjusting the thread pool parameters.
[0032] S3. Collect thread-related data, task-related data, and thread pool status data of the target thread pool, and generate a thread pool running status report based on the thread-related data, task-related data, and thread pool status data.
[0033] In this embodiment of the invention, thread-related data includes the total number of threads, the number of active threads, etc.; task-related data includes the total number of tasks, the number of queued tasks, etc.; and thread pool status data includes the running status data of the target thread pool, such as the running status of the target thread pool. By analyzing the usage and load of the target thread pool through thread-related data, task-related data, and thread pool status data, the thread pool performance of the target thread pool can be monitored and managed.
[0034] Specifically, the target thread pool's runtime status data, such as thread-related data, task-related data, and thread pool status data, can be automatically collected through preset methods or monitoring tools and frameworks. For example, this can be achieved using methods provided by ThreadPoolExecutor, Prometheus, Grafana, Spring Boot Actuator, etc.
[0035] In this embodiment of the invention, the thread pool running status report is a visual summary and analysis of the running status of the target thread pool within a certain period of time. It can help developers or system administrators understand the performance, resource utilization, and potential problems of the target thread pool.
[0036] Specifically, the thread pool running status report typically includes the thread pool's basic configuration, key operating metrics, task processing status, trend analysis, and recommendations.
[0037] Specifically, generating a thread pool running status report based on the thread-related data, the task-related data, and the thread pool status data includes: The preset metric calculation engine is invoked to perform metric calculations on the thread-related data, the task-related data, and the thread pool status data to obtain metric data. The indicator data is matched with the fill characters in the preset report template to obtain the character area corresponding to each indicator data. The indicator data is filled into the corresponding character area to obtain the thread pool running status report.
[0038] In this embodiment of the invention, the metric calculation is to calculate the running metric data in thread-related data, task-related data, and thread pool status data. For example, the metric data includes the average time spent by a task from start to finish, the average time a task waits in the queue to be executed, the degree of thread utilization in the thread pool, the total number of tasks, the number of rejected tasks, the task submission rate, the task completion rate, and the queue task backlog trend (the trend of the number of tasks in the queue over time, used to determine whether the task backlog is worsening).
[0039] Specifically, the corresponding metric calculation engine can be invoked to calculate metrics based on thread-related data, task-related data, and thread pool state data. The metric calculation engine includes predefined business rules and algorithms to automatically calculate metric data for thread-related data, task-related data, and thread pool state data.
[0040] Furthermore, data matching involves matching the metric data with the fill characters in the preset report template. For example, the total number of tasks is matched with the character corresponding to the total number of tasks in the report template. Then, the metric data corresponding to the total number of tasks can be filled into the character area where the total number of tasks is located in the report template. Similarly, each metric data can be matched with the preset report template and the metric data can be filled into the corresponding fill position in the report template to obtain the thread pool running status report.
[0041] In this embodiment of the invention, the thread pool running status report can visualize the thread-related data, task-related data, and thread pool status data of the target thread pool, which can provide data support for subsequent thread pool parameter adjustment operations, detect abnormal behavior in a timely manner, and adjust the thread pool parameters more accurately.
[0042] S4. Generate thread pool parameter adjustment operations for the target thread pool based on the thread pool running status report.
[0043] In this embodiment of the invention, the thread pool parameter adjustment operation of the target thread pool refers to the action of adjusting the size of various configuration parameters of the target thread pool according to the actual load and resource usage during system operation. For example, the action of increasing or decreasing the core thread number, the maximum thread number, and the queue capacity, etc., to achieve the optimal performance and resource utilization strategy.
[0044] Specifically, the thread pool parameter adjustment operation based on the thread pool running status report includes: Extract time-dimensional features, task-dimensional features, and resource-dimensional features from the thread pool running status report; Analyze the system resource load of the target thread pool based on the time dimension characteristics, the task dimension characteristics, and the resource dimension characteristics; The thread pool parameter adjustment operation of the target thread pool is determined based on the system resource load.
[0045] In this embodiment of the invention, the multi-dimensional features are the multi-dimensional indicator data features in the thread pool running status report that reflect the execution status of the target thread pool, reflecting the running status and performance of the thread pool from different perspectives.
[0046] In detail, features can be calculated from the time dimension, such as the number of tasks submitted and completed per unit time in the thread pool's runtime status report; features can also be calculated from the task dimension, such as average task waiting time and average task execution time; and features can be calculated from the resource dimension, such as the ratio of CPU time used by all threads in the thread pool to the total time to obtain CPU utilization, and the amount of memory used by the thread pool and related task data structures to obtain memory usage. Furthermore, multi-dimensional features can be composed of indicators from multiple perspectives, such as average number of active threads, task throughput, resource utilization, task timeout rate, and thread pool congestion rate, to comprehensively analyze the performance and runtime status of the target thread pool.
[0047] Furthermore, the load mode of the target thread pool refers to the load characteristics and change patterns exhibited during operation, reflecting the usage of system resources (such as CPU, memory, network bandwidth, etc.) and the submission and execution of tasks. It can include a variety of preset load modes such as stable load mode, periodic load mode, burst load mode, random load mode, increasing load mode, and decreasing load mode.
[0048] In this embodiment of the invention, a pre-built machine learning model can be used to calculate the load pattern of the target thread pool based on multi-dimensional features.
[0049] Specifically, preset business rules can be used to determine the thread pool's control actions, such as increasing the number of threads, decreasing the number of threads, or expanding the queue capacity. Then, based on these control actions, thread pool parameter control operations can be generated to dynamically adjust the thread pool configuration. For example, if an increase in system load is predicted, the number of threads can be increased or the queue capacity expanded in advance to cope with the upcoming high load; if a decrease in system load is predicted, the number of threads can be reduced to save resources. This allows for dynamic adjustment of the thread pool configuration to optimize system performance and resource utilization.
[0050] S5. Use the thread pool parameter adjustment operation to adjust the parameters of the target thread pool.
[0051] In this embodiment of the invention, parameter control involves adjusting parameters such as the core number of threads, the maximum number of threads, and the queue capacity of the target thread pool, so that the target thread pool can automatically achieve dynamic expansion and contraction according to the load conditions, and efficiently control the thread pool.
[0052] Specifically, the step of calculating the target thread pool parameter adjustment value using the thread pool parameter adjustment operation, and adjusting the target thread pool parameters according to the parameter adjustment value, includes: Obtain the parameter limit range for each thread pool parameter of the target thread pool; The parameter adjustment value for each thread pool parameter is calculated based on the thread pool parameter adjustment operation and the parameter limit range; The parameters of the target thread pool are adjusted using the aforementioned parameter adjustment values.
[0053] In this embodiment of the invention, the parameter limitation range is the resource limitation of the target thread pool, that is, the adjustment range of the number of threads and queue capacity of the thread pool. This can ensure that the adjustment of the number of threads and queue capacity of the target thread pool is within a reasonable range and avoids exceeding the system resource limit.
[0054] Furthermore, the thread pool parameter adjustment operation determines whether to increase the number of threads, expand the queue capacity, or decrease the number of threads. At the same time, the parameter limit range ensures that the increase or decrease in the number of threads is within a reasonable range, thus guaranteeing the normal operation of the target thread pool.
[0055] In this embodiment of the invention, the parameter values that need to be adjusted are calculated through thread pool parameter adjustment operations and parameter limit range calculations, such as the number of threads that need to be increased or decreased. The parameters of the target thread pool are adjusted through running status data to achieve efficient control of the thread pool.
[0056] As can be seen, in the above scheme, the initial thread pool is configured through a preset parameter configuration center to obtain the configured thread pool; thread pool parameter change events are monitored in the parameter configuration center, and the configured thread pool is updated according to the thread pool parameter change events to obtain the target thread pool. This can dynamically respond to changes in task configuration in the application, and thus flexibly update the thread pool; thread-related data, task-related data, and thread pool status data of the target thread pool are collected, and a thread pool running status report is generated based on the thread-related data, task-related data, and thread pool status data. This provides data support for subsequent thread pool parameter adjustment operations, timely detection of abnormal behavior, and more precise parameter adjustment of the thread pool; thread pool parameter adjustment operations for the target thread pool are generated based on the thread pool running status report. The thread pool configuration can be dynamically adjusted using thread pool parameter adjustment operations to optimize system performance and resource utilization. At the same time, the parameter values that need to be adjusted are determined through thread pool parameter adjustment operations, achieving efficient thread pool control.
[0057] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0058] In one embodiment, a dynamic thread pool parameter control system is provided, which corresponds one-to-one with the dynamic thread pool parameter control method described in the above embodiments. For example... Figure 3As shown, the thread pool parameter dynamic control system includes a parameter configuration module 101, a parameter configuration update module 102, a report generation module 103, a parameter control action generation module 104, and a parameter control module 105. Detailed descriptions of each functional module are as follows: The parameter configuration module 101 is used to obtain the initial thread pool and schedule the threads in the initial thread pool to the update thread pool corresponding to the pre-built parameter configuration center to obtain the configuration thread pool. The parameter configuration update module 102 is used to listen for thread pool parameter change events of the configured thread pool in the parameter configuration center, and update the parameter configuration of the configured thread pool according to the thread pool parameter change events to obtain the target thread pool. The report generation module 103 is used to collect thread-related data, task-related data and thread pool status data of the target thread pool, and generate a thread pool running status report based on the thread-related data, task-related data and thread pool status data. The parameter adjustment action generation module 104 is used to generate thread pool parameter adjustment operations for the target thread pool based on the thread pool running status report. The parameter control module 105 is used to calculate the target thread pool parameter control value using the thread pool parameter control operation, and to control the target thread pool parameters according to the parameter control value.
[0059] In one embodiment, the data processing module 101 schedules threads from the initial thread pool to the update thread pool corresponding to the pre-built parameter configuration center to obtain a configuration thread pool, including: The configuration file is extracted from the parameter configuration center based on the business identifier of the initial thread pool; The thread pool configuration parameters are determined according to the configuration file, and the thread pool is built and updated according to the thread pool configuration parameters; The threads in the initial thread pool are scheduled to the updated thread pool to obtain the configured thread pool.
[0060] In one embodiment, the parameter configuration update module 102 listens for thread pool parameter change events of the configured thread pool in the parameter configuration center, including: Create a configuration object in the parameter configuration center; Add an event listener to the parameter configuration center according to the method in the configuration object; The event listener is used to monitor thread pool parameter change events in the parameter configuration center. In one embodiment, the parameter configuration update module 102 updates the parameter configuration of the configured thread pool according to the thread pool parameter change event to obtain the target thread pool, including: Extract the thread pool change parameter value of the configured thread pool from the thread pool parameter change event; Calculate the thread pool change value of the configured thread pool based on the thread pool change parameter value; Determine the thread pool update method based on the thread pool change value; The thread pool configuration is updated using the thread pool update method based on the changed parameter values to obtain the target thread pool.
[0061] In one embodiment, the report generation module 103 generates a thread pool running status report based on the thread-related data, the task-related data, and the thread pool status data, including: The preset metric calculation engine is invoked to perform metric calculations on the thread-related data, the task-related data, and the thread pool status data to obtain metric data. The indicator data is matched with the fill characters in the preset report template to obtain the character area corresponding to each indicator data. The indicator data is filled into the corresponding character area to obtain the thread pool running status report.
[0062] In one embodiment, the parameter adjustment action generation module 104 generates thread pool parameter adjustment operations for the target thread pool based on the thread pool running status report, including: Extract time-dimensional features, task-dimensional features, and resource-dimensional features from the thread pool running status report; Analyze the system resource load of the target thread pool based on the time dimension characteristics, the task dimension characteristics, and the resource dimension characteristics; The thread pool parameter adjustment operation of the target thread pool is determined based on the system resource load.
[0063] In one embodiment, the parameter control module 105 calculates the target thread pool parameter control value using the thread pool parameter control operation, and performs parameter control on the target thread pool according to the parameter control value, including: Obtain the parameter limit range for each thread pool parameter of the target thread pool; The parameter adjustment value for each thread pool parameter is calculated based on the thread pool parameter adjustment operation and the parameter limit range; The parameters of the target thread pool are adjusted using the aforementioned parameter adjustment values.
[0064] This invention provides a dynamic thread pool parameter control system. It configures an initial thread pool using a pre-defined parameter configuration center to obtain a configured thread pool. It monitors thread pool parameter change events in the parameter configuration center and updates the configured thread pool's parameter configuration accordingly to obtain a target thread pool. This system can dynamically respond to changes in task configurations within the application, allowing for flexible thread pool updates. It collects thread-related data, task-related data, and thread pool status data from the target thread pool and generates a thread pool runtime status report based on this data. This report provides data support for subsequent thread pool parameter control operations, enabling timely detection of abnormal behavior and more precise parameter control. Based on the thread pool runtime status report, it generates thread pool parameter control operations for the target thread pool. These operations allow for dynamic adjustment of the thread pool configuration to optimize system performance and resource utilization. Furthermore, the system determines the parameter values to be controlled, achieving efficient thread pool control.
[0065] For specific limitations regarding the thread pool parameter dynamic adjustment system, please refer to the limitations of the thread pool parameter dynamic adjustment method mentioned above, which will not be repeated here. Each module in the aforementioned thread pool parameter dynamic adjustment system can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of the computer device in hardware form or independent of it, or they can be stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of each module.
[0066] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 4 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external clients via a network connection. When the computer program is executed by the processor, it implements the server-side functions or steps of a thread pool parameter dynamic adjustment method.
[0067] In one embodiment, a computer device is provided, which may be a client, and its internal structure diagram may be as follows: Figure 5As shown, the computer device includes a processor, memory, network interface, display screen, and input system connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it implements client-side functions or steps of a thread pool parameter dynamic adjustment method.
[0068] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps: Obtain the initial thread pool, and schedule the threads in the initial thread pool to the update thread pool corresponding to the pre-built parameter configuration center to obtain the configuration thread pool; Listen for thread pool parameter change events in the parameter configuration center, update the parameter configuration of the configured thread pool according to the thread pool parameter change events, and obtain the target thread pool; Collect thread-related data, task-related data, and thread pool status data of the target thread pool, and generate a thread pool running status report based on the thread-related data, task-related data, and thread pool status data; Based on the thread pool running status report, generate thread pool parameter adjustment operations for the target thread pool; The target thread pool parameter adjustment value is calculated using the thread pool parameter adjustment operation, and the target thread pool is adjusted according to the parameter adjustment value.
[0069] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor: Obtain the initial thread pool, and schedule the threads in the initial thread pool to the update thread pool corresponding to the pre-built parameter configuration center to obtain the configuration thread pool; Listen for thread pool parameter change events in the parameter configuration center, update the parameter configuration of the configured thread pool according to the thread pool parameter change events, and obtain the target thread pool; Collect thread-related data, task-related data, and thread pool status data of the target thread pool, and generate a thread pool running status report based on the thread-related data, task-related data, and thread pool status data; Based on the thread pool running status report, generate thread pool parameter adjustment operations for the target thread pool; The target thread pool parameter adjustment value is calculated using the thread pool parameter adjustment operation, and the target thread pool is adjusted according to the parameter adjustment value.
[0070] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to the relevant descriptions on the server side and client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0071] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0072] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the system can be divided into different functional units or modules to complete all or part of the functions described above.
[0073] Finally, it should be noted that if any software tools or components not belonging to this company appear in the embodiments of the application, they are merely illustrative examples and do not represent actual use. The embodiments described above are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A method for dynamically adjusting thread pool parameters, characterized in that, include: Obtain the initial thread pool, and schedule the threads in the initial thread pool to the update thread pool corresponding to the pre-built parameter configuration center to obtain the configuration thread pool; Listen for thread pool parameter change events in the parameter configuration center, update the parameter configuration of the configured thread pool according to the thread pool parameter change events, and obtain the target thread pool; Collect thread-related data, task-related data, and thread pool status data of the target thread pool, and generate a thread pool running status report based on the thread-related data, task-related data, and thread pool status data; Based on the thread pool running status report, generate thread pool parameter adjustment operations for the target thread pool; The target thread pool parameter adjustment value is calculated using the thread pool parameter adjustment operation, and the target thread pool is adjusted according to the parameter adjustment value.
2. The method for dynamically adjusting thread pool parameters as described in claim 1, characterized in that, The step of scheduling threads from the initial thread pool to the update thread pool corresponding to the pre-built parameter configuration center to obtain the configuration thread pool includes: The configuration file is extracted from the parameter configuration center based on the business identifier of the initial thread pool; The thread pool configuration parameters are determined according to the configuration file, and the thread pool is built and updated according to the thread pool configuration parameters; The threads in the initial thread pool are scheduled to the updated thread pool to obtain the configured thread pool.
3. The method for dynamically adjusting thread pool parameters as described in claim 1, characterized in that, The monitoring of thread pool parameter change events in the parameter configuration center includes: Create a configuration object in the parameter configuration center; Add an event listener to the parameter configuration center according to the method in the configuration object; The event listener is used to listen for thread pool parameter change events in the parameter configuration center.
4. The method for dynamically adjusting thread pool parameters as described in claim 1, characterized in that, The step of updating the configuration parameters of the configured thread pool according to the thread pool parameter change event to obtain the target thread pool includes: Extract the thread pool change parameter value of the configured thread pool from the thread pool parameter change event; Calculate the thread pool change value of the configured thread pool based on the thread pool change parameter value; Determine the thread pool update method based on the thread pool change value; The parameter configuration of the configured thread pool is updated using the thread pool update method to obtain the target thread pool.
5. The method for dynamically adjusting thread pool parameters as described in claim 1, characterized in that, The step of generating a thread pool running status report based on the thread-related data, the task-related data, and the thread pool status data includes: The preset metric calculation engine is invoked to perform metric calculations on the thread-related data, the task-related data, and the thread pool status data to obtain metric data. The indicator data is matched with the fill characters in the preset report template to obtain the character area corresponding to each indicator data. The indicator data is filled into the corresponding character area to obtain the thread pool running status report.
6. The method for dynamically adjusting thread pool parameters as described in claim 1, characterized in that, The thread pool parameter adjustment operation, which generates the target thread pool based on the thread pool running status report, includes: Extract time-dimensional features, task-dimensional features, and resource-dimensional features from the thread pool running status report; Analyze the system resource load of the target thread pool based on the time dimension characteristics, the task dimension characteristics, and the resource dimension characteristics; The thread pool parameter adjustment operation of the target thread pool is determined based on the system resource load.
7. The method for dynamically adjusting thread pool parameters as described in claim 1, characterized in that, The step of calculating the target thread pool parameter adjustment value using the thread pool parameter adjustment operation, and adjusting the target thread pool parameters according to the parameter adjustment value, includes: Obtain the parameter limit range for each thread pool parameter of the target thread pool; The parameter adjustment value for each thread pool parameter is calculated based on the thread pool parameter adjustment operation and the parameter limit range; The parameters of the target thread pool are adjusted using the aforementioned parameter adjustment values.
8. A thread pool parameter dynamic control system, characterized in that, include: The parameter configuration module is used to obtain the initial thread pool and schedule the threads in the initial thread pool to the update thread pool corresponding to the pre-built parameter configuration center to obtain the configuration thread pool. The parameter configuration update module is used to listen for thread pool parameter change events of the configured thread pool in the parameter configuration center, and update the parameter configuration of the configured thread pool according to the thread pool parameter change events to obtain the target thread pool. The report generation module is used to collect thread-related data, task-related data and thread pool status data of the target thread pool, and generate a thread pool running status report based on the thread-related data, task-related data and thread pool status data; The parameter adjustment action generation module is used to generate thread pool parameter adjustment operations for the target thread pool based on the thread pool running status report. The parameter control module is used to calculate the target thread pool parameter control value using the thread pool parameter control operation, and to control the parameters of the target thread pool according to the parameter control value.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the thread pool parameter dynamic adjustment method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the thread pool parameter dynamic adjustment method as described in any one of claims 1 to 7.