Thread pool management architecture and thread pool management method
By using a thread pool management architecture and methods, thread pool specifications can be monitored and adjusted in real time, solving the problem of performance optimization that cannot be done in a timely manner in existing technologies and improving performance optimization efficiency.
Patent Information
- Application Number
- CN202311111863.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-30
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2043-08-30
AI Technical Summary
Existing technologies cannot adjust thread pool specifications in a timely manner after thread pool performance issues arise, resulting in low efficiency in performance optimization.
The system collects the running status data of the thread pool from the business system and uploads it to the thread pool management system. The management system determines whether the performance meets the preset requirements based on the status data. If it does not meet the requirements, it sends a request to the business system to update the parameters. The business system then adjusts the thread pool specifications to meet the performance requirements.
This allows for timely adjustment of thread pool parameters when performance issues arise, improving performance optimization efficiency.
Smart Images

Figure CN117170842B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of operating system technology, and in particular to a thread pool management architecture and thread pool management method. Background Technology
[0002] With the increasing prevalence of high-concurrency scenarios and the widespread use of multithreading technology, improving resource utilization has become a challenge for multithreaded applications.
[0003] Currently, existing business systems pre-build thread pools using thread pooling technology. When processing business requests, if performance issues arise, the system is shut down to check thread pool parameters one by one and adjust the thread pool specifications to optimize performance. However, this method adjusts thread pool specifications after a shutdown, failing to adjust them immediately after a performance issue occurs, resulting in low performance optimization efficiency.
[0004] The above content is only used to help understand the technical solution of the present invention and does not represent an admission that the above content is prior art. Summary of the Invention
[0005] The main objective of this invention is to provide a thread pool management architecture and method, aiming to solve the technical problem that existing technologies, which involve adjusting thread pool specifications after a shutdown, cannot optimize performance issues in the immediate aftermath of performance problems, resulting in low performance optimization efficiency.
[0006] To achieve the above objectives, the present invention provides a thread pool management architecture, the architecture comprising: a business system and a thread pool management system;
[0007] The business system is deployed with an SDK tool, which provides a first interface and a second interface. The business system calls the thread pool provided by the target vendor through the first interface. The thread pool is used to process business requests. The business system connects to the thread pool management system through the second interface.
[0008] The business system is also used to collect the running status data of the thread pool and upload the running status data to the thread pool management system through the second interface;
[0009] The thread pool management system is used to determine whether the thread pool performance meets the preset performance requirements corresponding to the business request based on the running status data.
[0010] The thread pool management system is also used to send a request to update parameters to the business system through the second interface when the preset performance requirements are not met.
[0011] The business system is also used to adjust the thread pool specifications according to the request update parameters so that the thread pool performance meets the preset performance requirements.
[0012] Optionally, the thread pool management architecture includes: a monitoring module, a decision-making module, and a management module;
[0013] Both the monitoring module and the management module are connected to the business system through the second interface;
[0014] The monitoring module is used to receive the running status data uploaded by the business system through the second interface;
[0015] The decision module is used to extract the running resource data and thread pool data from the running status data, and determine the task type of the business request based on the running resource data;
[0016] The management module is also used to generate the request update parameters and feed back the request update parameters to the decision module when the performance of the thread pool does not meet the preset performance requirements.
[0017] The decision module is also used to check and evaluate the request update parameters according to the task type and the thread pool data, and to feed back the evaluation result to the management module when the check and evaluation is passed;
[0018] The management module is used to send the request to update parameters to the business system through the second interface.
[0019] Optionally, the decision module is further configured to determine the number of worker threads in the thread pool based on the thread pool data;
[0020] The decision module is also used to determine whether the number of worker threads is lower than a first preset threshold when the task type is IO intensive.
[0021] The decision module is also used to determine that the parameter update request has passed the evaluation when the number of worker threads is not lower than the first preset threshold.
[0022] Optionally, the decision module is further configured to determine whether the number of worker threads reaches a second preset threshold when the task type is computationally intensive, wherein the second preset threshold is higher than the first preset threshold;
[0023] The decision module is also used to determine that the parameter update request has passed the evaluation when the number of worker threads has not reached the second preset threshold.
[0024] Optionally, the thread pool management system further includes: an early warning module;
[0025] The monitoring module is also used to extract thread pool task data from the running status data;
[0026] The early warning module is used to determine the thread pool running status based on the thread pool data, and to determine the thread pool task execution status based on the thread pool task data.
[0027] The early warning module is also used to push alarm information to the target terminal when the thread pool running state or the task execution state fails to meet the standard.
[0028] Optionally, the management module is further configured to extract the configuration time and scaling strategy from the thread pool configuration information when it receives the thread pool configuration information;
[0029] The management module is also used to generate timed adjustment parameters according to the scaling strategy when the current time reaches the configured time, and send the timed adjustment parameters to the business system through the second interface;
[0030] The business system is also used to adjust the thread pool specification to the specification corresponding to the scaling strategy according to the timed adjustment parameters.
[0031] Optionally, the business system is further configured to obtain the unified programming model provided by the SDK tool when receiving the business request;
[0032] The business system is also used to package the business request into an orchestratable task according to the unified programming model, and to orchestrate the orchestratable task to obtain a task queue composed of each task.
[0033] The business system is also used to call the thread pool through the first interface, and to chain the threads in the thread pool together according to the task orchestration method of the task queue to obtain the target thread;
[0034] The business system is also used to add each task in the task queue to the thread pool in sequence, and execute each task through the target thread.
[0035] Optionally, the business system is further configured to, upon detecting a thread pool shutdown instruction, pause the operation of sequentially adding each task in the task queue to the thread pool, and check whether there are any active threads processing tasks in the thread pool;
[0036] The business system is also used to close the thread pool after the active thread has finished executing when the active thread exists.
[0037] The business system is also configured to shut down the thread pool if the active thread has not completed execution when the waiting time reaches a preset waiting time.
[0038] Furthermore, to achieve the above objectives, this invention also proposes a thread pool management method based on the thread pool management architecture described above. The thread pool management method is executed by the thread pool management system, and the method includes:
[0039] Receive runtime status data uploaded by the business system, wherein the runtime status data is generated by the thread pool invoked by the business system when processing business requests;
[0040] Based on the running status data, determine whether the thread pool performance meets the preset performance requirements corresponding to the business request;
[0041] If the preset performance requirements are not met, a request to update parameters is sent to the business system so that the business system can adjust the thread pool specifications through the request to update parameters so that the thread pool performance meets the preset performance requirements.
[0042] Furthermore, to achieve the above objectives, this invention also proposes a thread pool management method. This method is applied to an architecture comprising a business system and a thread pool management system. The business system deploys an SDK tool, which provides a first interface and a second interface. The business system calls a thread pool provided by a target vendor through the first interface. The thread pool is used to process business requests. The business system connects to the thread pool management system through the second interface. The method includes:
[0043] The business system collects the running status data of the thread pool and uploads the running status data to the thread pool management system through the second interface;
[0044] The thread pool management system determines whether the thread pool performance meets the preset performance requirements corresponding to the business request based on the running status data.
[0045] When the preset performance requirements are not met, the thread pool management system sends a request to the business system to update parameters through the second interface.
[0046] The business system adjusts the thread pool specifications according to the updated parameters of the request, so that the performance of the thread pool meets the preset performance requirements.
[0047] This invention provides a thread pool management architecture and method. The architecture includes a business system and a thread pool management system. The business system deploys an SDK tool, which provides a first interface and a second interface. The business system calls a thread pool provided by a target vendor to handle business requests through the first interface, and connects to the thread pool management system through the second interface. This invention collects runtime status data of the thread pool from the business system and uploads this data to the thread pool management system via the SDK tool. The thread pool management system determines whether the thread pool performance meets the preset performance requirements corresponding to the business request based on the runtime status data. If the preset performance requirements are not met, the thread pool management system sends a request to update parameters to the business system through the second interface. The business system adjusts the thread pool specifications according to the updated parameters to ensure that the thread pool performance meets the preset performance requirements. The business system of this invention uploads the running status data of the acquisition thread pool to the thread pool management system through a first interface. When the thread pool management system determines that the thread pool performance does not meet the preset performance requirements based on the running status data, it sends a request to update parameters to the business system through a second interface, so that the business system can adjust the thread pool to meet the preset performance requirements. Compared with the prior art, which adjusts the thread pool specifications after a shutdown if a performance problem is encountered, and cannot optimize the performance problem in a timely manner, the above-mentioned system of this invention can adjust the thread pool parameters to optimize the performance problem as soon as a performance problem occurs, effectively improving the efficiency of performance optimization. Attached Figure Description
[0048] Figure 1 This is a schematic diagram of the first embodiment of the thread pool management architecture of the present invention;
[0049] Figure 2 This is a schematic diagram of a thread pool in the first embodiment of the thread pool management architecture of the present invention;
[0050] Figure 3 This is a schematic diagram of thread pool operation in the first embodiment of the thread pool management architecture of the present invention;
[0051] Figure 4 This is a schematic diagram of the second embodiment of the thread pool management architecture of the present invention;
[0052] Figure 5 This is a flowchart illustrating the first embodiment of the thread pool management method of the present invention;
[0053] Figure 6 This is a flowchart illustrating the second embodiment of the thread pool management method of the present invention.
[0054] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0055] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0056] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0057] It should be noted that the descriptions involving "first," "second," etc., in the embodiments of the present invention are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, features defined with "first" and "second" may explicitly or implicitly include at least one of those features. Furthermore, the technical solutions of the various embodiments can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. If the combination of technical solutions is contradictory or impossible to implement, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection claimed by the present invention.
[0058] This invention provides a thread pool management architecture, referring to Figure 1 , Figure 1 This is a schematic diagram of the first embodiment of the thread pool management architecture of the present invention.
[0059] The architecture includes: business system 100 and thread pool management system 200.
[0060] The business system 100 is equipped with an SDK tool, which provides a first interface and a second interface. The business system 100 calls the thread pool provided by the target vendor through the first interface. The thread pool is used to process business requests. The business system 100 connects to the thread pool management system 200 through the second interface.
[0061] The business system 100 is also used to collect the running status data of the thread pool and upload the running status data to the thread pool management system 200 through the second interface.
[0062] It should be noted that the aforementioned Software Development Kit (SDK) can be a toolkit for calling the thread pool provided by a third-party service provider. This third-party service provider is the aforementioned target vendor. The SDK tool provides various Application Programming Interfaces (APIs), and the first and second interfaces mentioned above are these API interfaces. The first interface can proxy the thread pool, allowing the business system 100 to call the thread pool through this interface, thus achieving the thread pool function without locally creating the thread pool. Simultaneously, the second interface can be used to establish a connection with the thread pool management system 200 for communication.
[0063] Understandably, the aforementioned thread pool can be a container pool that maintains a set of reusable threads. This thread pool can be built by the target vendor mentioned above. When a business system executes a business request task, it can reuse threads from the thread pool without creating new threads, thereby improving business processing efficiency.
[0064] It should be noted that the above-mentioned running status data can be a series of status data generated when the thread pool executes tasks, such as thread tasks, running resources, task processing time, etc.
[0065] In its implementation, the aforementioned business system 100 can obtain an SDK tool provided by the target vendor. This SDK tool serves as a development and integration environment, allowing the business system 100 to call API interfaces, namely the first and second interfaces mentioned above. Upon receiving a business request task, the business system 100 can invoke the thread pool through the first interface, using the worker threads provided by the thread pool to execute the task. Simultaneously, the business system 100 can retrieve a pre-built plugin library locally. During thread pool runtime, it monitors the thread pool through plugins in this library, polling and scanning the status of the thread pool, thread tasks, and runtime resources to obtain runtime status data. This data is then uploaded to the thread pool management system 200 via the second interface. The plugin library possesses good extensibility, allowing developers to implement custom listeners by extending the plugin library interface.
[0066] It should be understood that the business request tasks submitted to the thread pool for processing can be named according to the business scenario. By default, tasks are identified by their Java class, method name, and line number. Furthermore, the thread pool has good compatibility and can be used in conjunction with open-source Tomcat containers, the Okhttp framework, and the in-house ZA21 framework.
[0067] Furthermore, in this embodiment, the business system 100 is also used to obtain the unified programming model provided by the SDK tool when receiving the business request.
[0068] It should be noted that the above unified programming model can be used to orchestrate business requests and form processing tasks that meet the requirements of a thread pool.
[0069] In the specific implementation, since the processing of business requests has a logical order, the aforementioned business system 100 can obtain the SDK to arrange the business requests according to the order of the business requests based on the provided unified programming model when it receives the business request, forming a task that meets the requirements of the thread pool and can be processed by the thread pool.
[0070] The business system 100 is further configured to package the business request into an orchestratable task according to the unified programming model, and to orchestrate the orchestratable task to obtain a task queue composed of each task.
[0071] In a specific implementation, the aforementioned business system 100 can determine the order of business requests using the above-mentioned unified programming model and fluent code style, and arrange the business requests in order according to the set task orchestration method, that is, specify which tasks to process first and which tasks to process later. Then, the orchestrated tasks are packaged to form multiple orchestratable tasks, and then the orchestratable tasks are chained together to form a task queue composed of each task and arranged in the above-mentioned task orchestration method.
[0072] The business system 100 is also used to call the thread pool through the first interface and chain the threads in the thread pool together according to the task orchestration method of the task queue to obtain the target thread.
[0073] In a specific implementation, the aforementioned business system 100 can call the aforementioned thread pool through the aforementioned first interface, and then chain together the worker threads in the thread pool according to the task orchestration method of the task queue to form a thread string that matches the task queue, so as to accurately process the task queue.
[0074] For ease of understanding, please refer to Figure 2 This explanation does not limit the scope of this solution. Figure 2 This is a schematic diagram of a thread pool in the first embodiment of the thread pool management architecture of the present invention. Figure 2In this example, the SDK tool can proxy multiple thread pools. We will use two thread pools, Thread Pool 1 and Thread Pool 2, as an example. Depending on the task orchestration method, Thread Pool 1 can be connected by one thread to two parallel threads. During task execution, one thread is executed first, followed by the execution of two parallel threads simultaneously. Either of these threads can repeat this process. Thread Pool 2 can be connected by two parallel threads to one thread. During task execution, two threads are executed in parallel first, followed by the execution of one thread. This thread can execute concurrently with another parallel thread, repeating the task execution process. Besides the thread connection method between Thread Pool 1 and Thread Pool 2, it can also be a combination of Thread Pool 1 and Thread Pool 2, or other connection methods. This embodiment does not limit this. To improve thread pool management efficiency, TCC transaction management for multiple tasks can be provided for Thread Pool 1 and Thread Pool 2.
[0075] The business system 100 is also used to add each task in the task queue to the thread pool in sequence, and execute each task through the target thread.
[0076] In a specific implementation, the aforementioned business system 100 can add each task in the task queue to the thread pool in sequence, and the worker threads in the thread pool can execute each task in sequence to complete the processing of business requests.
[0077] For ease of understanding, please refer to Figure 3 This explanation does not limit the scope of this solution. Figure 3 This is a schematic diagram of thread pool operation in the first embodiment of the thread pool management architecture of the present invention. Figure 3 In the SDK tools, the thread pools they manage can include a blocking queue, a maximum thread pool, and a core thread pool. When a task in the task queue is added to a thread pool, it is first executed by a thread connected in the core thread pool, such as one thread connected to two threads in parallel (or two parallel threads connected to one thread, which is not limited). When all core thread pools are executing tasks and there are no idle threads, the tasks in the task queue can be added to the maximum thread pool for execution. This maximum thread pool can be a backup thread pool expanded under the current hardware resources. Here, the maximum thread pool is configured as two parallel threads connected to one thread, or one thread connected to two threads in parallel, which is not limited. When there are no idle threads in the maximum thread pool, the tasks in the task queue can be stored in the blocking queue. That is, each task in the blocking queue is a task waiting for an idle thread to process. When there are idle threads in the maximum thread pool or the core thread pool, each task in the blocking queue can be added to the maximum thread pool or the core thread pool in turn, and the idle thread will execute the task.
[0078] Furthermore, in this embodiment, the business system 100 is also used to pause the operation of sequentially adding each task in the task queue to the thread pool when a thread pool shutdown instruction is detected, and to check whether there are active threads processing tasks in the thread pool.
[0079] It should be noted that the above thread pool shutdown command is the command to shut down the thread pool and stop it from running.
[0080] In the specific implementation, when the above business system 100 detects the thread pool shutdown instruction, if the tasks in the task queue have not yet been completed by the thread pool, it will pause the tasks in the task queue that have not yet been added to the thread pool and stop their transmission to the thread pool for processing. At the same time, it will further check whether there are still active threads in the thread pool that are processing tasks.
[0081] The business system 100 is also used to close the thread pool after the active thread has finished executing when the active thread exists.
[0082] In practical implementation, to ensure uninterrupted business operations, the aforementioned business system can continue to wait for active threads to complete their currently executing tasks while there are still active threads in the thread pool. The thread pool can then be closed after all active threads have completed their tasks, thus ensuring uninterrupted business operations and improving user experience.
[0083] The business system 100 is also configured to shut down the thread pool if the active thread has not completed execution when the waiting time reaches a preset waiting time.
[0084] It should be noted that the above-mentioned preset waiting time can be pre-set and is used to determine whether the time for waiting for the active thread to complete the task is the process time.
[0085] In its implementation, the aforementioned business system 100 can determine that the waiting time is too long when the waiting time for an active thread to complete its task reaches a preset time. At this point, the thread pool can be shut down directly to ensure that the thread pool is closed, avoid unnecessary waste of resources, and meet the expectations of developers or users to close the thread pool, thereby improving the user experience.
[0086] The thread pool management system 200 is used to determine whether the thread pool performance meets the preset performance requirements corresponding to the business request based on the running status data.
[0087] It should be noted that the above-mentioned preset performance requirements can be the requirements set when configuring business requests. For example, the preset performance requirements can be to require the thread pool to complete the business request within a specified time, or to require the thread pool to complete the business request with the best performance.
[0088] In its implementation, the thread pool management system 200 can determine whether the thread pool performance meets the preset performance requirements corresponding to the business request based on the core thread pool count, maximum thread pool count, or thread pool load in the above-mentioned running status data. For example, if the preset performance requirement is that the thread pool completes the business request with optimal performance, and the core thread pool is not fully utilized, it can be determined that the thread pool size is too large and fails to achieve optimal performance. As another example, if the preset performance requirement is that the thread pool completes the business request within a specified time, and the core thread pool is fully utilized but still cannot complete the business request within the specified time, it can be determined that the thread pool size is too small and fails to achieve optimal performance.
[0089] The thread pool management system 200 is also used to send a request to update parameters to the business system 100 through the second interface when the preset performance requirements are not met.
[0090] It should be noted that the above request update parameters can be parameters for adjusting the thread pool specifications.
[0091] In its implementation, the thread pool management system 200 can determine that the thread pool size needs to be adjusted when it detects that the thread pool performance fails to meet the preset performance requirements corresponding to the business request. At this time, it can generate request update parameters according to the thread pool specifications. If the thread pool specifications are too large and cannot meet the preset performance requirements, it can generate request update parameters to reduce the thread pool specifications. If the thread pool specifications are too small and cannot meet the preset performance requirements, it can generate request update parameters to increase the thread pool specifications. Then, it sends the request update parameters to the business system 100 through the second interface.
[0092] The business system 100 is also used to adjust the thread pool specifications according to the request update parameters so that the thread pool performance meets the preset performance requirements.
[0093] In the specific implementation, the above-mentioned business system 100 can adjust the thread pool specifications according to the above-mentioned request update parameters, so that the number of worker threads corresponds to the business request tasks, avoiding the number of worker threads being more than the number of tasks, and also avoiding the number of worker threads being less than the number of tasks, so that the thread pool specifications meet the preset performance requirements.
[0094] This embodiment's thread pool management architecture includes a business system and a thread pool management system. The business system deploys an SDK tool, which provides a first interface and a second interface. The business system calls the thread pool provided by the target vendor to handle business requests through the first interface, and connects to the thread pool management system through the second interface. This embodiment collects the thread pool's runtime status data through the business system and uploads this data to the thread pool management system via the SDK tool. The thread pool management system determines whether the thread pool's performance meets the preset performance requirements corresponding to the business request based on the runtime status data. If the preset performance requirements are not met, the thread pool management system sends a request to update parameters to the business system through the second interface. The business system adjusts the thread pool specifications according to the updated parameters to ensure that the thread pool's performance meets the preset performance requirements. In this embodiment, the business system uploads the running status data of the acquisition thread pool to the thread pool management system through the first interface. When the thread pool management system determines that the thread pool performance does not meet the preset performance requirements based on the running status data, it sends a request to update parameters to the business system through the second interface, so that the business system can adjust the thread pool to meet the preset performance requirements. Compared with the prior art, if a performance problem is encountered, the thread pool specifications are adjusted after a shutdown, which cannot optimize the performance problem in a timely manner, the above system in this embodiment can adjust the thread pool parameters to optimize the performance problem as soon as a performance problem occurs, effectively improving the performance optimization efficiency.
[0095] refer to Figure 4 , Figure 4 This is a schematic diagram of the second embodiment of the thread pool management architecture of the present invention.
[0096] Based on the first embodiment described above, in this embodiment, the thread pool management architecture 200 includes: a monitoring module 201, a decision module 203, and a management module 202.
[0097] Both the monitoring module 201 and the management module 202 are connected to the business system 100 through the second interface.
[0098] The monitoring module 201 is used to receive the operating status data uploaded by the business system 100 through the second interface.
[0099] In a specific implementation, the monitoring module 201 can be responsible for receiving the running status data collected by the plug-in in the business system 100. The running status data may include thread pool data, thread task data and running resource data. The thread pool data includes the number of worker threads, queue depth, thread pool load, number of thread pool joining failures and the status of each thread in the pool. The thread task data includes the task waiting time, task processing time and task concurrency. The running resource data includes the CPU load, memory load, disk load and IO load.
[0100] It should be understood that after collecting the above-mentioned running status data, the aforementioned module 201 can provide a visual interface to display the running status of the system and thread pool in real time, which facilitates online troubleshooting by developers and improves system stability.
[0101] The decision module 203 is used to extract the running resource data and thread pool data from the running status data, and determine the task type of the business request based on the running resource data.
[0102] It should be noted that the above task types can refer to the number of threads required for a business request.
[0103] In its implementation, the decision module 203 can extract the runtime resource data and thread pool data from the runtime status data. Then, based on the runtime resource data, such as CPU load, memory load, disk load, and IO load, it determines the load occupied by the business request and determines the task type based on the type of load occupied. For example, if the CPU load is high, it means that the process of processing the business request involves a large proportion of calculation, logical judgment, or looping, requiring more threads to process, and the task type is determined to be the type that occupies more threads. On the other hand, if the IO load is high, it means that the process of processing the business request involves a large proportion of data transmission, requiring less threads to process, and the task type is determined to be the type that occupies fewer threads.
[0104] The management module 202 is further configured to generate request update parameters and feed back the request update parameters to the decision module 203 when the performance of the thread pool does not meet the preset performance requirements.
[0105] In a specific implementation, the management module 202 can determine whether the performance of the thread pool meets the preset performance requirements corresponding to the business request based on the core thread pool number, maximum thread pool number, or thread pool load in the above running status data. When it is detected that the thread pool performance fails to meet the preset performance requirements, the above request update parameters can be generated. Before sending the request update parameters, the feedback is first sent to the decision module 203 for verification and evaluation.
[0106] The decision module 203 is also used to check and evaluate the request update parameters according to the task type and the thread pool data, and to feed back the evaluation result to the management module 202 when the check and evaluation is passed.
[0107] In its implementation, when the thread pool performance fails to meet the preset performance requirements, the decision module 203 can further check and evaluate the generated request update parameters based on the task type of the business request to confirm whether the request update parameters are reasonable. For example, if the preset performance requirement is that the thread pool completes the business request with optimal performance, and the core thread pool is not fully utilized, it can be determined that the thread pool size is too large and fails to achieve optimal performance. Request update parameters with a smaller thread pool size can then be generated. In this case, if the task type of the business request is one that requires fewer threads, the generated request update parameters are deemed reasonable, and the check and evaluation pass; otherwise, the request update parameters are deemed unreasonable, and the check and evaluation fail. As another example, if the preset performance requirement is that the thread pool completes the business request within a specified time, and the core thread pool is fully utilized but still cannot complete the business request within the specified time, it can be determined that the thread pool size is too small and fails to achieve optimal performance. Request update parameters with a larger thread pool size can then be generated. In this case, if the task type of the business request is one that requires more threads, the generated request update parameters are deemed reasonable, and the check and evaluation pass; otherwise, the request update parameters are deemed unreasonable, and the check and evaluation fail. Furthermore, when the request to update parameters passes the evaluation, the decision module 203 allows the management module 202 to send the request to update parameters to the business system to adjust the thread pool specifications. Otherwise, when the request to update parameters fails the evaluation, the management module 202 is prohibited from sending the request to update parameters to the business system. This ensures that the thread pool specifications are consistent with the task type of the business request and improves the accuracy of the thread pool specifications adjustment.
[0108] Furthermore, in this embodiment, the decision module 203 is also used to determine the number of worker threads in the thread pool based on the thread pool data.
[0109] It should be noted that the number of worker threads mentioned above refers to the number of threads in the thread pool that execute the task queue.
[0110] In a specific implementation, the decision module 203 can determine the number of thread pools for each task in the current task queue based on the thread pool data.
[0111] The decision module 203 is further configured to determine whether the number of worker threads is lower than a first preset threshold when the task type is IO intensive.
[0112] It should be noted that the above-mentioned IO-intensive type can be a type with low CPU load and a large proportion of network transmission processes.
[0113] Understandably, the aforementioned first preset threshold can be the maximum number of threads allocated to I / O-intensive business requests. Since different business requests require different numbers of threads, it is impossible to set a fixed number of threads to achieve optimal performance. However, a certain range can be set. When processing I / O-intensive business requests, controlling the number of worker threads within this range can be considered to meet the thread count requirement, resulting in relatively better performance.
[0114] In its implementation, the aforementioned thread pool initially processes business request tasks with a default number of threads. However, since different task types require different numbers of worker threads, the thread pool needs to be dynamically adjusted. When the decision module 203 detects that the task type is I / O intensive, it determines that the business request does not require a large number of threads. Therefore, it can determine whether the current number of worker threads is below a first preset threshold to further determine whether the current number of worker threads meets the standard.
[0115] The decision module 203 is further configured to determine that the request update parameter check and evaluation has passed when the number of working threads is not lower than the first preset threshold.
[0116] In specific implementation, when the decision module 203 detects that the number of worker threads is not lower than the first preset threshold, it can determine that the number of worker threads is too large. At this time, the performance of the thread pool that processes IO-intensive business requests does not meet the preset performance requirements, and it can be determined that the number of worker threads is too large. That is, the inspection and evaluation results are consistent with the situation where the preset performance requirements are not met, and it can be confirmed that the request update parameters are reasonable and the inspection and evaluation are passed.
[0117] Furthermore, in this embodiment, the decision module 203 is also used to determine whether the number of worker threads reaches a second preset threshold when the task type is computationally intensive, wherein the second preset threshold is higher than the first preset threshold.
[0118] It should be noted that the above-mentioned computationally intensive types can be those with high CPU load and a large proportion of processes involving calculations, logical judgments, or loops.
[0119] Understandably, the aforementioned second preset threshold can be the maximum number of threads allocated to compute-intensive business requests. Since compute-intensive requests require high CPU load and a large number of threads, the aforementioned second preset threshold must be greater than the aforementioned first preset threshold, and the number of threads must be greater than the second preset threshold for the target to be met.
[0120] In the specific implementation, when the decision module 203 detects that the above task type is computationally intensive, it determines that the business request requires a lot of threads. Therefore, it can determine whether the current number of working threads has reached the first preset threshold, so as to further determine whether the current number of working threads meets the standard.
[0121] The decision module 203 is also used to determine that the request update parameter check and evaluation has passed when the number of working threads has not reached the second preset threshold.
[0122] In specific implementation, when the decision module 203 detects that the number of worker threads has not reached the second preset threshold, it can determine that the number of worker threads is too small. At this time, the performance of the thread pool that processes computationally intensive business requests does not meet the preset performance requirements, and it can be determined that the number of worker threads is too small. That is, the inspection and evaluation results are consistent with the situation where the preset performance requirements are not met, and it can be confirmed that the request update parameters are reasonable and the inspection and evaluation are passed.
[0123] It should be understood that, in order to avoid the number of worker threads becoming too large and exceeding the capacity of hardware resources, an over-limit threshold can be set. When the number of worker threads is detected to reach the second preset threshold and is close to the over-limit threshold, it can be determined that the number of worker threads is too large, and the sending of requests to update parameters will be temporarily stopped. A suggestion prompt will be pushed to the developer to avoid performance bottlenecks after updating the thread pool specifications.
[0124] This embodiment checks and evaluates the request update parameters according to the task type of the business request before feeding them back to the business system when the thread pool performance does not meet the preset performance requirements. Only when the check and evaluation is passed can the request update parameters be fed back to the business system. This ensures that the thread pool specification update is consistent with the task type of the business request and improves the accuracy of thread pool specification adjustment.
[0125] Furthermore, in this embodiment, the thread pool management system further includes an early warning module 204.
[0126] The monitoring module 201 is also used to extract thread pool task data from the running status data.
[0127] In its specific implementation, the monitoring module 201 can extract thread pool task data from the running status data when the thread pool executes tasks, namely the task processing time, task waiting time, and task concurrency of the thread when it processes the task.
[0128] The early warning module 204 is used to determine the running status of the thread pool based on the thread pool data, and to determine the task execution status of the thread pool based on the thread pool task data.
[0129] In a specific implementation, the aforementioned early warning module 204 can determine the current running status of the thread pool based on the aforementioned thread pool data, such as the number of worker threads, queue depth, thread pool load, number of failed thread pool additions, and the status of each thread in the pool. It can also determine the task execution status of the thread pool based on the aforementioned thread pool task data, such as task processing time, task waiting time, and task concurrency.
[0130] The early warning module 204 is also used to push alarm information to the target terminal when the thread pool running state or the task execution state fails to meet the standard.
[0131] In its implementation, the aforementioned early warning module 204 can be configured with a core thread pool count and a task processing time threshold. When it detects that the number of worker threads in the thread pool has reached the core thread pool count, it indicates that the core thread pool is being fully utilized, and the thread pool's operating status is deemed satisfactory. Otherwise, the thread pool's operating status is deemed unsatisfactory. For example, if the core thread pool count is 50, to achieve full performance, the number of worker threads should be 50 or close to 50, with a small deviation from 50, such as 80% or 90% of the core thread pool count. Similarly, if it detects that the thread pool's processing time for business request tasks has not exceeded the aforementioned task processing time threshold, the task execution status can be deemed satisfactory. Otherwise, it indicates that the thread pool's processing time for business request tasks is too long, and the task execution status is deemed unsatisfactory. For example, if the task processing time threshold is 10 minutes, meaning that business request tasks must be processed within 10 minutes, but the thread pool takes 30 minutes, far exceeding 10 minutes, then the task execution status can be deemed unsatisfactory.
[0132] It should be understood that when the thread pool is running at its optimal state, if a new business request is received at this time, since the core thread pool is already fully utilized, a request can be generated to update the parameters and expand the thread pool size. Furthermore, the aforementioned early warning module 204 can also be configured with a resource load threshold. When the resource load of the application where the business system 100 resides reaches this threshold, the thread pool size cannot be expanded further, and an alert can be sent to the developers to prevent interruption of business request processing.
[0133] The management module 202 is used to send the request update parameters to the business system 100 through the second interface.
[0134] In a specific implementation, after receiving the request to update parameters sent by the decision module 203 after verification and evaluation, the management module 202 can send the request to update parameters to the business system 100 through the second interface so that the business system 100 can update the thread pool specifications.
[0135] Furthermore, in this embodiment, the management module 202 is also used to extract the configuration time and scaling strategy from the thread pool configuration information when it receives the thread pool configuration information.
[0136] It should be noted that the above thread pool configuration information can be updated automatically or periodically.
[0137] It is understandable that the above configuration time can be the time when the thread pool specification is updated. Accordingly, the above scaling strategy can be a strategy for shrinking or increasing the thread pool specification.
[0138] In practical implementation, if the developers predict a surge in business activity during the current time period or a future period, they can send thread pool configuration information, including the configured time and scaling strategy, to the management module 202. For example, a marketing campaign might experience high traffic at noon or 8 PM, causing significant pressure on the business system 100 and consuming a large number of threads. The normally configured thread pool size might be insufficient, so the thread pool size can be adjusted at these times to alleviate the pressure. Upon receiving the thread pool configuration information, the management module 202 can extract the configured time and scaling strategy from it.
[0139] The management module 202 is further configured to generate timing adjustment parameters according to the scaling strategy when the current time reaches the configured time, and send the timing adjustment parameters to the business system 100 through the second interface.
[0140] It should be noted that the above-mentioned timed adjustment parameters can be parameters for adjusting the thread pool size at the above-mentioned configured time. When the above-mentioned scaling strategy is to reduce the thread pool size, timed adjustment parameters for reducing the thread pool size can be generated. Correspondingly, when the above-mentioned scaling strategy is to increase the thread pool size, timed adjustment parameters for increasing the thread pool size can be generated.
[0141] In a specific implementation, the management module 202 can determine whether to increase or decrease the thread pool size according to the scaling strategy after the current time reaches the configured time, and generate corresponding adjustment parameters. Then, the timed adjustment parameters can be sent to the business system 100 through the second step.
[0142] The business system 100 is also used to adjust the thread pool specification to the specification corresponding to the scaling strategy according to the timed adjustment parameters.
[0143] In practical implementation, the aforementioned business system can adjust the thread pool specifications according to the timed adjustment parameters, adjusting the thread pool specifications to the specifications corresponding to the scaling strategy, thereby meeting business requirements and improving user experience.
[0144] Furthermore, this embodiment of the invention also provides a thread pool management method based on the thread pool management architecture described in the above embodiments, referring to... Figure 5 , Figure 5 This is a flowchart illustrating the first embodiment of the thread pool management method of the present invention.
[0145] In this embodiment, the thread pool management method includes the following steps:
[0146] Step S10: Receive the running status data uploaded by the business system. The running status data is generated by the thread pool called by the business system when processing business requests.
[0147] It should be noted that the execution subject of the method in this embodiment can be a computing service device with thread pool management, network communication, and program execution functions, such as a mobile phone, tablet computer, or personal computer, or other electronic devices that implement the same or similar functions. The following description uses a thread pool management system as an example to illustrate this embodiment.
[0148] In its implementation, when the aforementioned business system receives a business request task, it can call the thread pool and use the worker threads provided by the thread pool to execute the business request task. At the same time, the aforementioned business system can obtain a pre-built plugin library from its local machine. When the thread pool is running, it can listen to the thread pool through the plugins in the plugin library, and obtain the running status data by polling and scanning the status of the thread pool, thread tasks, and running resources. Then, it can upload the collected running status data to the thread pool management system through the aforementioned second interface.
[0149] Step S20: Determine whether the thread pool performance meets the preset performance requirements corresponding to the business request based on the running status data.
[0150] In practical implementation, the aforementioned thread pool management system can determine whether the thread pool performance meets the preset performance requirements corresponding to the business request based on the core thread pool count, maximum thread pool count, or thread pool load in the above-mentioned running status data. For example, if the preset performance requirement is that the thread pool completes the business request with optimal performance, and the core thread pool is not fully utilized, it can be determined that the thread pool size is too large and fails to achieve optimal performance. As another example, if the preset performance requirement is that the thread pool completes the business request within a specified time, and the core thread pool is fully utilized but still cannot complete the business request within the specified time, it can be determined that the thread pool size is too small and fails to achieve optimal performance.
[0151] Step S30: If the preset performance requirements are not met, send a request to update parameters to the business system so that the business system can adjust the thread pool specifications through the request to update parameters so that the thread pool performance meets the preset performance requirements.
[0152] In its implementation, the aforementioned thread pool management system can determine the need to adjust the thread pool size when it detects that the thread pool performance fails to meet the preset performance requirements corresponding to the business request. At this point, it can generate request update parameters based on the thread pool specifications. For example, if the thread pool size is too large and cannot meet the preset performance requirements, request update parameters to reduce the thread pool size can be generated; if the thread pool size is too small and cannot meet the preset performance requirements, request update parameters to increase the thread pool size can be generated. These request update parameters are then sent to the business system. The business system can adjust the thread pool specifications according to these request update parameters to ensure that the number of worker threads corresponds to the business request task, avoiding both an excess and deficiency of worker threads, thus ensuring that the thread pool specifications meet the preset performance requirements.
[0153] This embodiment receives runtime status data uploaded by the business system. This runtime status data is generated when the thread pool called by the business system processes business requests. Based on the runtime status data, it determines whether the thread pool performance meets the preset performance requirements corresponding to the business request. If the preset performance requirements are not met, a request to update parameters is sent to the business system so that the business system can adjust the thread pool specifications to meet the preset performance requirements. This embodiment determines that the thread pool performance does not meet the preset performance requirements based on the runtime status data uploaded by the business system, and then sends a request to update parameters to the business system so that the business system can adjust the thread pool to meet the preset performance requirements. Compared to existing technologies, which adjust the thread pool specifications after downtime when performance problems occur, thus failing to optimize performance issues in a timely manner, the method described in this embodiment can adjust the thread pool parameters to optimize performance issues as soon as they occur, effectively improving performance optimization efficiency.
[0154] Furthermore, this invention also provides a thread pool management method. This method is applied to an architecture including a business system and a thread pool management system. The business system deploys an SDK tool, which provides a first interface and a second interface. The business system calls a thread pool provided by a target vendor through the first interface. The thread pool is used to process business requests. The business system connects to the thread pool management system through the second interface. Figure 6 , Figure 6 This is a flowchart illustrating the second embodiment of the thread pool management method of the present invention.
[0155] In this embodiment, the thread pool management method includes the following steps:
[0156] The business system collects the running status data of the thread pool and uploads the running status data to the thread pool management system through the second interface.
[0157] In its implementation, the aforementioned business system can obtain an SDK tool provided by the target vendor. This SDK tool serves as a development and integration environment, allowing the business system to call API interfaces, namely the first and second interfaces mentioned above. Upon receiving a business request task, the business system can invoke the thread pool through the first interface, using the worker threads provided by the thread pool to execute the task. Simultaneously, the business system can retrieve a pre-built plugin library locally. During thread pool runtime, it monitors the thread pool through plugins in this library, polling and scanning the status of the thread pool, thread tasks, and runtime resources to obtain runtime status data. This data is then uploaded to the thread pool management system via the second interface. The plugin library possesses excellent extensibility, allowing developers to implement custom listeners by extending the plugin library interface.
[0158] The thread pool management system determines whether the thread pool performance meets the preset performance requirements corresponding to the business request based on the running status data.
[0159] In practical implementation, the aforementioned thread pool management system can determine whether the thread pool performance meets the preset performance requirements corresponding to the business request based on the core thread pool count, maximum thread pool count, or thread pool load in the above-mentioned running status data. For example, if the preset performance requirement is that the thread pool completes the business request with optimal performance, and the core thread pool is not fully utilized, it can be determined that the thread pool size is too large and fails to achieve optimal performance. As another example, if the preset performance requirement is that the thread pool completes the business request within a specified time, and the core thread pool is fully utilized but still cannot complete the business request within the specified time, it can be determined that the thread pool size is too small and fails to achieve optimal performance.
[0160] When the preset performance requirements are not met, the thread pool management system sends a request to the business system to update parameters through the second interface.
[0161] In its implementation, the aforementioned thread pool management system can determine that the thread pool size needs to be adjusted when it detects that the thread pool performance fails to meet the preset performance requirements corresponding to the business request. At this time, it can generate request update parameters based on the thread pool specifications. If the thread pool specifications are too large and cannot meet the preset performance requirements, request update parameters for reducing the thread pool specifications can be generated. If the thread pool specifications are too small and cannot meet the preset performance requirements, request update parameters for increasing the thread pool specifications can be generated. Then, the request update parameters are sent to the business system through the second interface.
[0162] The business system adjusts the thread pool specifications according to the updated parameters of the request, so that the performance of the thread pool meets the preset performance requirements.
[0163] In practical implementation, the above-mentioned business system can adjust the thread pool specifications according to the above-mentioned request update parameters, so that the number of worker threads corresponds to the business request tasks, avoiding the number of worker threads being more than the number of tasks, and also avoiding the number of worker threads being less than the number of tasks, so that the thread pool specifications meet the preset performance requirements.
[0164] This embodiment collects thread pool runtime status data through the business system and uploads the data to the thread pool management system via an SDK tool. The thread pool management system determines whether the thread pool performance meets the preset performance requirements corresponding to the business request based on the runtime status data. If the preset performance requirements are not met, the thread pool management system sends a request to update parameters to the business system through a second interface. The business system adjusts the thread pool specifications according to the updated parameters to ensure the thread pool performance meets the preset performance requirements. In this embodiment, the business system uploads the collected thread pool runtime status data to the thread pool management system through a first interface. When the thread pool management system determines that the thread pool performance does not meet the preset performance requirements based on the runtime status data, it sends a request to update parameters to the business system through a second interface, causing the business system to adjust the thread pool to meet the preset performance requirements. Compared to existing technologies where performance issues are addressed by adjusting thread pool specifications after system downtime, which cannot optimize performance issues promptly, this embodiment's method can adjust thread pool parameters to optimize performance issues as soon as they occur, effectively improving performance optimization efficiency.
[0165] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0166] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0167] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as read-only memory / random access memory, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0168] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. A thread pool management architecture, characterized in that, The architecture includes: a business system and a thread pool management system; The business system is deployed with an SDK tool, which provides a first interface and a second interface. The business system calls the thread pool provided by the target vendor through the first interface. The thread pool is used to process business requests. The business system connects to the thread pool management system through the second interface. The thread pool is not created locally but is built by the target vendor. The first interface proxies the thread pool. The business system is also used to collect the running status data of the thread pool and upload the running status data to the thread pool management system through the second interface; The thread pool management system is used to determine whether the thread pool performance meets the preset performance requirements corresponding to the business request based on the running status data. The thread pool management system is also used to send a request to update parameters to the business system through the second interface when the preset performance requirements are not met. The business system is also used to adjust the thread pool specifications through the first interface according to the request update parameters, so that the thread pool performance meets the preset performance requirements.
2. The thread pool management architecture as described in claim 1, characterized in that, The thread pool management architecture includes: a monitoring module, a decision-making module, and a management module; Both the monitoring module and the management module are connected to the business system through the second interface; The monitoring module is used to receive the running status data uploaded by the business system through the second interface; The decision module is used to extract the running resource data and thread pool data from the running status data, and determine the task type of the business request based on the running resource data; The management module is also used to generate the request update parameters and feed back the request update parameters to the decision module when the performance of the thread pool does not meet the preset performance requirements. The decision module is also used to check and evaluate the request update parameters according to the task type and the thread pool data, and to feed back the evaluation result to the management module when the check and evaluation is passed; The management module is used to send the request to update parameters to the business system through the second interface.
3. The thread pool management architecture as described in claim 2, characterized in that, The decision module is also used to determine the number of worker threads in the thread pool based on the thread pool data; The decision module is also used to determine whether the number of worker threads is lower than a first preset threshold when the task type is IO intensive. The decision module is also used to determine that the parameter update request has passed the evaluation when the number of worker threads is not lower than the first preset threshold.
4. The thread pool management architecture as described in claim 3, characterized in that, The decision module is also used to determine whether the number of worker threads reaches a second preset threshold when the task type is computationally intensive, wherein the second preset threshold is higher than the first preset threshold. The decision module is also used to determine that the parameter update request has passed the evaluation when the number of worker threads has not reached the second preset threshold.
5. The thread pool management architecture as described in claim 2, characterized in that, The thread pool management system also includes: an early warning module; The monitoring module is also used to extract thread pool task data from the running status data; The early warning module is used to determine the thread pool running status based on the thread pool data, and to determine the thread pool task execution status based on the thread pool task data. The early warning module is also used to push alarm information to the target terminal when the thread pool running state or the task execution state fails to meet the standard.
6. The thread pool management architecture as described in claim 5, characterized in that, The management module is also used to extract the configuration time and scaling strategy from the thread pool configuration information when it receives the thread pool configuration information. The management module is also used to generate timed adjustment parameters according to the scaling strategy when the current time reaches the configured time, and send the timed adjustment parameters to the business system through the second interface; The business system is also used to adjust the thread pool specification to the specification corresponding to the scaling strategy according to the timed adjustment parameters.
7. The thread pool management architecture as described in any one of claims 2 to 6, characterized in that, The business system is also used to obtain the unified programming model provided by the SDK tool when it receives the business request; The business system is also used to package the business request into an orchestratable task according to the unified programming model, and to orchestrate the orchestratable task to obtain a task queue composed of each task. The business system is also used to call the thread pool through the first interface, and to chain the threads in the thread pool together according to the task orchestration method of the task queue to obtain the target thread; The business system is also used to add each task in the task queue to the thread pool in sequence, and execute each task through the target thread.
8. The thread pool management architecture as described in claim 7, characterized in that, The business system is also used to pause the operation of adding each task in the task queue to the thread pool in sequence when a thread pool shutdown instruction is detected, and to check whether there are active threads in the thread pool that are processing tasks. The business system is also used to close the thread pool after the active thread has finished executing when the active thread exists. The business system is also configured to shut down the thread pool if the active thread has not completed execution when the waiting time reaches a preset waiting time.
9. A thread pool management method based on the thread pool management architecture according to any one of claims 1 to 8, characterized in that, The thread pool management method is executed by the thread pool management system, and the method includes: Receive runtime status data uploaded by the business system, wherein the runtime status data is generated by the thread pool invoked by the business system when processing business requests; Based on the running status data, determine whether the thread pool performance meets the preset performance requirements corresponding to the business request; If the preset performance requirements are not met, a request to update parameters is sent to the business system so that the business system can adjust the thread pool specifications through the request to update parameters so that the thread pool performance meets the preset performance requirements.
10. A thread pool management method, characterized in that, The thread pool management method is applied to an architecture that includes a business system and a thread pool management system. The business system deploys an SDK tool, which provides a first interface and a second interface. The business system calls a thread pool provided by a target vendor through the first interface. The thread pool is used to process business requests. The business system connects to the thread pool management system through the second interface. The thread pool is not created locally but is built by the target vendor. The first interface proxies the thread pool. The method includes: The business system collects the running status data of the thread pool and uploads the running status data to the thread pool management system through the second interface; The thread pool management system determines whether the thread pool performance meets the preset performance requirements corresponding to the business request based on the running status data. When the preset performance requirements are not met, the thread pool management system sends a request to the business system to update parameters through the second interface. The business system updates parameters according to the request and adjusts the thread pool specifications through the first interface so that the thread pool performance meets the preset performance requirements.
Citation Information
Patent Citations
File management method, device and system and storage medium
CN113656357A
Dynamic reassignment of search processes into workload pools in a search and indexing system
US10942774B1
