Thread pool thread configuration method, device, server and storage medium
By obtaining the changing trends of thread pool configuration amounts and task request amounts in multiple business scenarios and single business scenarios, the number of thread pool threads is determined, which solves the problem of inaccurate thread settings in the existing technology and improves server resource utilization and performance.
Patent Information
- Application Number
- CN202010971594.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-16
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2040-09-16
AI Technical Summary
The number of thread pool thread settings in the prior art is inaccurate, which affects server performance, makes it impossible to fully utilize resources, and makes it difficult to adapt to changes in task request volume in different business scenarios.
By obtaining the thread pool configuration amount of multiple business scenarios and single business scenarios, combined with the current trend of task request volume changes in the thread pool, the optimal number of threads in the thread pool is determined, and multiple pre-configured computing models are used to select targets based on the task request volume trend. The model is configured for threading.
It achieves more accurate setting of the number of thread pool threads, maximizes the utilization of server resources, and improves task processing efficiency and server performance.
Smart Images

Figure CN113778656B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of server application technology, and in particular to a thread pool thread configuration method, device, server and storage medium. Background Art
[0002] With the development of Internet information technology, thread pools have been widely used to maximize the use of server resources. By creating a thread pool and delegating tasks to threads in the thread pool, they can be executed concurrently. In addition, the use of thread pools in high concurrency conditions can effectively reduce the time and resource overhead of thread creation and release. However, the number of threads in the thread pool will also affect the server. If the number of threads in the thread pool is set to a small number, the server resources cannot be fully utilized. If the number of threads in the thread pool is set to a large number, it is easy to cause congestion, making the task processing efficiency low.
[0003] The prior art mainly uses an estimation algorithm to estimate the number of threads to be set in a thread pool. The specific method is to first determine whether the server is central processing unit (CPU) intensive or input / output (I / O) intensive, and then calculate the number of threads that need to be set in the thread pool according to the number of CPU cores. This method only considers the number of cores of the server CPU, and cannot accurately obtain the number of threads that need to be set in the thread pool corresponding to each business scenario, which has an adverse impact on server performance. Summary of the invention
[0004] The present application provides a thread pool thread configuration method, device, server and storage medium, which are used to solve the problem that the number of threads in the existing thread pool is inaccurately set, which has an adverse effect on server performance.
[0005] In a first aspect, an embodiment of the present application provides a thread pool thread configuration method, comprising:
[0006] Get the first thread configuration amount of the thread pool in multiple business scenarios;
[0007] Get the second thread configuration amount of the thread pool in a single business scenario;
[0008] Obtaining a task request amount change trend of the current thread pool, and determining a thread configuration amount of the current thread pool according to the first thread configuration amount, the second thread configuration amount and the task request amount change trend;
[0009] The number of threads in the current thread pool is configured according to the thread configuration amount of the current thread pool.
[0010] In a possible design of the first aspect, obtaining a first thread configuration amount of a thread pool in a multi-business scenario includes:
[0011] Obtain the task request volume and task processing time of the thread pool in multiple business scenarios;
[0012] The first thread configuration quantity of the thread pool for multiple business scenarios is obtained according to the task request quantity and the task processing duration.
[0013] In another possible design of the first aspect, obtaining the second thread configuration amount of the thread pool of a single business scenario includes:
[0014] Get the task proportion of thread pool in multiple business scenarios;
[0015] Get the initial thread configuration for a single business scenario;
[0016] According to the task proportion and the initial thread configuration amount, the second thread configuration amount of the thread pool of the single business scenario is obtained.
[0017] In another possible design of the first aspect, obtaining the task proportion of the thread pool in multiple business scenarios includes:
[0018] Obtaining a total amount of tasks of a thread pool of multiple business scenarios, where the thread pool of the multiple business scenarios includes more than two, and the total amount of tasks is the sum of the task requests of each thread pool;
[0019] According to the total amount of tasks and the amount of task requests of each thread pool, the task proportions of the thread pools in multiple business scenarios are obtained.
[0020] In another possible design of the first aspect, obtaining the initial thread configuration amount of the single service scenario includes:
[0021] Get the number of CPU cores, CPU usage, CPU waiting time, and CPU computing time;
[0022] According to the number of cores of the central processing unit, the utilization rate of the central processing unit, the waiting time of the central processing unit, and the calculation time of the central processing unit, the initial thread configuration amount of the single business scenario is obtained. In another possible design of the first aspect, the task request amount change trend of the current thread pool is obtained, and the thread configuration amount of the current thread pool is determined according to the first thread configuration amount, the second thread configuration amount, and the task request amount change trend, including:
[0023] Obtaining a magnitude relationship between the first thread configuration amount and the second thread configuration amount;
[0024] Determining a target computing model from a plurality of pre-configured computing models for computing the current thread configuration amount according to the size relationship and the change trend of the task request amount;
[0025] The thread configuration amount of the current thread pool is calculated according to the target computing model, the first thread configuration amount, and the second thread configuration amount.
[0026] In another possible design of the first aspect, the task request amount change trend includes an increasing trend, a stable trend, and a decreasing trend, and determining a target computing model from a plurality of computing models pre-configured for calculating the current thread configuration amount according to the size relationship and the task request amount change trend includes:
[0027] When the change trend of the task request amount is an increasing trend, selecting a growth calculation model as the target calculation model from a plurality of calculation models pre-configured for calculating the current thread configuration amount according to the size relationship;
[0028] When the change trend of the task request amount is a stable trend, selecting a stable calculation model from a plurality of calculation models pre-configured for calculating the current thread configuration amount according to the size relationship as the target calculation model;
[0029] When the change trend of the task request amount is a downward trend, a downward calculation model is selected as the target calculation model from a plurality of calculation models pre-configured for calculating the current thread configuration amount according to the size relationship.
[0030] In another possible design of the first aspect, when the change trend of the task request amount is an increasing trend, selecting a growth calculation model as the target calculation model from a plurality of calculation models pre-configured for calculating the current thread configuration amount according to the size relationship includes:
[0031] When the first thread configuration amount is greater than the second thread configuration amount, selecting a first growth calculation model as the target calculation model;
[0032] When the thread configuration amount of the thread pool of the multi-business scenario is not greater than the thread configuration amount of the thread pool of the single-business scenario, the second growth calculation model is selected as the target calculation model.
[0033] In another possible design of the first aspect, when the change trend of the task request amount is a stable trend, selecting a stable computing model as the target computing model from a plurality of computing models pre-configured for calculating the current thread configuration amount according to the size relationship includes:
[0034] When the first thread configuration amount is greater than the second thread configuration amount, selecting a first stable computing model as the target computing model;
[0035] When the first thread configuration amount is not greater than the second thread configuration amount, a second stable computing model is selected as the target computing model.
[0036] In another possible design of the first aspect, when the change trend of the task request amount is a downward trend, selecting a downward computing model from a plurality of computing models pre-configured for calculating the current thread configuration amount as the target computing model according to the size relationship includes:
[0037] When the first thread configuration amount is greater than the second thread configuration amount, selecting a first descent calculation model as the target calculation model;
[0038] When the first thread configuration amount is not greater than the second thread configuration amount, a second descent calculation model is selected as the target calculation model.
[0039] In another possible design of the first aspect, configuring the number of threads in the current thread pool according to the thread configuration information of the current thread pool includes:
[0040] Get the number of core threads and the maximum number of threads in the current thread pool;
[0041] The number of core threads and the maximum number of threads are adjusted according to the thread configuration information of the current thread pool.
[0042] In a second aspect, an embodiment of the present application provides a thread pool thread configuration device, including:
[0043] A first configuration quantity acquisition module, used to acquire a first thread configuration quantity of a thread pool in multiple business scenarios;
[0044] A second configuration quantity acquisition module, used to acquire a second thread configuration quantity of a thread pool in a single business scenario;
[0045] An information acquisition module, used to obtain a task request amount change trend of the current thread pool, and determine a thread configuration amount of the current thread pool according to the first thread configuration amount, the second thread configuration amount and the task request amount change trend;
[0046] A configuration module is used to configure the number of threads in the current thread pool according to the thread configuration amount of the current thread pool.
[0047] In a third aspect, an embodiment of the present application provides a server, including a memory, a processor, and a computer program;
[0048] The computer program is stored in the memory and is configured to be executed by the processor to implement the method as described above.
[0049] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to perform the method described above.
[0050] The thread configuration method, device, server and storage medium of the thread pool provided in the embodiments of the present application can more accurately set the number of threads in the thread pool and maximize the utilization of server resources by determining the thread configuration amount of each thread pool in multiple business scenarios and the thread configuration amount of a single thread pool in a single business scenario, and combining the changing trend of the task request amount of the current thread pool to determine the optimal setting number of threads in the current thread pool. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 A schematic diagram of an application scenario of a thread pool thread configuration method provided in an embodiment of the present application;
[0052] Figure 2 A schematic diagram of the server structure provided in the embodiment of the present application;
[0053] Figure 3 A schematic diagram of the structure of a thread pool for a single business scenario provided in an embodiment of the present application;
[0054] Figure 4 A schematic diagram of the structure of a thread pool for multiple business scenarios provided in an embodiment of the present application;
[0055] Figure 5 A flowchart of a first embodiment of a method for configuring threads in a thread pool provided in an embodiment of the present application;
[0056] Figure 6 A flowchart of a second embodiment of a method for configuring threads in a thread pool provided in an embodiment of the present application;
[0057] Figure 7 A flowchart of a third embodiment of a method for configuring threads in a thread pool provided in an embodiment of the present application;
[0058] Figure 8 A flowchart of a fourth embodiment of a method for configuring threads in a thread pool provided in an embodiment of the present application;
[0059] Fig. 9 A flowchart of a fifth embodiment of a method for configuring threads in a thread pool provided in an embodiment of the present application;
[0060] Fig.10 A flowchart of a sixth embodiment of a method for configuring threads in a thread pool provided in an embodiment of the present application;
[0061] Fig.11 A flowchart of a thread configuration method for a thread pool provided in another embodiment of the present application;
[0062] Fig.12 A schematic diagram of the structure of a thread configuration device for a thread pool provided in an embodiment of the present application. DETAILED DESCRIPTION
[0063] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0064] Figure 1 A schematic diagram of an application scenario of the thread pool thread configuration method provided in an embodiment of the present application, such as Figure 1 As shown, terminals such as tablet 101, computer 102 and mobile phone 103 interact with server 104 through the network. Server 104 receives various business requests from the terminals, such as e-commerce ordering services performed by users through mobile phones, sellers' ordering services, etc. Server 104 creates corresponding thread pools for these business requests. Each business request can generate one or more tasks, which are assigned to threads in the thread pool for execution.
[0065] Figure 2 A schematic diagram of the structure of the server provided in the embodiment of the present application, such as Figure 2 As shown, the application scenario of the embodiment of the present application is a server, and the server has hardware or software that can create a thread pool. The thread pool has a single or multiple threads (not shown in the figure). The thread is the smallest execution unit, and the tasks generated by the business request are delegated to the thread. When the business request volume is large, each thread can be executed concurrently. After a thread completes the delegated task, the thread pool can reuse the created thread and continue to delegate tasks to the thread later. This can reduce the time and resource overhead occupied by thread creation and release.
[0066] Exemplarily, the server can create a single thread pool or multiple thread pools based on the business request. For example, when the business request has one business scenario, the server only needs to create a single thread pool to process the business request through the single thread pool. When the business request has multiple business scenarios, the server needs to create a thread pool for each business scenario, so that the business request can have a corresponding thread pool to perform task processing in different business scenarios.
[0067] Figure 3 A schematic diagram of the structure of a thread pool for a single business scenario provided in an embodiment of the present application, such as Figure 3 As shown, thread pool A includes tasks 1 to 8, which are respectively delegated to two threads to execute these tasks. Since some business requests have only one business scenario, the tasks in the business requests are of the same type. Therefore, the server only needs to create a thread pool A and delegate these tasks of the same type to the threads in thread pool A for execution.
[0068] Figure 4 A schematic diagram of the structure of the thread pool for multiple business scenarios provided in the embodiment of the present application, such as Figure 4 As shown, there are thread pools 1 to N (N is a positive integer greater than 1), each thread pool can have a different number of threads, and the types of tasks delegated to the threads in each thread pool are also different. This is for another part of the business requests. Since this part of the business requests includes different types of tasks and has multiple different business scenarios, the server needs to create a thread pool for each business scenario so that different types of tasks in the business request are delegated to the threads of the corresponding thread pool for execution.
[0069] Figure 5 A flowchart of a thread configuration method for a thread pool provided in an embodiment of the present application is shown in FIG. Figure 5 As shown, the method can use a server as an execution subject, the server receives a service request from a terminal, creates a thread pool for processing the service request, and configures the number of threads in the thread pool. The method can specifically include the following steps:
[0070] S501: Obtain a first thread configuration amount of a thread pool in multiple business scenarios.
[0071] In an embodiment of the present application, the first configuration amount of the thread pool for multiple business scenarios can be calculated through a multi-business scenario computing model. When the server receives a business request, the server can obtain the status of its own CPU and related information of the tasks included in the business request, and then input them into the multi-business scenario computing model to obtain the first thread configuration amount through the multi-business scenario computing model.
[0072] The multi-business scenario calculation model can be a calculation formula or algorithm program pre-established in the server. Specifically, the multi-business scenario calculation model can be obtained by simulating when a business request has multiple business scenarios. For example, when a business request has multiple business scenarios, the server needs to create a corresponding thread pool for each business scenario, and multiple thread pools work together to complete the business request (for details, please refer to the attached Figure 4), then a multi-business scenario calculation model is needed to calculate the number of threads that need to be set in each thread pool.
[0073] Exemplarily, when the server receives a business request, it only needs to obtain the number of requests per second for the task in the business request and the CPU processing time for the task, and then input them into the established multi-business scenario computing model. The multi-business scenario computing model can then calculate and output the first thread configuration amount.
[0074] Exemplarily, the number of requests per second of tasks received by the thread pool multiplied by the processing time of the tasks can be used as a multi-business scenario model, or the number of requests per second of tasks received by the thread pool multiplied by the processing time of the tasks and then multiplied by a preset correction coefficient can be used as a multi-business scenario model, and then the first thread configuration amount of the thread pool can be obtained through the multi-business scenario model.
[0075] Exemplarily, the multi-business scenario calculation model may be the following calculation formula:
[0076] BN threads =TPS task *T task
[0077] In the above formula, BN threads The configuration amount for the first thread of the thread pool in multiple business scenarios, T task The CPU processing time for the task, TPS task The number of requests per second for each thread pool's tasks.
[0078] It should be noted that the number of first thread configuration quantities of a thread pool can be multiple and the values can be the same or different. For example, if different thread pools receive different numbers of requests per second for tasks, the values of the first thread configuration quantities of different thread pools will be different. If different thread pools receive the same number of requests per second for tasks, the values of the first thread configuration quantities of different thread pools will be the same.
[0079] S502: Obtain a second thread configuration amount of a thread pool for a single business scenario.
[0080] In an embodiment of the present application, the second thread configuration amount of the thread pool of a single business scenario can be calculated through a single business scenario calculation model. The single business scenario calculation model can be a calculation formula or a program algorithm. When the server receives a business request, it can obtain relevant information such as the number of CPU cores, CPU utilization, CPU waiting time, and CPU calculation time, and input them into the single business scenario calculation model. The second thread configuration amount is obtained by calculating and outputting the single business scenario calculation model.
[0081] The single business scenario computing model can be preset in the server. Specifically, the single business scenario computing model can be obtained by simulating when the business request has a single business scenario. For example, when simulating when the business request has a single business scenario, the server needs to establish a corresponding single thread pool for the business request and delegate the tasks included in the business request to the thread of the single thread pool (for details, please refer to the attached Figure 3 ), the server also needs to configure the number of threads for the single-thread pool, that is, the second thread configuration amount.
[0082] Exemplarily, the server can obtain the number of CPU cores and then input it into the single business scenario calculation model to calculate the second thread configuration amount of the thread pool for the single business scenario. The specific single business scenario calculation model can be N+1 or 2N+1 (N is the number of CPU cores), and the calculation result is the second thread configuration amount.
[0083] Exemplarily, the server may also obtain the CPU usage rate, the CPU waiting time of the thread task, and the CPU calculation time, and calculate the second thread configuration amount through a single business scenario calculation model. The specific single business scenario calculation model may be calculated as follows:
[0084] WN 1 =N cpu *U cpu *(1+W / C)
[0085] In the above formula, WN 1 The configuration amount for the second thread, N cpu is the number of CPU cores, U cpu is the CPU utilization rate, W is the CPU waiting time of the thread task, and C is the CPU calculation time.
[0086] Exemplarily, the single-business scenario calculation model may also be combined with a weight factor to calculate the second thread configuration amount. The weight factor may be a variable or a constant. The single-business scenario calculation model may be the following calculation formula:
[0087] WN threads =N cpu *U cpu *(1+W / C)*R
[0088] In the above formula, WN threads is the second thread configuration amount, R is the weight factor, N cpu is the number of CPU cores, U cpu is the CPU utilization rate, W is the CPU waiting time of the thread task, and C is the CPU calculation time.
[0089] S503: Obtain a task request amount change trend of the current thread pool, and determine a thread configuration amount of the current thread pool according to the first thread configuration amount, the second thread configuration amount, and the task request amount change trend.
[0090] In an embodiment of the present application, when the server needs to configure the number of threads for the current thread pool, it can first determine the changing trend of the task request volume of the current thread pool, specifically in seconds, by determining the task request volume in the previous second and the current task request volume.
[0091] Exemplarily, the changing trend of the task request volume includes an increasing trend, a stable trend and a decreasing trend. If the difference between the current task request volume and the task request volume in the previous second exceeds a preset numerical range, it is an increasing trend. If the difference between the current task request volume and the task request volume in the previous second is within the preset numerical range, it is a stable trend. If the difference between the current task request volume and the task request volume in the previous second is a negative number, and the absolute value of the negative number also exceeds the preset numerical range, it is a decreasing trend.
[0092] In an embodiment of the present application, the server can preset several different configuration quantity calculation models, select the corresponding configuration quantity calculation model according to the changing trends of different task request quantities, and then input the first thread configuration quantity and the second thread configuration quantity into the configuration quantity calculation model to calculate the thread configuration quantity of the current thread pool.
[0093] It should be noted that the number of current thread pools can be multiple or single, and each current thread pool corresponds to a thread configuration amount.
[0094] Exemplarily, if the service request sent by the server receiving terminal has multiple service scenarios, the number of current thread pools is multiple; if the service request has a single service scenario, the number of current thread pools is single.
[0095] S504: Configure threads of the current thread pool according to the thread configuration amount of the current thread pool.
[0096] In an embodiment of the present application, after receiving a service request from a terminal, the server determines whether the service request has multiple service scenarios or a single service scenario. When the service request has multiple service scenarios, multiple thread pools are created accordingly, and then the thread configuration amount of the current thread pool is used to set the number of threads in the current thread pool. The current thread pool can be any one or more of the multiple thread pools created by the server. When the service request has a single service scenario, the server creates a thread pool accordingly. At this time, the current thread pool is the thread pool created by the server, and the server configures the number of threads in the thread pool according to the thread configuration information.
[0097] In an embodiment of the present application, the first thread configuration amount is calculated by a multi-business scenario calculation model, and the second thread configuration amount is calculated by a single business scenario calculation model. This allows the server to reasonably determine the number of threads in each thread pool based on the type of task in the business request, and combined with the changing trend of the task request amount of each thread pool, it can solve the problem of inaccurate estimation of the existing number of threads in the thread pool, so that the server can accurately adjust the number of threads in each thread pool to maximize the use of server resources.
[0098] Based on the above embodiments, Figure 6 A flow chart of a second embodiment of a thread pool thread configuration method provided in an embodiment of the present application, such as Figure 6 As shown, the above step S501 can be implemented by the following steps:
[0099] S601. Obtain the task request volume and task processing duration of the thread pool in multiple business scenarios.
[0100] In an embodiment of the present application, the server receives a business request sent by a terminal. When the business request has multiple business scenarios, the server establishes multiple thread pools, and then delegates different types of tasks in the business request to different thread pools, respectively. The tasks are executed by threads in each thread pool. In this way, the server can obtain the task request amount of each thread pool and the task processing time required to process the tasks.
[0101] S602: Obtain a first thread configuration amount of a thread pool for multiple business scenarios according to a task request amount and a task processing duration.
[0102] Exemplarily, the multiplication of the task request amount and the task processing time can be used as a multi-business scenario calculation model. The server inputs the obtained task request amount and task processing time into the multi-business scenario calculation model, that is, the first thread configuration amount of the thread pool of the multi-business scenario can be calculated.
[0103] The embodiment of the present application determines the configuration amount of the first thread by obtaining the task request amount and task processing time of the thread pool of multiple business scenarios. The obtained data is small, and the configuration amount of the first thread can be determined conveniently and quickly, thereby reducing the occupation of the server CPU resources and avoiding reducing the task processing efficiency of the CPU.
[0104] Based on the above embodiments, Figure 7 The flowchart of the thread configuration method of the thread pool provided in the embodiment of the present application is as follows: Figure 7 As shown, the above step S502 can be implemented by the following steps:
[0105] S701. Obtain task proportions of thread pools in multiple business scenarios.
[0106] In an embodiment of the present application, when the service request received by the server from the terminal has multiple service scenarios, the server will establish a corresponding thread pool for each service scenario to process different types of tasks in the service request.
[0107] Exemplarily, the task proportion may be a ratio of the total amount of tasks included in the business request to the amount of tasks required to be processed by each corresponding thread pool.
[0108] S702: Obtain an initial thread configuration amount for a single business scenario.
[0109] Exemplarily, the initial thread configuration amount of a single business scenario can be calculated by using an initial calculation model of a single business scenario. The initial calculation model of a single business scenario can be the following calculation formula:
[0110] WN 0 =N cpu *U cpu *(1+T wait / T calc )
[0111] In the above formula, WN 0 N is the initial thread configuration for a single business scenario. cpu The number of CPU cores in the server, U cpu is the target CPU usage of the server, T wait is the CPU waiting time for single thread pool processing tasks, T calc Calculates time for the CPU.
[0112] S703: Obtain a second thread configuration amount of the thread pool of a single business scenario according to the task proportion and the initial thread configuration amount.
[0113] Exemplarily, the calculation model for a single business scenario may be the following calculation formula:
[0114] WN threads =N cpu *U cpu *(1+T wait / T calc )*R
[0115] In the above formula, WN threads The configuration amount for the second thread, N cpu *U cpu *(1+T wait / T calc ) is the initial thread configuration amount for a single business scenario, and R is the task proportion.
[0116] The embodiment of the present application first determines the task proportion of each thread pool, and then obtains the second thread configuration amount in combination with the initial thread configuration amount, so as to improve the accuracy of the obtained second thread configuration amount and ensure the accuracy of subsequent thread configuration information.
[0117] Furthermore, in one embodiment, the above step S701 can be specifically implemented by the following steps: obtaining the total number of tasks of the thread pool for multiple business scenarios, and obtaining the task proportion of the thread pool for multiple business scenarios based on the total number of tasks and the task request amount of each thread pool.
[0118] Among them, the thread pools for multiple business scenarios include more than two, and the total number of tasks is the sum of the task requests of each thread pool. In the embodiment of the present application, when the service request sent by the server receiving terminal has multiple business scenarios, the server creates a corresponding thread pool for each business scenario, and the total number of tasks refers to the total number of task requests of all thread pools created by the server.
[0119] Exemplarily, the task proportion may be obtained by dividing the amount of task requests per second of each thread pool by the sum of the amount of task requests per second of each thread pool.
[0120] The embodiment of the present application obtains the task request amount of each thread pool, and obtains the total business volume of the thread pool in multiple business scenarios based on the task request amount of each thread pool, so as to determine the task proportion of each thread pool. The whole calculation process is simple and can effectively reduce the server burden.
[0121] In one embodiment, the above step S702 can be implemented by the following steps:
[0122] The number of cores of a central processing unit (CPU), the utilization rate of the CPU, the waiting time of the CPU, and the calculation time of the CPU are obtained, and the initial thread configuration amount of a single business scenario is obtained based on the number of cores of the CPU, the utilization rate of the CPU, the waiting time of the CPU, and the calculation time of the CPU.
[0123] In an embodiment of the present application, the server may have multiple CPU cores, and the full load utilization rate of each CPU is 100%. When the CPU starts working, such as processing a task, its resources will be occupied, that is, the CPU utilization rate. The CPU waiting time refers to the CPU waiting time when the thread pool processes the task, and the CPU calculation time refers to the calculation time when the thread pool processes the task.
[0124] For example, the initial thread configuration amount for a single business scenario can be calculated using the calculation formula mentioned above:
[0125] WN0 =N cpu *U cpu *(1+T wait / T calc )
[0126] In the above formula, WN 0 N is the initial thread configuration for a single business scenario. cpu The number of CPU cores in the server, U cpu is the target CPU usage of the server, T wait is the CPU waiting time for single thread pool processing tasks, T calc Calculates time for the CPU.
[0127] The embodiment of the present application obtains the number of CPU cores, the CPU utilization rate, the CPU waiting time and the CPU calculation time, and calculates the initial thread configuration amount of a single business scenario with high accuracy, so that the subsequently obtained second thread configuration amount and the thread configuration amount of the current thread pool are more accurate.
[0128] Based on the above embodiments, Figure 8 A flowchart of a fourth embodiment of a thread configuration method for a thread pool provided in an embodiment of the present application is shown in FIG. Figure 8 As shown, the above step S503 can be implemented by the following steps:
[0129] S801: Obtain a magnitude relationship between a first thread configuration amount and a second thread configuration amount.
[0130] Exemplarily, the server can compare the first thread configuration amount with the second thread configuration amount, and the first thread configuration amount may be greater than the second thread configuration amount or not greater than the second thread configuration amount.
[0131] S802: Determine a target computing model from a plurality of pre-configured computing models for computing the current thread configuration amount according to the size relationship and the trend of the task request amount change.
[0132] Exemplarily, in an embodiment of the present application, the multiple calculation models used to calculate the current thread configuration amount can be different or partially the same, and the size relationship and the trend of changes in the task request amount can determine which calculation model the server selects.
[0133] Exemplarily, the server first determines whether the change trend of the task request volume of the current thread pool is an increasing trend, a stable trend, or a decreasing trend, and then determines the size relationship between the first thread configuration volume and the second thread configuration volume, and selects the corresponding calculation model according to the determined order.
[0134] For example, when the task request amount change trend is an increasing trend, comparing the first thread configuration amount (such as the above-mentioned BNthreads ) and the second thread configuration amount (such as the above WN threads ), when BN threads Less than WN threads The target calculation models that can be selected are as follows:
[0135]
[0136] In the above formula, N threads is the thread configuration amount of the current thread pool, Z is the growth coefficient, the value range is 1-1.5, and the default value is 1.2.
[0137] S803: Calculate the thread configuration amount of the current thread pool according to the target computing model, the first thread configuration amount, and the second thread configuration amount.
[0138] For example, if the selected target calculation model is:
[0139]
[0140] Then the first thread configuration amount BN threads and the second thread configuration volume WN threads By introducing the above target calculation model, we can calculate the thread configuration N of the current city. threads .
[0141] The embodiment of the present application determines the target computing model through the size relationship and the changing trend of the task request volume, and obtains the thread configuration amount of the current thread pool through the target computing model, which effectively solves the problem that the existing estimation algorithm does not consider the impact of the changing trend of the task request volume on the thread pool size. It can accurately estimate the number of threads in the thread pool and maximize the utilization of server resources.
[0142] Based on the above embodiments, Fig. 9 A flowchart of a fifth embodiment of a thread configuration method for a thread pool provided in an embodiment of the present application is shown in FIG. Fig. 9 As shown, if the task request amount change trend includes an increasing trend, a stable trend and a decreasing trend, the above step S802 can be implemented by the following steps:
[0143] S901. When the task request amount change trend is an increasing trend, a growth calculation model is selected as a target calculation model from a plurality of calculation models pre-configured for calculating the current thread configuration amount according to a size relationship.
[0144] In an embodiment of the present application, the size relationship includes two relationships: the first thread configuration amount is greater than the second thread configuration amount and the first thread configuration amount is not greater than the second thread configuration amount. The growth calculation models can be multiple and different, and different size relationships correspond to different growth calculation models.
[0145] Exemplarily, the growth calculation model may be:
[0146]
[0147] In the above formula, N threads The thread configuration amount of the current thread pool, BN threads is the configuration amount of the second thread, WNthreads is the configuration amount of the first thread, and Z is the growth coefficient. The value range is 1-1.5, and the default value is 1.2.
[0148] S902: When the task request amount change trend is a stable trend, a stable calculation model is selected as a target calculation model from a plurality of calculation models pre-configured for calculating the current thread configuration amount according to the size relationship.
[0149] In the embodiment of the present application, the stable calculation model includes multiple and different ones. For example, the stable calculation model can be:
[0150]
[0151] In the above formula, N threads The thread configuration amount of the current thread pool, BN threads is the configuration amount of the second thread, WNthreads is the configuration amount of the first thread, and Z is the growth coefficient. The value range is 1-1.5, and the default value is 1.2.
[0152] S903: When the task request amount change trend is a downward trend, a downward calculation model is selected as a target calculation model from a plurality of calculation models pre-configured for calculating the current thread configuration amount according to the size relationship.
[0153] In the embodiment of the present application, the descent calculation model may include multiple and different ones. For example, the descent calculation model may be the same as the above-mentioned stable calculation model. The descent calculation model is specifically:
[0154]
[0155] In the above formula, N threads The thread configuration amount of the current thread pool, BN threads is the configuration amount of the second thread, WNthreads is the configuration amount of the first thread, and Z is the growth coefficient. The value range is 1-1.5, and the default value is 1.2.
[0156] The embodiment of the present application determines the changing trend of the task request amount and then selects the corresponding target computing model according to the size relationship, so that the thread configuration amount of the current thread pool finally calculated can be more accurate.
[0157] Furthermore, in one embodiment, if there are multiple growth calculation models, the above step S901 can be implemented by the following steps:
[0158] When the first thread configuration amount is greater than the second thread configuration amount, selecting the first growth calculation model as the target calculation model;
[0159] When the thread configuration amount of the thread pool of the multi-business scenario is not greater than the thread configuration amount of the thread pool of the single-business scenario, the second growth calculation model is selected as the target calculation model.
[0160] In this embodiment, the first growth calculation model and the second growth calculation model are different.
[0161] Exemplarily, the first growth calculation model may be:
[0162]
[0163] In the above formula, N threads The thread configuration amount of the current thread pool, BN threads is the configuration amount of the second thread, WNthreads is the configuration amount of the first thread, and Z is the growth coefficient. The value range is 1-1.5, and the default value is 1.2.
[0164] The second growth calculation model can be:
[0165]
[0166] In the above formula, N threads The thread configuration amount of the current thread pool, BN threads is the configuration amount of the second thread, WNthreads is the configuration amount of the first thread, and Z is the growth coefficient. The value range is 1-1.5, and the default value is 1.2.
[0167] This embodiment selects the corresponding first growth calculation model or the second growth calculation model according to the size relationship, so that there are more options when calculating the thread configuration amount of the current thread pool, and the thread configuration amount of the current thread pool is calculated more flexibly and accurately.
[0168] In one embodiment, if there are multiple stable calculation models, the above step S902 can be implemented by the following steps:
[0169] When the first thread configuration amount is greater than the second thread configuration amount, selecting the first stable calculation model as the target calculation model;
[0170] When the first thread configuration amount is not greater than the second thread configuration amount, the second stable calculation model is selected as the target calculation model.
[0171] In this embodiment, the first stable calculation model and the second stable calculation model are different.
[0172] Exemplarily, the first stable calculation model may be:
[0173]
[0174] In the above formula, N threads The thread configuration amount of the current thread pool, BN threads is the configuration amount of the second thread, WNthreads is the configuration amount of the first thread, and Z is the growth coefficient. The value range is 1-1.5, and the default value is 1.2.
[0175] The second stable calculation model can be:
[0176]
[0177] In the above formula, N threads The thread configuration amount of the current thread pool, BN threads is the configuration amount of the second thread, WNthreads is the configuration amount of the first thread, and Z is the growth coefficient. The value range is 1-1.5, and the default value is 1.2.
[0178] This embodiment determines the size relationship between the first thread configuration amount and the second thread configuration amount, and accordingly selects the first stable calculation model or the second stable calculation model as the target calculation model, which can improve the calculation accuracy of the thread configuration amount of the current thread pool.
[0179] In one embodiment, if there are multiple descent calculation models, the above step S903 can be implemented by the following steps:
[0180] When the thread configuration amount of the thread pool of the multi-business scenario is greater than the thread configuration amount of the thread pool of the single-business scenario, the first descending calculation model is selected as the target calculation model;
[0181] When the thread configuration amount of the thread pool of the multi-business scenario is not greater than the thread configuration amount of the thread pool of the single-business scenario, the second descending calculation model is selected as the target calculation model.
[0182] In this embodiment, the first descent calculation model is different from the second descent calculation model.
[0183] Exemplarily, the first descent calculation model may be:
[0184]
[0185] In the above formula, N threads The thread configuration amount of the current thread pool, BN threadsis the configuration amount of the second thread, WNthreads is the configuration amount of the first thread, and Z is the growth coefficient. The value range is 1-1.5, and the default value is 1.2.
[0186] The second descent calculation model can be:
[0187]
[0188] In the above formula, N threads The thread configuration amount of the current thread pool, BN threads is the configuration amount of the second thread, WNthreads is the configuration amount of the first thread, and Z is the growth coefficient. The value range is 1-1.5, and the default value is 1.2.
[0189] This embodiment determines the size relationship between the first thread configuration amount and the second thread configuration amount, and accordingly selects the first descent calculation model or the second descent calculation model as the target calculation model, which can improve the calculation accuracy of the thread configuration amount of the current thread pool.
[0190] Based on the above embodiments, Fig.10 A flowchart of a sixth embodiment of a thread configuration method for a thread pool provided in an embodiment of the present application is shown in FIG. Fig.10 As shown, the above step S504 can be implemented by the following steps:
[0191] S1001. Obtain the number of core threads and the maximum number of threads in the current thread pool.
[0192] In the embodiment of the present application, the number of core threads refers to a fixed number of threads. These core threads will not be destroyed after the task is executed. The core threads can also be in an idle state. The maximum number of threads is the maximum value of the number of threads in the current thread pool.
[0193] Exemplarily, the value of the core thread number and the maximum thread number may be the same.
[0194] S1002. According to thread configuration information of the current thread pool, the number of core threads and the maximum number of threads are adjusted.
[0195] Exemplarily, the number of core threads and the maximum number of threads may be adjusted simultaneously, and the values of the number of core threads and the maximum number of threads are kept consistent during adjustment.
[0196] The embodiment of the present application can avoid the current thread pool from frequently creating or destroying threads by adjusting the number of core threads and the maximum number of threads of the current thread pool at the same time, and can effectively improve the task processing efficiency of the thread pool.
[0197] Based on the above embodiments, Fig.11A flow chart of another thread pool thread configuration method provided in an embodiment of the present application, wherein various parameters related to thread pool tasks include the number of CPU cores, target CPU utilization, CPU waiting time, CPU calculation time, the number of task requests per second of the thread pool, the total number of task requests of the thread pool, and the processing time of the task.
[0198] To summarize, the thread pool thread configuration method provided in the embodiment of the present application adaptively adjusts the thread size of the thread pool according to the various task request frequencies and their changes of multiple thread pools in multiple business scenarios, effectively solving the problem that the prior art does not consider the impact of task request frequencies and their changes on the thread pool size, and solves the problem that there are multiple thread pool tasks competing for resources in the application and the thread pool size cannot be accurately estimated, effectively improving the accuracy of thread pool size calculation in an environment with multiple thread pools.
[0199] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0200] Fig.12 A schematic diagram of the structure of a thread configuration device for a thread pool provided in an embodiment of the present application, wherein the device 110 may include a first configuration quantity acquisition module 111, a second configuration quantity acquisition module 112, an information acquisition module 113 and a configuration module 114.
[0201] The first configuration amount acquisition module 111 is used to acquire the first thread configuration amount of the thread pool of multiple business scenarios;
[0202] A second configuration amount acquisition module 112 is used to acquire a second thread configuration amount of a thread pool in a single business scenario;
[0203] The information acquisition module 113 is used to obtain the task request amount change trend of the current thread pool, and determine the thread configuration amount of the current thread pool according to the first thread configuration amount, the second thread configuration amount and the task request amount change trend;
[0204] The configuration module 114 is used to configure the number of threads in the current thread pool according to the thread configuration amount of the current thread pool.
[0205] In one embodiment, the first configuration quantity acquisition module 111 may include a task information acquisition module and an information processing module. The task information acquisition module is used to acquire the task request quantity and task processing duration of the thread pool of multiple business scenarios. The information processing module is used to acquire the first thread configuration quantity of the thread pool of multiple business scenarios according to the task request quantity and task processing duration.
[0206] In one embodiment, the above-mentioned second configuration quantity acquisition module 112 may include a proportion acquisition module, an initial quantity acquisition module and a data processing module, wherein the proportion acquisition module is used to obtain the task proportion of the thread pool of multiple business scenarios; the initial quantity acquisition module is used to obtain the initial thread configuration quantity of a single business scenario; the data processing module is used to obtain the second thread configuration quantity of the thread pool of a single business scenario based on the task proportion and the initial thread configuration quantity.
[0207] In one embodiment, the above-mentioned proportion acquisition module may include a total task amount acquisition unit and a proportion calculation unit. The total task amount acquisition unit is used to obtain the total task amount of the thread pool of multiple business scenarios; the proportion calculation unit is used to obtain the task proportion of the thread pool of multiple business scenarios based on the total task amount and the task request amount of each thread pool.
[0208] Among them, the thread pools of multiple business scenarios include more than two, and the total number of tasks is the sum of the task requests of each thread pool.
[0209] In one embodiment, the above-mentioned initial quantity acquisition module may include a CPU information acquisition unit and an initial quantity calculation unit, wherein the CPU information acquisition unit is used to obtain the number of cores of the central processing unit, the utilization rate of the central processing unit, the waiting time of the central processing unit and the calculation time of the central processing unit; the initial quantity calculation unit is used to obtain the initial thread configuration quantity of a single business scenario based on the number of cores of the central processing unit, the utilization rate of the central processing unit, the waiting time of the central processing unit and the calculation time of the central processing unit.
[0210] In one embodiment, the above-mentioned information acquisition module 113 may include a size relationship acquisition module, a model determination module and a configuration quantity calculation module, wherein the size relationship acquisition module is used to obtain the size relationship between the first thread configuration quantity and the second thread configuration quantity; the model determination module is used to determine the target computing model from multiple computing models pre-configured for calculating the current thread configuration quantity according to the size relationship and the trend of changes in the task request quantity; the configuration quantity calculation module is used to calculate the thread configuration quantity of the current thread pool according to the target computing model, the first thread configuration quantity and the second thread configuration quantity.
[0211] In one embodiment, if the task request amount change trend includes a growth trend, a stable trend and a downward trend, the above-mentioned model determination module includes a growth model determination module, a stable model determination module and a downward model determination module, wherein the growth model determination module is used to select a growth calculation model as the target calculation model from a plurality of calculation models pre-configured for calculating the current thread configuration amount according to a size relationship when the task request amount change trend is a growth trend; the stable model determination module is used to select a stable calculation model as the target calculation model from a plurality of calculation models pre-configured for calculating the current thread configuration amount according to a size relationship when the task request amount change trend is a stable trend; the downward model determination module is used to select a downward calculation model as the target calculation model from a plurality of calculation models pre-configured for calculating the current thread configuration amount according to a size relationship when the task request amount change trend is a downward trend.
[0212] In one embodiment, the above-mentioned growth model determination module may include a first growth model determination unit and a second growth model determination unit, wherein the first growth model determination unit is used to select the first growth calculation model as the target calculation model when the first thread configuration amount is greater than the second thread configuration amount; the second growth model determination unit is used to select the second growth calculation model as the target calculation model when the thread configuration amount of the thread pool of multiple business scenarios is not greater than the thread configuration amount of the thread pool of a single business scenario.
[0213] In one embodiment, the above-mentioned stable model determination module may include a first stable model determination unit and a second stable model determination unit, wherein the first stable model determination unit is used to select the first stable computing model as the target computing model when the thread configuration amount of the thread pool of the multi-business scenario is greater than the thread configuration amount of the thread pool of the single business scenario; the second stable model determination unit is used to select the second stable computing model as the target computing model when the thread configuration amount of the thread pool of the multi-business scenario is not greater than the thread configuration amount of the thread pool of the single business scenario.
[0214] In one embodiment, the above-mentioned descent model determination module may include a first descent model determination unit and a second descent model determination unit, wherein the first descent model determination unit is used to select the first descent calculation model as the target calculation model when the thread configuration amount of the thread pool of the multi-business scenario is greater than the thread configuration amount of the thread pool of the single business scenario; the second descent model determination unit is used to select the second descent calculation model as the target calculation model when the thread configuration amount of the thread pool of the multi-business scenario is not greater than the thread configuration amount of the thread pool of the single business scenario.
[0215] In one embodiment, the above-mentioned configuration module 114 may include a thread number acquisition unit and an adjustment unit, wherein the thread number acquisition unit is used to obtain the core thread number and the maximum thread number of the current thread pool; the adjustment unit is used to adjust the core thread number and the maximum thread number according to the thread configuration information of the current thread pool.
[0216] The device provided in the embodiment of the present application can be used to perform Figures 5 to 10 The implementation principle and technical effect of the method in the illustrated embodiment are similar and will not be described in detail here.
[0217] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or physically separated. Moreover, these modules can be all implemented in the form of software calling through processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software calling through processing elements, and some modules can be implemented in the form of hardware.
[0218] Optionally, an embodiment of the present application further provides a server, which is used to execute the above method steps.
[0219] An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method steps described above are implemented.
[0220] In the present application, "at least one" means one or more, and "plurality" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship; in the formula, the character " / " indicates that the previous and next associated objects are in a "division" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.
[0221] It is to be understood that the various numerical numbers involved in the embodiments of the present application are only for the convenience of description and are not intended to limit the scope of the embodiments of the present application. In the embodiments of the present application, the size of the sequence number of each process does not mean 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 application.
[0222] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A thread configuration method for a thread pool, characterized in that: include: Obtaining a first thread configuration amount of a thread pool for multiple business scenarios; the first thread configuration amount of the thread pool for multiple business scenarios is obtained according to a task request amount and a task processing duration of the thread pool for multiple business scenarios; Obtaining a second thread configuration amount of a thread pool for a single business scenario; the second thread configuration amount of the thread pool for the single business scenario is obtained according to a task proportion of the thread pool for multiple business scenarios and an initial thread configuration amount for the single business scenario; Obtaining a task request amount change trend of the current thread pool, and determining a thread configuration amount of the current thread pool according to the first thread configuration amount, the second thread configuration amount and the task request amount change trend; According to the thread configuration amount of the current thread pool, configure the threads of the current thread pool; The obtaining of the task request amount change trend of the current thread pool and determining the thread configuration amount of the current thread pool according to the first thread configuration amount, the second thread configuration amount and the task request amount change trend includes: Obtaining a magnitude relationship between the first thread configuration amount and the second thread configuration amount; Determining a target computing model from a plurality of computing models pre-configured for calculating the current thread configuration amount according to the size relationship and the change trend of the task request amount; The thread configuration amount of the current thread pool is calculated according to the target computing model, the first thread configuration amount, and the second thread configuration amount.
2. The method according to claim 1, characterized in that The obtaining of the first thread configuration amount of the thread pool of the multi-business scenario includes: Obtain the task request volume and task processing time of the thread pool in multiple business scenarios; The first thread configuration quantity of the thread pool for multiple business scenarios is obtained according to the task request quantity and the task processing duration.
3. The method according to claim 1 or 2, characterized in that: The obtaining of the second thread configuration amount of the thread pool of the single business scenario includes: Get the task proportion of thread pool in multiple business scenarios; Get the initial thread configuration for a single business scenario; According to the task proportion and the initial thread configuration amount, the second thread configuration amount of the thread pool of the single business scenario is obtained.
4. The method according to claim 3, characterized in that The task proportion of the thread pool for obtaining multiple business scenarios includes: Obtaining a total amount of tasks of a thread pool of multiple business scenarios, where the thread pool of the multiple business scenarios includes more than two, and the total amount of tasks is the sum of the task requests of each thread pool; According to the total amount of tasks and the amount of task requests of each thread pool, the task proportions of the thread pools in multiple business scenarios are obtained.
5. The method according to claim 3, characterized in that: The obtaining of the initial thread configuration amount of a single business scenario includes: Get the number of CPU cores, CPU usage, CPU waiting time, and CPU computing time; The initial thread configuration amount of the single business scenario is obtained according to the number of cores of the central processing unit, the utilization rate of the central processing unit, the waiting time of the central processing unit, and the calculation time of the central processing unit.
6. The method according to claim 1, characterized in that The task request amount change trend includes an increasing trend, a stable trend and a decreasing trend, and determining a target computing model from a plurality of computing models pre-configured for calculating the current thread configuration amount according to the size relationship and the task request amount change trend includes: When the change trend of the task request amount is an increasing trend, selecting a growth calculation model as the target calculation model from a plurality of calculation models pre-configured for calculating the current thread configuration amount according to the size relationship; When the change trend of the task request amount is a stable trend, selecting a stable calculation model from a plurality of calculation models pre-configured for calculating the current thread configuration amount according to the size relationship as the target calculation model; When the change trend of the task request amount is a downward trend, a downward calculation model is selected as the target calculation model from a plurality of calculation models pre-configured for calculating the current thread configuration amount according to the size relationship.
7. The method according to claim 6, characterized in that When the change trend of the task request amount is an increasing trend, selecting a growth calculation model as the target calculation model from a plurality of calculation models pre-configured for calculating the current thread configuration amount according to the size relationship, includes: When the first thread configuration amount is greater than the second thread configuration amount, selecting a first growth calculation model as the target calculation model; When the thread configuration amount of the thread pool of the multi-business scenario is not greater than the thread configuration amount of the thread pool of the single-business scenario, the second growth calculation model is selected as the target calculation model.
8. The method according to claim 6, characterized in that When the change trend of the task request amount is a stable trend, selecting a stable calculation model as the target calculation model from a plurality of calculation models pre-configured for calculating the current thread configuration amount according to the size relationship, includes: When the first thread configuration amount is greater than the second thread configuration amount, selecting a first stable computing model as the target computing model; When the first thread configuration amount is not greater than the second thread configuration amount, a second stable computing model is selected as the target computing model.
9. The method according to claim 6, characterized in that When the change trend of the task request amount is a downward trend, selecting a downward calculation model from a plurality of calculation models pre-configured for calculating the current thread configuration amount as the target calculation model according to the size relationship, includes: When the first thread configuration amount is greater than the second thread configuration amount, selecting a first descent calculation model as the target calculation model; When the first thread configuration amount is not greater than the second thread configuration amount, a second descent calculation model is selected as the target calculation model.
10. The method according to claim 1, characterized in that The configuring the number of threads in the current thread pool according to the thread configuration information of the current thread pool includes: Get the number of core threads and the maximum number of threads in the current thread pool; The number of core threads and the maximum number of threads are adjusted according to the thread configuration information of the current thread pool.
11. A thread configuration device for a thread pool, characterized in that: include: A first configuration amount acquisition module, used to acquire a first thread configuration amount of a thread pool for multiple business scenarios; the first thread configuration amount of the thread pool for multiple business scenarios is obtained according to a task request amount and a task processing time of the thread pool for multiple business scenarios; A second configuration amount acquisition module is used to acquire a second thread configuration amount of a thread pool for a single business scenario; the second thread configuration amount of the thread pool for a single business scenario is obtained according to a task proportion of the thread pool for multiple business scenarios and an initial thread configuration amount for a single business scenario; An information acquisition module, used to obtain a task request amount change trend of the current thread pool, and determine a thread configuration amount of the current thread pool according to the first thread configuration amount, the second thread configuration amount and the task request amount change trend; A configuration module, used to configure the number of threads in the current thread pool according to the thread configuration amount of the current thread pool; The information acquisition module is specifically used to obtain the size relationship between the first thread configuration amount and the second thread configuration amount; according to the size relationship and the change trend of the task request amount, determine the target computing model from multiple computing models pre-configured for calculating the current thread configuration amount; The thread configuration amount of the current thread pool is calculated according to the target computing model, the first thread configuration amount, and the second thread configuration amount.
12. A server, characterized in that: include: memory, processors and computer programs; The computer program is stored in the memory and is configured to be executed by the processor to implement the method steps as claimed in any one of claims 1 to 10.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method steps according to any one of claims 1 to 10 are implemented.
Citation Information
Patent Citations
Machine learning-based DNS thread management method and apparatus, and server
CN108446170A
Thread allocation method and device, computer equipment and storage medium
CN110569123A
Abnormal task processing method and device, medium and electronic equipment
CN111459754A
Dynamic thread pool management
US20160350157A1
