Method for generating configuration information of thread pool, task processing method and device
By obtaining the historical time-consuming data of the interface, the interface time-consuming threshold is determined and the thread pool configuration information is generated. The thread partition is dynamically adjusted, which solves the problem of thread pool management, improves the processing efficiency and business stability of the thread pool, and avoids thread pool congestion.
Patent Information
- Application Number
- CN202210450181.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-26
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2042-04-26
AI Technical Summary
The existing technology is difficult to effectively manage the thread pool, resulting in thread pool blocking and performance impact. In particular, it is difficult to determine a reasonable timeout threshold in actual business scenarios, which affects the stability of online business.
By obtaining the historical time-consuming data of the interface of the target application, determine the interface time-consuming threshold of each interface, and generate thread pool configuration information based on these thresholds, dynamically adjust thread partitions, process tasks in a priority matching and resource isolation manner, and avoid thread pooling. clogged.
It improves the processing efficiency of the thread pool and the stability of online services, reduces thread pool blocking caused by misjudgments, and enhances the system's robustness and task completion rate.
Smart Images

Figure CN114995996B
Abstract
Description
Technical Field
[0001] The embodiments of this specification generally relate to the field of computer technology, and more particularly to a method for generating configuration information of a thread pool, a task processing method and an apparatus. Background Art
[0002] A thread pool is a thread usage mode. Too many threads will bring scheduling overhead, which will affect cache locality and overall performance. The thread pool maintains multiple threads, reduces the consumption caused by thread creation and destruction by reusing the created threads, and can also improve the response speed and thread manageability. In actual business scenarios, all threads of an application (application, APP) often share the same thread pool, that is, multiple interfaces of the application call thread resources from the same thread pool. Therefore, when a thread has a problem and cannot be executed, the remaining threads in the thread pool can only wait passively, causing the entire thread pool to be blocked and causing online failures. Although the prior art can determine whether a timeout has occurred by whether the task execution time of the thread is greater than a predetermined threshold, it is difficult to determine a reasonable threshold as a distinction due to the complex scenarios of actual business. Therefore, how to manage the threads in the thread pool to improve the processing efficiency of the thread pool and ensure the stability of online business has become an urgent problem to be solved. Summary of the invention
[0003] In view of the above, the embodiments of this specification provide a method for generating configuration information of a thread pool, a task processing method and a device. By using this method and device, the threads in the thread pool can be managed to improve the processing efficiency of the thread pool and ensure the stability of online services.
[0004] According to one aspect of an embodiment of the present specification, a method for generating configuration information of a thread pool is provided, comprising: obtaining historical time consumption data of each interface in an interface set of a target application; determining an interface time consumption threshold of each interface based on the historical time consumption data of each interface, wherein the interface time consumption threshold of each interface is used to determine the timeout risk of a thread when being called by the interface; and generating configuration information of a thread pool corresponding to the target application based on the interface time consumption threshold of each interface, wherein the thread pool includes threads created via each interface, and the configuration information includes an identifier of each interface and a corresponding interface time consumption threshold.
[0005] According to another aspect of an embodiment of the present specification, a task processing method is provided, comprising: receiving a task to be processed via a target interface of a target application; calling a thread created via the target interface from a thread partition of a thread pool of the target application that matches the thread priority of the target interface, the thread pool comprising a plurality of resource-isolated thread partitions, each thread partition having a specified thread priority; executing the task to be processed using the called thread; and dynamically adjusting the thread partition in which the called thread is located according to the thread execution time of the called thread and the interface time consumption threshold of the target interface in the configuration information of the thread pool, the configuration information of the thread pool comprising the identifier of each interface and the corresponding interface time consumption threshold, the interface time consumption threshold of each interface being determined based on the historical time consumption data of each interface.
[0006] According to another aspect of an embodiment of the present specification, a device for generating configuration information of a thread pool is provided, comprising: a time consumption data acquisition unit, configured to acquire historical time consumption data of each interface in an interface set of a target application; an interface threshold determination unit, configured to determine an interface time consumption threshold of each interface based on the historical time consumption data of each interface, wherein the interface time consumption threshold of each interface is used to determine the timeout risk of a thread when being called by the interface; and a configuration information generation unit, configured to generate configuration information of a thread pool corresponding to the target application based on the interface time consumption threshold of each interface, wherein the thread pool includes threads created via each interface, and the configuration information includes an identifier of each interface and a corresponding interface time consumption threshold.
[0007] According to another aspect of an embodiment of the present specification, a task processing device is provided, comprising: a task receiving unit, configured to receive a task to be processed via a target interface of a target application; a thread calling unit, configured to call a thread created via a target interface from a thread partition of a thread pool of a target application that matches the thread priority of the target interface, the thread pool comprising a plurality of resource-isolated thread partitions, each thread partition having a specified thread priority; a task execution unit, configured to execute the task to be processed using the called thread; a thread adjustment unit, configured to dynamically adjust the thread partition where the called thread is located according to the thread execution time of the called thread and the interface time consumption threshold of the target interface in the configuration information of the thread pool, the configuration information of the thread pool comprising the identifier of each interface and the corresponding interface time consumption threshold, the interface time consumption threshold of each interface being determined based on the historical time consumption data of each interface.
[0008] According to another aspect of an embodiment of the present specification, there is provided an apparatus for generating configuration information of a thread pool, comprising: at least one processor, and a memory coupled to the at least one processor, and a computer program stored on the memory, wherein the at least one processor executes the computer program to implement the method for generating configuration information of a thread pool as described above.
[0009] According to another aspect of an embodiment of the present specification, there is provided a task processing device, comprising: at least one processor, and a memory coupled to the at least one processor, and a computer program stored in the memory, wherein the at least one processor executes the computer program to implement the task processing method as described above.
[0010] According to another aspect of an embodiment of the present specification, a computer-readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the method for generating configuration information of a thread pool or the task processing method as described above is implemented.
[0011] According to another aspect of an embodiment of the present specification, a computer program product is provided, including a computer program, wherein the computer program is executed by a processor to implement the method for generating configuration information of a thread pool or the task processing method as described above. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] A further understanding of the nature and advantages of the content of this specification may be achieved by referring to the following drawings. In the drawings, similar components or features may have the same reference numerals.
[0013] Figure 1 An exemplary architecture of a method for generating configuration information of a thread pool, a task processing method, and an apparatus according to an embodiment of the present specification is shown.
[0014] Figure 2 A flowchart of a method for generating configuration information of a thread pool according to an embodiment of the present specification is shown.
[0015] Figure 3 A schematic diagram showing an example of a process for determining interface time consumption thresholds of various interfaces according to an embodiment of this specification.
[0016] Figure 4a A schematic diagram showing an example of a process for determining time-consuming data distribution of various interfaces according to an embodiment of this specification.
[0017] Figure 4b A schematic diagram showing an example of a method for determining a peak interval set of timing consumption data of a certain interface according to an embodiment of this specification.
[0018] Figure 5 A schematic diagram showing another example of a process for determining an interface time consumption threshold of each interface according to an embodiment of this specification.
[0019] Figure 6 A schematic diagram showing another example of a process for determining an interface time consumption threshold value of each interface according to an embodiment of this specification
[0020] Figure 7 A flowchart of a task processing method according to an embodiment of the present specification is shown.
[0021] Figure 8 A schematic diagram showing an example of an application scenario of the task processing method according to an embodiment of the present specification.
[0022] Fig. 9 A block diagram showing an example of a device for generating configuration information of a thread pool according to an embodiment of the present specification.
[0023] Fig.10 A block diagram showing an example of an interface threshold determination unit in an apparatus for generating configuration information of a thread pool according to an embodiment of this specification.
[0024] Fig.11 A block diagram showing an example of an interface threshold determination module in an apparatus for generating configuration information of a thread pool according to an embodiment of this specification.
[0025] Fig.12 A block diagram showing an example of a task processing device according to an embodiment of the present specification.
[0026] Fig.13 A schematic diagram of a device for generating configuration information of a thread pool according to an embodiment of the present specification is shown.
[0027] Fig.14 A schematic diagram of a task processing device according to an embodiment of the present specification is shown. DETAILED DESCRIPTION
[0028] The subject matter described herein will be discussed below with reference to example implementations. It should be understood that the discussion of these implementations is only to enable those skilled in the art to better understand and implement the subject matter described herein, and is not a limitation of the scope of protection, applicability or examples set forth in the claims. The functions and arrangements of the elements discussed may be changed without departing from the scope of protection of the embodiments of this specification. Various processes or components may be omitted, substituted or added to each example as needed. In addition, the features described relative to some examples may also be combined in other examples.
[0029] As used herein, the term "including" and its variations represent open terms, meaning "including but not limited to". The term "based on" means "based at least in part on". The terms "one embodiment" and "an embodiment" mean "at least one embodiment". The term "another embodiment" means "at least one other embodiment". The terms "first", "second", etc. may refer to different or the same objects. Other definitions may be included below, whether explicit or implicit. Unless the context clearly indicates otherwise, the definition of a term is consistent throughout the specification.
[0030] In this specification, the term "application" may refer to application software. An "application" may generally include multiple interfaces. Each interface may execute tasks by calling threads in a thread pool to implement interface-specific functions.
[0031] In this specification, the term "distribution" can be used to describe the frequency of occurrence of each value in data. For example, a histogram can be used to show the frequency or frequency of occurrence of each value in a data set.
[0032] In this specification, the term "kernel density estimation" (KDE) refers to a density function used in probability theory to estimate unknowns, and is one of the non-parametric test methods. Compared with the estimation using histograms, the kernel density estimation can obtain a smooth distribution and get rid of the influence of the number of groups, thereby better defining the distribution shape.
[0033] In this specification, the term "confidence level" refers to the probability that the value of a population parameter falls within a certain interval of the sample statistic value. From the perspective of a probability statement method (i.e., the interval estimation method in mathematical statistics), it refers to the corresponding probability that the estimated value and the population parameter are within a certain allowable error range. The term "confidence interval" refers to the error range between the sample statistic value and the population parameter value at a certain confidence level. The terms "upper confidence limit" and "lower confidence limit" are used to indicate the two endpoints of the above-mentioned "confidence interval" respectively.
[0034] The method for generating configuration information of a thread pool, the task processing method and the device according to the embodiments of this specification will be described in detail below with reference to the accompanying drawings.
[0035] Figure 1 An exemplary architecture 100 of a method for generating configuration information of a thread pool, a task processing method, and an apparatus according to an embodiment of this specification is shown.
[0036] exist Figure 1In the example, networks 111 , 112 , 113 are used to interconnect terminal devices 121 , 122 , 123 , 124 and application 1 server 131 , application 2 server 132 and configuration server 140 .
[0037] The networks 111, 112, 113 may be any type of network capable of interconnecting network entities. The networks 111, 112, 113 may be a single network or a combination of various networks. In terms of coverage, the networks 111, 112, 113 may be a local area network (LAN), a wide area network (WAN), etc. In terms of carrier media, the networks 111, 112, 113 may be a wired network, a wireless network, etc. In terms of data exchange technology, the networks 111, 112, 113 may be a circuit switching network, a packet switching network, etc.
[0038] Terminal devices 121 and 122 may be any type of electronic computing device capable of connecting to network 111, accessing a server or website on network 111, processing data or signals, etc. Similarly, terminal devices 123 and 124 may be any type of electronic computing device capable of connecting to network 112, accessing a server or website on network 112, processing data or signals, etc. For example, terminal devices 121, 122, 123, and 124 may be desktop computers, laptop computers, tablet computers, smart phones, etc. Although Figure 1 Only a few terminal devices are shown, but it should be understood that a different number of terminal devices may be connected to the networks 111 , 112 .
[0039] In one embodiment, the terminal devices 121, 122, 123, 124 may be used by a user. The terminal devices 121, 122, 123, 124 may include application clients (e.g., application 1 client 1211, application 1 client 1221, application 2 client 1232, application 2 client 1242) that may provide various services to the user. In some cases, the application 1 clients 1211, 1221 may interact with the application 1 server 131. For example, the application 1 clients 1211, 1221 may transmit a message input by a user to the application 1 server 131, and receive a response associated with the message from the application 1 server 131. Similarly, the application 2 clients 1232, 1242 may transmit a message input by a user to the application 2 server 132, and receive a response associated with the message from the application 2 server 132. However, it should be understood that in other cases, the application 1 client 1211 , 1221 or the application 2 client 1232 , 1242 may also generate a response to the user input message locally instead of interacting with the application 1 server 131 or the application 2 server 132 .
[0040] In this specification, "message" may refer to any input information, such as a query statement input by a user. The above-mentioned "message" may be processed by the above-mentioned application 1 client 1211, application 1 client 1221, application 2 client 1232, and application 2 client 1242 to generate a corresponding request, and may be transmitted to interface 1', interface 2' of application 1 server 131 or interface 3', interface 4' of application 2 server 132 via network 111, 112 via corresponding interface 1, interface 2, interface 3, or interface 4. Application 1 server 131 and application 2 server 132 may be connected to configuration server 140 via network 113. Configuration server 140 may be used to support application 1 server 131 and application 2 server 132 to generate response information, for example, configuration information 141, 142 of thread pool 1311, 1321 corresponding to application 1 or application 2 may be generated.
[0041] It should be understood that Figure 1 All network entities shown in the figure are exemplary. Any other network entities may be involved in the architecture 100 according to specific application requirements.
[0042] Figure 2 A flowchart of a method 200 for generating configuration information of a thread pool according to an embodiment of the present specification is shown.
[0043] like Figure 2 As shown, at 210, historical time consumption data of each interface in the interface set of the target application is obtained.
[0044] In this embodiment, the historical time-consuming data of each interface in the interface set of the target application can be obtained in various ways. As an example, the historical time-consuming data of each interface in the interface set of the target application can be obtained from a local or communication-connected electronic device. Among them, the target application can be any pre-specified application, or it can be an application determined according to preset rules. The above-mentioned historical time-consuming data may include various data for characterizing the historical response time (response time, RT) of the interface. For example, the above-mentioned historical time-consuming data may be the average time consumed by a certain interface in the past period of time. For another example, the above-mentioned historical time-consuming data may be a data set formed by the response time corresponding to each response of a certain interface in the past period of time.
[0045] It should be noted that the target application may generally include multiple interfaces. The above interface set may include all or part of the interfaces of the above target application, which is not limited here. It can be understood that the above historical time consumption data generally corresponds to the identification of the application and the identification of the interface, and optionally may also correspond to the identification of the function or method contained in the interface, so that the historical time consumption data of each interface can be distinguished.
[0046] At 220, the interface time consumption threshold of each interface is determined according to the historical time consumption data of each interface. In this embodiment, the interface time consumption threshold of each interface can be used to determine the timeout risk of the thread when it is called by the interface. The interface time consumption threshold of each interface can be determined by various methods according to the historical time consumption data of each interface obtained in step 210. As an example, if the historical time consumption data of the above interface is the average time consumption of the interface in the past period of time, the result obtained by multiplying the average time consumption by a coefficient greater than 1 (for example, 1.5) can be determined as the interface time consumption threshold of the interface. As another example, if the historical time consumption data of the above interface is a data set formed by the response time corresponding to each response of the interface in the past period of time, the distinction value corresponding to the largest top 10% of the response time in the above data set can be determined as the interface time consumption threshold of the interface. For example, if the above data set contains 10 data, the interface time consumption threshold of the interface can be determined as a value between the largest data and the second largest data in the above data set. For another example, if the data set includes 100 data, the interface time consumption threshold of the interface may be determined as a value between the 10th data and the 11th data in the data set arranged from large to small.
[0047] It should be noted that it is understandable that the data volume of the historical time consumption data of each of the above interfaces usually needs to reach a certain number to prevent the accuracy of the determined interface time consumption threshold from being affected due to insufficient data.
[0048] Figure 3 FIG. 3 is a schematic diagram showing an example of a process 300 for determining an interface time-consuming threshold value of each interface according to an embodiment of the present specification. Figure 3 In the example, the historical time consumption data of each interface may include the time series time consumption data of the interface within a preset historical period. The preset historical period may be determined according to the actual application scenario, such as within the past 24 hours, within the past week, etc. The time series time consumption data is usually used to refer to the numerical elements in each piece of historical time consumption data being arranged in chronological order. The numerical elements may be used to represent the response time of each response.
[0049] like Figure 3 As shown, at 310, the time consumption data distribution of each interface is determined according to the historical time consumption data of each interface. In this embodiment, for the historical time consumption data of each interface, the time consumption data distribution of the interface can be obtained according to the number of times each value appears in the historical time consumption data of the interface. Thus, the time consumption data distribution of each interface can be determined.
[0050] At 320, kernel density estimation is performed on the time consumption data distribution of each interface to generate a probability density distribution corresponding to the time consumption data of each interface. Density estimation can be performed on the time consumption data distribution of each interface determined above using various commonly used kernel functions (such as Gaussian curve, Epanechnikov curve, etc.), so as to obtain the probability density distribution corresponding to the time consumption data of each interface. It can be understood that the probability density distribution obtained here is a probability density function obtained by kernel density estimation.
[0051] At 330, the interface time threshold of each interface is determined according to the upper confidence limit corresponding to the preset confidence level in the probability density distribution of each interface. In this embodiment, for each interface, the upper confidence limit corresponding to the preset confidence level (for example, 90%, 95%, etc.) in the probability density distribution of the interface obtained in step 320 can be determined. Furthermore, the interface time threshold of each interface can be determined according to the determined upper confidence limit of each interface. As an example, the upper confidence limit of each interface can be directly determined as the corresponding interface time threshold. Among them, the above-mentioned preset confidence level can be flexibly set according to actual needs and is not limited here.
[0052] It can be seen that Figure 3 The illustrated embodiment can determine the distribution of time consumption data of each interface according to the sequential time consumption data of the interface within a preset historical period, and then generate the corresponding probability density distribution using kernel density estimation, and then determine the interface time consumption threshold of each interface according to the confidence upper limit corresponding to the preset confidence level in the probability density distribution. Compared with the assumption in the prior art that the response time of the interface does not change significantly and fluctuates around the central value, it more objectively takes into account that each response time of the same interface will have a certain span due to different internal and external resource conditions, different parameters of the executed tasks, etc., and the method of determining the interface time consumption threshold of the interface granularity based on kernel density estimation makes the determination of the interface time consumption threshold more reasonable, which helps to ensure the stability of the online system.
[0053] In some optional implementations of this embodiment, the above-mentioned preset bottom threshold can be pre-set according to the actual application scenario, or can be determined according to the numerical level (such as the average value) of the interface time threshold determined over a period of time in the past, which is not limited here. For each interface, the larger value of the confidence upper limit corresponding to the preset confidence level in the probability density distribution corresponding to the interface and the preset bottom threshold can be determined as the interface time threshold of the interface.
[0054] It should be noted that the above-mentioned preset bottom threshold can be the same value for all interfaces, or different values for different interfaces, and there is no limitation here.
[0055] It can be seen that the above implementation method provides a strategy for setting a bottom threshold to determine the interface time threshold, which can effectively reduce the adverse effects of estimation deviations caused by insufficient data or limited accuracy of the calculation method.
[0056] Figure 4a A schematic diagram showing an example of a process 400 for determining time-consuming data distribution of various interfaces according to an embodiment of this specification.
[0057] like Figure 4a As shown, at 410, the peak interval set in the timing time consumption data of each interface is determined. In this embodiment, the peak interval set in the timing time consumption data of each interface can be determined by various peak interval detection methods. As an example, Figure 4b A schematic diagram of an example of a method for determining a peak interval set of timing time consumption data of a certain interface according to an embodiment of the present specification is shown. For example, a preset quantile (e.g., 75%) can be used to determine the peak interval set of the above timing time consumption data. It can be understood that, for each interface, the time consumption data in the peak interval set of the interface can be understood as the local maximum value of the time consumption data filtered out from the timing time consumption data of the interface.
[0058] At 420, the time consumption data in each peak interval in the peak interval set of each interface is resampled. In this embodiment, the time consumption data in each peak interval in the peak interval set of each interface determined in the above step 410 can be resampled by various sampling methods (such as random sampling, stratified sampling, weighted sampling, etc.).
[0059] At 430, the distribution of the time consumption data of each interface is determined according to the resampled time consumption data of each interface. In this embodiment, the distribution of the time consumption data of each interface can be determined according to the resampled time consumption data of each interface obtained in step 420 in various ways.
[0060] visible, Figure 4a The illustrated embodiment can determine the distribution of time-consuming data of each interface by resampling the time-consuming data in each peak interval of the peak interval concentration of the time-consuming data of each interface. This further reflects the idea that when the "interface time-consuming threshold" is used as the basis for timeout determination, more consideration should be given to the larger value of the normal response time, so as to avoid misjudging tasks that should have taken a long time as timeouts, thereby providing a technical basis for improving the rationality of the determined interface time-consuming threshold.
[0061] In particular, in actual scenarios, due to the mutual influence between various operations of a large number of users, the independence assumption of the Gaussian distribution is not met. Therefore, the results presented by the statistics of the average time consumption data of all interfaces in the prior art often deviate greatly from the Gaussian distribution. The inventors found that, analogous to the central limit theorem, when the time consumption data in the above peak interval is resampled by random sampling, for each interface, the distribution of the time consumption data of the interface obtained is just close to the normal distribution. Therefore, on this basis, the Gaussian kernel is used for kernel density estimation processing, which is more in line with the actual situation than the above-mentioned prior art method, and thus has higher accuracy.
[0062] Figure 5 A schematic diagram showing another example of a process 500 for determining an interface time consumption threshold of each interface according to an embodiment of this specification.
[0063] like Figure 5 As shown, at 510, the time period consumption threshold of each interface in the preset historical period is determined according to the upper confidence limit corresponding to the preset confidence level in the probability density distribution of each interface. In this embodiment, for each interface, the upper confidence limit corresponding to the preset confidence level (for example, 90%, 95%, etc.) in the probability density distribution of the interface can be determined. Furthermore, the time period consumption threshold of each interface in the preset historical period can be determined according to the determined upper confidence limit of each interface. Among them, the above-mentioned time period consumption threshold is used to characterize the interface time consumption threshold calculated for the above-mentioned preset historical period.
[0064] At 520, the target number of time-consuming thresholds of the time-consuming thresholds of the preset time intervals and the preset historical time periods are selected from the pre-stored time-consuming thresholds of the time periods of each interface. In this embodiment, the time-consuming thresholds of the time periods of each interface in multiple preset historical time periods can be pre-stored. As an example, when the preset historical time period is within the past 24 hours, the preset time interval associated with the preset historical time period can be, for example, within the past week or within the past month. It can be seen that the target number of time-consuming thresholds of the time period associated with the preset time interval and the preset historical time period can be the time-consuming thresholds of the daily time periods within the past week or within the past month. Optionally, the time-consuming thresholds corresponding to the time periods of each interface determined in the above step 510 in the above preset historical time period can also be stored, and accordingly, the corresponding interface identifier and the preset historical time period can be stored at the same time for subsequent selection of the time-consuming thresholds over time. The above "associated with the preset historical time period" can be determined according to the actual application scenario, such as being continuous with the above preset historical time period, belonging to the same time period as the above preset historical time period (for example, both belong to 10:00-12:00), etc.
[0065] At 530, for each interface, the interface time consumption threshold of the interface is determined according to the selected target number of time consumption thresholds and the determined time consumption threshold. In this embodiment, for each interface, the interface time consumption threshold of the interface can be determined in various ways according to the target number of time consumption thresholds and the determined time consumption threshold selected in the above step 520. As an example, the interface time consumption threshold of each interface can be determined by weighted summation, time series prediction, etc.
[0066] visible, Figure 5 The illustrated embodiment can determine the interface time consumption threshold of each interface by combining multiple time consumption thresholds associated with a preset historical period, thereby further improving the rationality of the determined interface time consumption threshold, and further providing a technical basis for enhancing the robustness of the entire system.
[0067] In some optional implementations of this embodiment, Figure 6 A schematic diagram showing another example of a process 600 for determining an interface time consumption threshold of each interface according to an embodiment of this specification.
[0068] like Figure 6 As shown, at 610, for each interface, the selected target number of time-consuming thresholds and the determined time-consuming thresholds are subjected to noise reduction processing according to the preset noise reduction conditions to generate a noise-reduced time-consuming threshold set for the interface. Among them, the above-mentioned noise reduction processing may include various processing methods for further screening the selected target number of time-consuming thresholds. As an example, the above-mentioned preset noise reduction conditions may include, but are not limited to, at least one of the following: sub-period screening conditions, abnormal value screening conditions. Among them, the above-mentioned sub-period screening conditions may, for example, be that the time period corresponding to the selected time-consuming threshold belongs to a preset screening time interval (for example, during the big promotion period such as "6.18", "11.11", etc.). The above-mentioned abnormal value screening conditions may, for example, be that the time-consuming threshold is outside the preset regular interval (that is, a particularly large or small value appears).
[0069] At 620, for each interface, the interface time consumption threshold of the interface is determined according to the noise-reduced period time consumption threshold set. As an example, the interface time consumption threshold of each interface can be determined by weighted summation, time series prediction, etc.
[0070] visible, Figure 6 The illustrated embodiment provides a method for determining the interface time consumption threshold of each interface based on noise reduction processing of the selected time period time consumption threshold, reducing the adverse impact of abnormal values on the determined final result, thereby further improving the accuracy of the determined interface time consumption threshold.
[0071] Back to Figure 2At 230, according to the interface time-consuming thresholds of each interface, the configuration information of the thread pool corresponding to the target application is generated. Among them, the above-mentioned thread pool may include threads created via each interface. And the above-mentioned configuration information may include the identification of each interface and the corresponding interface time-consuming threshold. As an example, the above-mentioned target application may include 6 interfaces. The configuration information of the above-mentioned thread pool may include the identification of the above-mentioned 6 interfaces: facade1, facade2, facade3, facade4, facade5, facade6. Correspondingly, the corresponding interface time-consuming thresholds may be: 35ms, 105ms, 77ms, 31ms, 264ms, 231ms respectively. Optionally, the configuration information of the above-mentioned thread pool may also include but is not limited to at least one of the following: the identification of the application to which the interface belongs (such as the name of the above-mentioned target application), the function implemented by the interface (such as the function name, the method name in Java), and the maximum number of threads that the interface can create.
[0072] In some optional implementations of this embodiment, the thread pool may include multiple thread partitions with resource isolation. Each of the thread partitions may have a specified thread priority, and the threads in each thread partition may be called by an interface with a corresponding thread priority. As an example, the thread pool may include a first thread partition and a second thread partition. The priority of the threads in the first thread partition is usually higher than the priority of the threads in the second thread partition. In addition, the six interfaces included in the target application may include, for example, interfaces facade1, facade2, and facade3 with higher priorities and interfaces facade4, facade5, and facade6 with lower priorities. Thus, the threads in the first thread partition may be called by interfaces facade1, facade2, and facade3; and the threads in the second thread partition may be called by interfaces facade4, facade5, and facade6. It should be noted that the priority of the interface may be determined, for example, according to the business type corresponding to the interface (for example, payment business and other business types requiring high reliability and ordinary business types), or may be determined according to the historical time consumption level of the interface, which is not specifically limited here. Optionally, the configuration information of the thread pool may further include a correspondence between interfaces and thread partitions.
[0073] In these implementations, step 240 may be further performed: the configuration information of the generated thread pool is sent to the target application, so that when the target application calls a thread in the thread pool via an interface to perform a task, the thread partition where the called thread is located is dynamically adjusted according to the thread execution time of the called thread and the interface time threshold of the interface in the configuration information. Among them, the above-mentioned target application may call the thread in the above-mentioned thread pool via an interface to perform the corresponding task. Generally, the above-mentioned target application may dynamically adjust the thread partition where the called thread is located according to the thread execution time of the called thread and the interface time threshold of the interface in the configuration information. As an example, a thread whose thread execution time of the called thread is greater than the interface time threshold of the interface may be adjusted to other thread partitions with a lower priority of the specified thread.
[0074] It can be seen that the above optional implementation method provides a solution for sending the configuration information of the generated thread pool to the target application, so that the target application dynamically adjusts the thread partition of the called thread according to the thread execution time of the called thread and the interface time threshold of the interface in the configuration information, thereby avoiding thread congestion of the entire thread pool due to a failure of a certain thread, thereby improving the stability of the online service system.
[0075] Optionally, in some embodiments, when dynamically adjusting the thread partition where the called thread is located according to the thread execution time of the called thread and the interface time threshold of the interface in the configuration information, the thread partition where the called thread is located can be dynamically adjusted according to the thread execution time of the called thread, the interface time threshold of the interface in the configuration information, and the partition reference threshold of the thread partition. The partition reference threshold of the above-mentioned thread partition can be used to divide adjacent thread partitions of the thread pool. For example, the thread pool may include a first partition and a second partition. The partition reference threshold can be used to distinguish the above-mentioned first partition and the second partition. For another example, the thread pool may include a first partition, a second partition, and a third partition. Thus, there may be an upper partition reference threshold for distinguishing the above-mentioned first partition and the second partition and a lower partition reference threshold for distinguishing the above-mentioned second partition and the third partition. The partition reference threshold of the above-mentioned thread partition can be determined in various ways. For example, the partition reference threshold of the above-mentioned thread partition can be determined according to the interface time threshold and preset quantile of each interface in the interface set of the above-mentioned target application. For another example, the partition reference threshold of the above-mentioned thread partition can be pre-set.
[0076] In these embodiments, as an example, after determining that the thread execution time of the called thread (for example, the thread in the first partition mentioned above) is greater than the interface time consumption threshold of the interface in the configuration information, it can be further determined whether the thread execution time of the called thread is greater than the partition reference threshold of the thread partition (for example, the upper partition reference threshold mentioned above). When it is greater than the partition reference threshold of the thread partition, the called thread is adjusted to the thread partition with a lower thread priority divided by the corresponding partition reference threshold (for example, the second partition mentioned above).
[0077] It can be seen that the above optional implementation method provides a solution for sending the configuration information of the generated thread pool to the target application, so that the target application dynamically adjusts the thread partition where the called thread is located according to the thread execution time of the called thread, the interface time threshold of the interface in the configuration information, and the partition reference threshold of the thread partition. In this way, while ensuring that the task is completed as much as possible, thread congestion caused by a certain thread taking too long is avoided, which enriches the method of dynamically adjusting the thread partition where the called thread is located, and can take into account both the task completion rate and the system stability.
[0078] In some optional implementations of this embodiment, the above-mentioned multiple thread partitions may include a fast response area, a regular response area, and an exception handling area with thread priorities decreasing in sequence. The above-mentioned configuration information may also include a first partition reference threshold for dividing the fast response area and the regular response area, a second partition reference threshold for dividing the regular response area and the exception handling area, and an exception handling timeout threshold. The above-mentioned first partition reference threshold may be determined based on the interface time threshold of each interface and the partition thread ratio. Among them, the above-mentioned partition thread ratio may be the ratio between the number of threads in the above-mentioned fast response area and the above-mentioned regular response area. As an example, when the above-mentioned ratio is 3:7, the above-mentioned first partition reference threshold may be the last (for example, there are 50 interfaces, the 15th) interface time threshold in the first 30% of the interface time thresholds of the above-mentioned interfaces arranged from small to large. The above-mentioned second partition reference threshold and the exception handling timeout threshold (for example, 2000ms) may be determined according to the interface time threshold of each interface in the interface set of the above-mentioned target application (for example, it may be the maximum interface time threshold), or may be pre-set by a technician. It should be noted that the above-mentioned first partition reference threshold, second partition reference threshold and exception handling timeout threshold are usually interface-independent (that is, they are the same values for each interface), so that a more flexible and reasonable thread dynamic adjustment scheme is formed by coordinating the above-mentioned interface-independent values and the interface time consumption threshold of the interface granularity.
[0079] It can be seen that, by using the above optional implementation method, a solution is provided for dividing the thread pool into a fast response area, a regular response area, and an exception handling area with thread priorities decreasing in sequence, and the configuration information also includes a first partition reference threshold for dividing the fast response area and the regular response area, a second partition reference threshold for dividing the regular response area and the exception handling area, and an exception handling timeout threshold, and the first partition reference threshold is determined based on the interface time consumption threshold of each interface and the partition thread ratio. Thus, a complete, more flexible, and reasonable thread dynamic adjustment solution is provided.
[0080] use Figure 1-Figure 6 The method for generating configuration information of a thread pool disclosed in the disclosure can obtain the historical time consumption data of each interface in the interface set of the target application, determine the interface time consumption threshold of each interface for determining the timeout risk of the thread when being called by the interface, and generate the configuration information of the thread pool including the interface time consumption threshold of the interface granularity. Compared with the traditional use of a unified timeout judgment threshold for the thread pool corresponding to the entire application, by drilling down the threshold for judging thread timeout from the application level to the interface level, each interface is analyzed separately, and the interface time consumption threshold of the interface granularity can effectively distinguish the time consumption differences between different interfaces in actual application scenarios, effectively reduce the misjudgment caused by "one size fits all", and thus improve the stability of the online service system.
[0081] Figure 7 A flowchart of a task processing method 700 according to an embodiment of the present specification is shown.
[0082] like Figure 7 As shown, at 710, a task to be processed is received via a target interface of a target application. The target interface may be any pre-specified interface (e.g., interface 3, interface 5), or an interface determined according to a preset rule (e.g., an interface that receives a task to be processed of a certain type). The task to be processed may include various tasks that can be completed by the target interface of the target application, such as query tasks and modification tasks in payment services.
[0083] At 720, a thread created via the target interface is called from a thread partition of the thread pool of the target application that matches the thread priority of the target interface. The thread pool may include multiple thread partitions with resource isolation. Each thread partition may have a specified thread priority. For more information about the thread pool, please refer to Figure 2The corresponding description in the optional implementation of step 230 in the embodiment is not repeated here. It can be understood that when there are no idle threads in the thread pool and the number of threads allows to continue to create threads, the target interface can create threads in the thread partition that matches the thread priority of the target interface. When there are idle threads created by the target interface in the thread pool, the target interface can directly call the thread created via the target interface.
[0084] At 730, the task to be processed is executed using the called thread.
[0085] At 740, the thread partition where the called thread is located is dynamically adjusted according to the thread execution time of the called thread and the interface time threshold of the target interface in the configuration information of the thread pool. The configuration information of the thread pool may include the identifier of each interface and the corresponding interface time threshold. The interface time threshold of each interface may be determined based on the historical time data of each interface. The above content can be referred to as Figure 2 The corresponding description of the optional implementation method of step 240 of the embodiment is not repeated here. Specifically, a monitoring program can be set to monitor whether the thread execution time exceeds the interface time threshold of the target interface.
[0086] In some optional implementations of this embodiment, the thread partition where the called thread is located can also be dynamically adjusted according to the thread execution time of the called thread, the interface time consumption threshold of the target interface in the configuration information of the thread pool, and the partition reference threshold of the thread partition. Figure 2 The corresponding description in the optional implementation of step 240 of the embodiment will not be repeated here.
[0087] It can be seen that the above optional implementation method provides a solution for dynamically adjusting the thread partition of the called thread according to the thread execution time of the called thread, the interface time consumption threshold of the target interface in the configuration information of the thread pool, and the partition reference threshold of the thread partition. This avoids thread congestion caused by a certain thread consuming too long while ensuring that the task is completed as much as possible, enriches the method of dynamically adjusting the thread partition of the called thread, and can take into account both the task completion rate and the system stability.
[0088] In some optional implementations of this embodiment, the above-mentioned multiple thread partitions may include a fast response area, a regular response area, and an exception handling area with thread priorities decreasing in sequence. The configuration information of the above-mentioned thread pool may also include a first partition reference threshold for dividing the fast response area and the regular response area, a second partition reference threshold for dividing the regular response area and the exception handling area, and an exception handling timeout threshold. The above-mentioned first partition reference threshold can be determined based on the interface time consumption threshold of each interface and the partition thread ratio. The above content can refer to the following. Figure 2 The corresponding description of the optional implementation of step 240 of the embodiment is not repeated here. Generally, when the thread execution time of the called thread is greater than the above exception handling timeout threshold, the thread can be destroyed.
[0089] Optionally, at least one of the first partition reference threshold and the second partition reference threshold can be applied to the optional implementation method of step 740 of dynamically adjusting the thread partition in which the called thread is located according to the thread execution time of the called thread, the interface time consumption threshold of the target interface in the configuration information of the thread pool, and the partition reference threshold of the thread partition, thereby forming a more flexible and reasonable thread dynamic adjustment scheme through the coordination between the above-mentioned interface-independent first partition reference threshold, the second partition reference threshold and the interface time consumption threshold of the interface granularity.
[0090] In some optional implementations of this embodiment, the above configuration information can be Figure 2-Figure 6 The method for generating configuration information of a thread pool disclosed in is generated.
[0091] Figure 8 A schematic diagram showing an example of an application scenario 800 of a task processing method according to an embodiment of this specification is shown.
[0092] like Figure 8As shown, the user can click on the application 1 client 811 through the terminal device 810 to generate various corresponding requests. The network 820 can send the request generated by the application 1 client 811 to the application 1 (for example, it can be a cloud microservice application) server 830. One or more interfaces of application 1 (for example, one or more of the interfaces facade1, facade2, facade3 belonging to the class I interface, and the interfaces facade4, facade5, facade6 belonging to the class II interface) can receive the pending tasks corresponding to the above request. The thread pool 831 of the above application 1 can include multiple thread partitions (for example, the first partition, the second partition, and the third partition) with resource isolation. The thread priorities in the above partitions 1, 2, and 3 can, for example, be reduced in sequence. The configuration information of the above thread pool 831 can include a class I interface threshold configuration table 832 and a class II interface threshold configuration table 833.
[0093] As an example, when a Class I interface (e.g., interface facade2) receives a pending task, a thread created via the interface (e.g., interface facade2) can be called from the first partition of the thread pool 831. Then, the interface can use the called thread to execute the pending task. When the listener finds that the thread execution time of the thread called by the interface exceeds the interface time threshold (e.g., 105ms) of the interface in the configuration information and the pending task has not yet been completed, the thread can be marked as timed out. Afterwards, application 1 can demote the thread marked as timed out to the second partition in various ways. For example, application 1 can directly demote the thread marked as timed out to the second partition. For another example, application 1 can compare the thread execution time of the thread marked as timed out with the partition reference threshold used to divide the first partition and the second partition, and demote the thread marked as timed out to the second partition when the thread execution time exceeds the partition reference threshold.
[0094] As another example, when a Class II interface (e.g., interface facade5) receives a pending task, a thread created via the interface (e.g., interface facade5) can be called from the second partition of the thread pool 831. Then, the interface can use the called thread to execute the pending task. When the listener finds that the thread execution time of the thread called by the interface exceeds the interface time threshold of the interface in the configuration information (e.g., 264ms) and the pending task has not yet been completed, the thread can be marked as timed out. Afterwards, application 1 can downgrade the thread marked as timed out to the third partition in various ways. For example, application 1 can directly downgrade the thread marked as timed out to the third partition.
[0095] use Figure 7-Figure 8The task processing method disclosed in the invention can call a thread created via an interface from a thread partition of a thread pool of a target application that matches the thread priority of the interface that receives the task to be processed, and dynamically adjust the thread partition where the called thread is located according to the thread execution time of the called thread and the interface time threshold of the interface in the configuration information of the thread pool including the identifier of each interface and the corresponding interface time threshold. Compared with the traditional method of using a unified timeout judgment threshold for the thread pool corresponding to the entire application, the interface time threshold at the interface granularity can effectively distinguish the time difference between different interfaces in actual application scenarios, effectively reduce the misjudgment caused by "one size fits all", and thus improve the stability of the online service system.
[0096] In addition, by dividing the thread pool into multiple resource-isolated thread partitions, and each thread partition has a specified thread priority, the corresponding interface can be connected to the matching thread partition to call the corresponding thread, thereby ensuring the stability of the online service system on the basis of improving task processing efficiency.
[0097] Fig. 9 A block diagram of an example of an apparatus 900 for generating configuration information of a thread pool according to an embodiment of the present specification is shown. Figure 2-Figure 6 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0098] like Fig. 9 As shown, the apparatus 900 for generating configuration information of a thread pool may include a time consumption data acquisition unit 910 , an interface threshold determination unit 920 , and a configuration information generation unit 930 .
[0099] The time consumption data acquisition unit 910 is configured to acquire the historical time consumption data of each interface in the interface set of the target application. The operation of the time consumption data acquisition unit 910 can refer to the above reference Figure 2 The operation of 210 is described.
[0100] The interface threshold determination unit 920 is configured to determine the interface time consumption threshold of each interface according to the historical time consumption data of each interface. The interface time consumption threshold of each interface can be used to determine the timeout risk of a thread when being called by the interface. The operation of the interface threshold determination unit 920 can refer to the above reference Figure 2 The operation of 220 is described.
[0101] In an example, the historical time consumption data of each interface may include the sequential time consumption data of the interface within a preset historical period. Fig.10A block diagram of an example of an interface threshold determination unit 920 in an apparatus 900 for generating configuration information of a thread pool according to an embodiment of the present specification is shown. The interface threshold determination unit 920 may include: a data distribution determination module 1010 configured to determine the distribution of time consumption data of each interface based on the historical time consumption data of each interface; a kernel density estimation module 1020 configured to perform kernel density estimation processing on the distribution of time consumption data of each interface to generate a probability density distribution corresponding to the time consumption data of each interface; an interface threshold determination module 1030 configured to determine the interface time consumption threshold of each interface based on the upper confidence limit corresponding to the preset confidence level in the probability density distribution of each interface. The operation of the interface threshold determination unit 920 may refer to the above reference. Figure 3 The operation of the process 300 for determining the interface time threshold of each interface is described.
[0102] In one example, the data distribution determination module 1010 can determine the time consumption data distribution of each interface in the following manner: determine the peak interval set in the time consumption data of each interface; resample the time consumption data in each peak interval in the peak interval set of each interface; and determine the time consumption data distribution of each interface based on the time consumption data of each interface after resampling. The operation of the data distribution determination module 1010 can refer to the above reference Figure 4a The operation of the process 400 for determining the time-consuming data distribution of each interface is described.
[0103] In one example, Fig.11 A block diagram of an example of an interface threshold determination module 1030 in an apparatus 900 for generating configuration information of a thread pool according to an embodiment of the present specification is shown. The interface threshold determination module 1030 may include: a time period threshold determination submodule 1110 is configured to determine the time period consumption threshold of each interface within a preset historical time period according to an upper confidence limit corresponding to a preset confidence level in the probability density distribution of each interface; a time period threshold selection submodule 1120 is configured to select a target number of time period consumption thresholds associated with a preset historical time period corresponding to a preset time interval from the pre-stored time period consumption thresholds of each interface; an interface threshold determination submodule 1130 is configured to determine, for each interface, the interface time consumption threshold of the interface according to the selected target number of time period consumption thresholds and the determined time period consumption threshold. The operation of the interface threshold determination module 1030 may refer to the above reference. Figure 5 The operation of the process 500 for determining the interface time threshold of each interface is described.
[0104] In one example, the interface threshold determination submodule 1130 can determine the interface time consumption threshold of each interface in the following manner: for each interface, the selected target number of time consumption thresholds and the determined time consumption threshold are subjected to noise reduction processing according to the preset noise reduction condition to generate a noise reduction time consumption threshold set for the interface; for each interface, the interface time consumption threshold of the interface is determined according to the noise reduction time consumption threshold set. The operation of the interface threshold determination submodule 1130 can refer to the above reference Figure 6 The operation of the process 600 for determining the interface time threshold of each interface is described.
[0105] In one example, the interface threshold determination module 1030 can determine the interface time threshold of each interface in the following manner: for each interface, the larger value of the confidence upper limit corresponding to the preset confidence level and the preset bottom threshold in the probability density distribution corresponding to the interface is determined as the interface time threshold of the interface. The operation of the interface threshold determination module 1030 can refer to the above reference Figure 3 The operations in the optional implementation manner of the process 300 for determining the interface time consumption threshold of each interface are described.
[0106] Back to Fig. 9 The configuration information generating unit 930 may be configured to generate configuration information of a thread pool corresponding to the target application according to the interface time consumption threshold of each interface. The thread pool may include threads created via each interface. The configuration information may include the identifier of each interface and the corresponding interface time consumption threshold. The operation of the configuration information generating unit 930 may refer to the above reference. Figure 2 The operation of step 230 is described.
[0107] In one example, the thread pool may include multiple thread partitions with resource isolation. Each thread partition may have a specified thread priority, and the threads in each thread partition may be available for interface calls with corresponding thread priority. The device 900 for generating configuration information of the thread pool may also include: a configuration information sending unit (not shown in the figure), which is configured to send the generated configuration information of the thread pool to the target application, so that when the target application calls the thread in the thread pool via the interface to execute a task, the thread partition where the called thread is located is dynamically adjusted according to the thread execution time of the called thread and the interface time threshold of the interface in the configuration information. The operation of the configuration information sending unit can refer to the above reference. Figure 2 The operation of step 240 is described.
[0108] In one example, the configuration information sending unit can be further configured to: send the generated thread pool configuration information to the target application, so that when the target application calls the thread in the thread pool via the interface to execute a task, the thread partition where the called thread is located is dynamically adjusted according to the thread execution time of the called thread, the interface time threshold of the interface in the configuration information, and the partition reference threshold of the thread partition. The operation of the configuration information sending unit can refer to the above reference Figure 2 The corresponding operations of the optional implementation of step 240 are described.
[0109] In one example, the above-mentioned multiple thread partitions may include a fast response area, a regular response area, and an exception handling area with thread priorities decreasing in sequence. The configuration information may also include a first partition reference threshold for dividing the fast response area and the regular response area, a second partition reference threshold for dividing the regular response area and the exception handling area, and an exception handling timeout threshold. The above-mentioned first partition reference threshold may be determined based on the interface time consumption threshold of each interface and the partition thread ratio. The specific description in the above example can be referred to the reference above. Figure 2 The corresponding description in the optional implementation of step 240 described.
[0110] Fig.12 FIG. 1 is a block diagram showing an example of a task processing device 1200 according to an embodiment of the present specification. Figure 7-Figure 8 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0111] like Fig.12 As shown, the task processing device 1200 includes a task receiving unit 1210 , a thread calling unit 1220 , a task executing unit 1230 and a thread adjusting unit 1240 .
[0112] The task receiving unit 1210 is configured to receive a task to be processed via a target interface of a target application. The operation of the task receiving unit 1210 may refer to the above reference. Figure 7 The operation of 710 is described.
[0113] The thread calling unit 1220 is configured to call a thread created via the target interface from a thread partition of the thread pool of the target application that matches the thread priority of the target interface. The thread pool may include multiple thread partitions with resource isolation. Each thread partition may have a specified thread priority. The operation of the thread calling unit 1220 may refer to the above reference. Figure 7 The operation of 720 is described.
[0114] The task execution unit 1230 is configured to execute the pending task using the called thread. The operation of the task execution unit 1230 can refer to the above reference Figure 7 The operation of 730 is described.
[0115] The thread adjustment unit 1240 is configured to dynamically adjust the thread partition where the called thread is located according to the thread execution time of the called thread and the interface time consumption threshold of the target interface in the configuration information of the thread pool. The configuration information of the thread pool may include the identifier of each interface and the corresponding interface time consumption threshold. The interface time consumption threshold of each interface may be determined based on the historical time consumption data of each interface. The operation of the thread adjustment unit 1240 may refer to the above reference. Figure 7 The operation of 740 is described.
[0116] In one example, the thread adjustment unit 1240 can dynamically adjust the thread partition of the called thread in the following manner: dynamically adjust the thread partition of the called thread according to the thread execution time of the called thread, the interface time consumption threshold of the target interface in the configuration information of the thread pool, and the partition reference threshold of the thread partition. The operation of the thread adjustment unit 1240 can refer to the above reference. Figure 7 The operation of the optional implementation in the dynamic adjustment process 740 of the thread partition where the called thread is located is described.
[0117] In one example, the above-mentioned multiple thread partitions may include a fast response area, a regular response area, and an exception handling area with thread priorities decreasing in sequence. The configuration information may also include a first partition reference threshold for dividing the fast response area and the regular response area, a second partition reference threshold for dividing the regular response area and the exception handling area, and an exception handling timeout threshold. The above-mentioned first partition reference threshold may be determined based on the interface time consumption threshold of each interface and the partition thread ratio. The specific description in the above example can be referred to the reference above. Figure 2 The corresponding description in the optional implementation of step 240 described.
[0118] In one example, the configuration information is as follows: Figure 2-Figure 6 The method for generating configuration information of a thread pool disclosed in is generated.
[0119] Reference above Figures 1 to 12 , describes an embodiment of a method and device for generating configuration information of a thread pool, and a task processing method and device according to an embodiment of this specification.
[0120] The device for generating the configuration information of the thread pool and the task processing device of the embodiment of this specification can be implemented by hardware, or by software or a combination of hardware and software. Taking software implementation as an example, as a device in a logical sense, it is formed by the processor of the device in which it is located reading the corresponding computer program instructions in the memory into the memory and running them. In the embodiment of this specification, the device for generating the configuration information of the thread pool and the task processing device can be implemented, for example, using electronic equipment.
[0121] Fig.13 A schematic diagram of an apparatus 1300 for generating configuration information of a thread pool according to an embodiment of the present specification is shown.
[0122] like Fig.13 As shown, the apparatus 1300 for generating configuration information of a thread pool may include at least one processor 1310, a memory (e.g., a non-volatile memory) 1320, a memory 1330, and a communication interface 1340, and the at least one processor 1310, the memory 1320, the memory 1330, and the communication interface 1340 are connected together via a bus 1350. At least one processor 1310 executes at least one computer-readable instruction stored or encoded in the memory (i.e., the above-mentioned element implemented in the form of software).
[0123] In one embodiment, computer executable instructions are stored in a memory, which, when executed, cause at least one processor 1310 to: obtain historical time consumption data of each interface in an interface set of a target application; determine an interface time consumption threshold of each interface based on the historical time consumption data of each interface, wherein the interface time consumption threshold of each interface is used to determine the timeout risk of a thread when the thread is called by the interface; and generate configuration information of a thread pool corresponding to the target application based on the interface time consumption threshold of each interface, wherein the thread pool includes threads created via each interface, and the configuration information includes an identifier of each interface and a corresponding interface time consumption threshold.
[0124] It should be understood that the computer executable instructions stored in the memory, when executed, cause at least one processor 1310 to perform the above combined operations in various embodiments of the present specification. Figure 2-Figure 6 Describes the various operations and functions.
[0125] According to one embodiment, a program product such as a computer-readable medium is provided. The computer-readable medium may have instructions (i.e., the above-mentioned elements implemented in the form of software), which, when executed by a computer, causes the computer to perform the above-mentioned combination of various embodiments of this specification. Figure 2-Figure 6 Describes the various operations and functions.
[0126] Fig.14 A schematic diagram of a task processing device 1400 according to an embodiment of the present specification is shown.
[0127] like Fig.14 As shown, the task processing device 1400 may include at least one processor 1410, a memory (e.g., a non-volatile memory) 1420, a memory 1430, and a communication interface 1440, and the at least one processor 1410, the memory 1420, the memory 1430, and the communication interface 1440 are connected together via a bus 1450. At least one processor 1410 executes at least one computer-readable instruction stored or encoded in the memory (i.e., the above-mentioned element implemented in the form of software).
[0128] In one embodiment, computer executable instructions are stored in a memory, which, when executed, cause at least one processor 1410 to: receive a task to be processed via a target interface of a target application; call a thread created via the target interface from a thread partition of a thread pool of the target application that matches the thread priority of the target interface, the thread pool comprising a plurality of resource-isolated thread partitions, each thread partition having a specified thread priority; execute the task to be processed using the called thread; and dynamically adjust the thread partition in which the called thread is located based on the thread execution time of the called thread and the interface time consumption threshold of the target interface in the configuration information of the thread pool, the configuration information of the thread pool comprising the identifier of each interface and the corresponding interface time consumption threshold, the interface time consumption threshold of each interface being determined based on the historical time consumption data of each interface.
[0129] It should be understood that the computer executable instructions stored in the memory, when executed, cause at least one processor 1410 to perform the above combined operations in various embodiments of the present specification. Figure 7-Figure 8 Describes the various operations and functions.
[0130] According to one embodiment, a program product such as a computer-readable medium is provided. The computer-readable medium may have instructions (i.e., the above-mentioned elements implemented in the form of software), which, when executed by a computer, causes the computer to perform the above-mentioned combination of various embodiments of this specification. Figure 7-Figure 8 Describes the various operations and functions.
[0131] Specifically, a system or device equipped with a readable storage medium can be provided, on which software program codes that implement the functions of any of the above-mentioned embodiments are stored, and a computer or processor of the system or device can read and execute instructions stored in the readable storage medium.
[0132] In this case, the program code itself read from the machine-readable medium can realize the function of any one of the above-mentioned embodiments, and thus the machine-readable code and the machine-readable storage medium storing the machine-readable code constitute a part of the present invention.
[0133] The computer program code required for the operation of each part of this specification can be written in any one or more programming languages, including object-oriented programming languages, such as Java, Scala, Smalltalk, Eiffel, JADE, Emerald, C++, C#, VB, NET and Python, conventional procedural programming languages such as C language, Visual Basic 2003, Perl, COBOL 2002, PHP and ABAP, dynamic programming languages such as Python, Ruby and Groovy, or other programming languages. The program code can be run on the user's computer, or run on the user's computer as an independent software package, or run partly on the user's computer and another part on the remote computer, or all on the remote computer or server. In the latter case, the remote computer can be connected to the user's computer through any network form, such as a local area network (LAN) or a wide area network (WAN), or connected to an external computer (e.g., via the Internet), or in a cloud computing environment, or used as a service, such as software as a service (SaaS).
[0134] Examples of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, the program code may be downloaded from a server computer or a cloud via a communication network.
[0135] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0136] Not all steps and units in the above-mentioned processes and system structure diagrams are necessary, and some steps or units can be ignored according to actual needs. The execution order of each step is not fixed and can be determined according to needs. The device structure described in the above-mentioned embodiments can be a physical structure or a logical structure, that is, some units may be implemented by the same physical entity, or some units may be implemented by multiple physical entities, or some components in multiple independent devices may be implemented together.
[0137] The term "exemplary" as used throughout this specification means "serving as an example, instance, or illustration" and does not imply "preferred" or "advantageous" over other embodiments. The detailed description includes specific details for the purpose of providing an understanding of the described techniques. However, the techniques may be implemented without these specific details. In some instances, in order to avoid obscuring the concepts of the described embodiments, well-known structures and devices are shown in block diagram form.
[0138] The optional implementation modes of the embodiments of the present specification are described in detail above in conjunction with the accompanying drawings. However, the embodiments of the present specification are not limited to the specific details in the above implementation modes. Within the technical concept of the embodiments of the present specification, various simple modifications can be made to the technical solutions of the embodiments of the present specification, and these simple modifications all belong to the protection scope of the embodiments of the present specification.
[0139] The above description of the contents of this specification is provided to enable any person of ordinary skill in the art to implement or use the contents of this specification. Various modifications to the contents of this specification will be apparent to those of ordinary skill in the art, and the general principles defined herein may be applied to other variations without departing from the scope of protection of the contents of this specification. Therefore, the contents of this specification are not limited to the examples and designs described herein, but are consistent with the widest range of principles and novel features disclosed herein.
Claims
1. A method for generating configuration information of a thread pool, comprising: Obtaining historical time consumption data of each interface in the interface set of the target application, wherein the historical time consumption data of each interface includes the time series time consumption data of the interface within a preset historical period; Determine the interface time consumption threshold of each interface based on the historical time consumption data of each interface. The interface time consumption threshold of each interface is used to determine the timeout risk of the thread when being called by the interface. as well as Generate configuration information of a thread pool corresponding to the target application according to the interface time consumption threshold of each interface, wherein the thread pool includes threads created via each interface, and the configuration information includes an identifier of each interface and a corresponding interface time consumption threshold; Determining the interface time consumption threshold of each interface according to the historical time consumption data of each interface includes: Determine the distribution of time consumption data of each interface based on the historical time consumption data of each interface; Performing kernel density estimation processing on the time consumption data distribution of each interface to generate a probability density distribution corresponding to the time consumption data of each interface; and Determine the interface time consumption threshold of each interface according to the confidence upper limit corresponding to the preset confidence level in the probability density distribution of each interface; Determining the distribution of time consumption data of each interface according to the historical time consumption data of each interface includes: Determine the peak interval set in the timing consumption data of each interface; Resampling the time consumption data in each peak interval of the peak interval set of each interface by using a random sampling method; and According to the resampled time consumption data of each interface, the time consumption data distribution of each interface is determined.
2. The method of claim 1, wherein: Determining the interface time consumption threshold of each interface according to the confidence upper limit corresponding to the preset confidence level in the probability density distribution of each interface includes: Determine, according to the confidence upper limit corresponding to the preset confidence level in the probability density distribution of each interface, the time consumption threshold of each interface within the preset historical period; Selecting a target number of time-consuming thresholds of time periods corresponding to the preset time intervals and associated with the preset historical time periods from the pre-stored time-consuming thresholds of time periods of each interface; For each interface, the interface time consumption threshold of the interface is determined according to the selected target number of time consumption thresholds for the time period and the determined time consumption threshold for the time period.
3. The method of claim 2, wherein: For each interface, determining the interface time consumption threshold of the interface according to the selected target number of time consumption thresholds of the time period and the determined time consumption threshold of the time period includes: For each interface, a noise reduction process is performed on the selected target number of time-consuming thresholds and the determined time-consuming thresholds according to a preset noise reduction condition, so as to generate a noise-reduced time-consuming threshold set for the interface; For each interface, the interface time consumption threshold of the interface is determined according to the time consumption threshold set after noise reduction.
4. The method of claim 1, wherein: Determining the interface time consumption threshold of each interface according to the confidence upper limit corresponding to the preset confidence level in the probability density distribution of each interface includes: For each interface, a larger value of an upper confidence limit corresponding to a preset confidence level and a preset bottom threshold in a probability density distribution corresponding to the interface is determined as an interface time consumption threshold of the interface.
5. The method according to any one of claims 1 to 4, wherein: The thread pool includes a plurality of resource-isolated thread partitions, each thread partition has a specified thread priority, and threads in each thread partition are available for interface calls with corresponding thread priority; as well as The method further comprises: The generated thread pool configuration information is sent to the target application, so that when the target application calls a thread in the thread pool via an interface to execute a task, the thread partition where the called thread is located is dynamically adjusted according to the thread execution time of the called thread and the interface time consumption threshold of the interface in the configuration information.
6. The method of claim 5, wherein: The dynamically adjusting the thread partition where the called thread is located according to the thread execution time of the called thread and the interface time consumption threshold of the interface in the configuration information comprises: The thread partition where the called thread is located is dynamically adjusted according to the thread execution time of the called thread, the interface time consumption threshold of the interface in the configuration information, and the partition reference threshold of the thread partition.
7. The method of claim 6, wherein: The multiple thread partitions include a fast response area, a regular response area, and an exception handling area with thread priorities decreasing in sequence. The configuration information also includes a first partition reference threshold for dividing the fast response area and the regular response area, a second partition reference threshold for dividing the regular response area and the exception handling area, and an exception handling timeout threshold. The first partition reference threshold is determined based on the interface time consumption threshold of each interface and the partition thread ratio.
8. A task processing method, comprising: Receiving a task to be processed via a target interface of a target application; Invoke a thread created via the target interface from a thread partition of a thread pool of the target application that matches the thread priority of the target interface, wherein the thread pool includes a plurality of resource-isolated thread partitions, each of which has a specified thread priority; Utilize the called thread to execute the pending task; as well as The thread partition where the called thread is located is dynamically adjusted according to the thread execution time of the called thread and the interface time consumption threshold of the target interface in the configuration information of the thread pool. The configuration information of the thread pool includes the identification of each interface and the corresponding interface time consumption threshold. The interface time consumption threshold of each interface is determined based on the historical time consumption data of each interface. The configuration information is generated according to the method described in any one of claims 1 to 7.
9. The task processing method according to claim 8, wherein: The dynamically adjusting the thread partition where the called thread is located according to the thread execution time of the called thread and the interface time consumption threshold of the target interface in the configuration information of the thread pool includes: The thread partition where the called thread is located is dynamically adjusted according to the thread execution time of the called thread, the interface time consumption threshold of the target interface in the configuration information of the thread pool, and the partition reference threshold of the thread partition.
10. The method of claim 9, wherein: The multiple thread partitions include a quick response area, a regular response area, and an exception handling area with thread priorities decreasing in sequence. The configuration information of the thread pool also includes a first partition reference threshold for dividing the quick response area and the regular response area, a second partition reference threshold for dividing the regular response area and the exception handling area, and an exception handling timeout threshold. The first partition reference threshold is determined based on the interface time consumption threshold of each interface and the partition thread ratio.
11. A device for generating configuration information of a thread pool, comprising: A time consumption data acquisition unit is configured to acquire historical time consumption data of each interface in the interface set of the target application, wherein the historical time consumption data of each interface includes the time series time consumption data of the interface within a preset historical period; An interface threshold determination unit is configured to determine an interface time consumption threshold of each interface according to historical time consumption data of each interface, wherein the interface time consumption threshold of each interface is used to determine a timeout risk of a thread when being called by the interface; as well as A configuration information generating unit, configured to generate configuration information of a thread pool corresponding to the target application according to an interface time consumption threshold of each interface, wherein the thread pool includes threads created via each interface, and the configuration information includes an identifier of each interface and a corresponding interface time consumption threshold; The interface threshold determination unit comprises: The data distribution determination module is configured to determine the time consumption data distribution of each interface according to the historical time consumption data of each interface; A kernel density estimation module is configured to perform kernel density estimation processing on the time consumption data distribution of each interface to generate a probability density distribution corresponding to the time consumption data of each interface; and An interface threshold determination module is configured to determine an interface time consumption threshold of each interface according to a confidence upper limit corresponding to a preset confidence level in a probability density distribution of each interface; The data distribution determination module is further configured to: Determine the peak interval set in the timing consumption data of each interface; Resampling the time consumption data in each peak interval of the peak interval set of each interface by using a random sampling method; and According to the resampled time consumption data of each interface, the time consumption data distribution of each interface is determined.
12. The device of claim 11, wherein: The interface threshold determination module includes: The time period threshold determination submodule is configured to determine the time period consumption threshold of each interface within the preset historical time period according to the confidence upper limit corresponding to the preset confidence level in the probability density distribution of each interface; a time period threshold selection submodule, configured to select a target number of time period consuming thresholds corresponding to a preset time interval and associated with the preset historical time period from the pre-stored time period consuming thresholds of each interface; and The interface threshold determination submodule is configured to determine, for each interface, an interface time consumption threshold of the interface according to the selected target number of time consumption thresholds for the time period and the determined time consumption threshold for the time period.
13. The device of claim 12, wherein: The interface threshold determination submodule is further configured as follows: For each interface, a noise reduction process is performed on the selected target number of time-consuming thresholds and the determined time-consuming thresholds according to a preset noise reduction condition, so as to generate a noise-reduced time-consuming threshold set for the interface; as well as For each interface, the interface time consumption threshold of the interface is determined according to the time consumption threshold set after noise reduction.
14. The device of claim 11, wherein: The interface threshold determination module is further configured to: For each interface, a larger value of an upper confidence limit corresponding to a preset confidence level and a preset bottom threshold in a probability density distribution corresponding to the interface is determined as an interface time consumption threshold of the interface.
15. The device according to any one of claims 11 to 14, wherein: The thread pool includes a plurality of resource-isolated thread partitions, each thread partition has a specified thread priority, and threads in each thread partition are available for interface calls with corresponding thread priority; as well as The device also includes: The configuration information sending unit is configured to send the configuration information of the generated thread pool to the target application so that when the target application calls a thread in the thread pool via an interface to execute a task, the thread partition where the called thread is located is dynamically adjusted according to the thread execution time of the called thread and the interface time consumption threshold of the interface in the configuration information.
16. A task processing device, comprising: A task receiving unit, configured to receive a to-be-processed task via a target interface of a target application; A thread calling unit, configured to call a thread created via the target interface from a thread partition of a thread pool of the target application that matches the thread priority of the target interface, wherein the thread pool includes a plurality of resource-isolated thread partitions, each thread partition having a specified thread priority; A task execution unit, configured to execute the to-be-processed task using the called thread; A thread adjustment unit is configured to dynamically adjust the thread partition where the called thread is located according to the thread execution time of the called thread and the interface time consumption threshold of the target interface in the configuration information of the thread pool, wherein the configuration information of the thread pool includes the identifier of each interface and the corresponding interface time consumption threshold, the interface time consumption threshold of each interface is determined based on the historical time consumption data of each interface, and the configuration information is generated according to any one of the methods described in claims 1 to 7.
17. The device of claim 16, wherein: The thread adjustment unit is further configured to: The thread partition where the called thread is located is dynamically adjusted according to the thread execution time of the called thread, the interface time consumption threshold of the target interface in the configuration information of the thread pool, and the partition reference threshold of the thread partition.
18. The device of claim 17, wherein: The multiple thread partitions include a quick response area, a regular response area, and an exception handling area with thread priorities decreasing in sequence. The configuration information of the thread pool also includes a first partition reference threshold for dividing the quick response area and the regular response area, a second partition reference threshold for dividing the regular response area and the exception handling area, and an exception handling timeout threshold. The first partition reference threshold is determined based on the interface time consumption threshold of each interface and the partition thread ratio.
19. A device for generating configuration information of a thread pool, comprising: At least one processor, a memory coupled to the at least one processor, and a computer program stored on the memory, wherein the at least one processor executes the computer program to implement the method according to any one of claims 1 to 7.
20. A task processing device, comprising: At least one processor, a memory coupled to the at least one processor, and a computer program stored on the memory, wherein the at least one processor executes the computer program to implement the method according to any one of claims 8 to 10.
21. A computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the computer program implements the method according to any one of claims 1 to 7 or executes the method according to any one of claims 8 to 10.
22. A computer program product, comprising a computer program, wherein the computer program is executed by a processor to implement the method according to any one of claims 1 to 7 or to perform the method according to any one of claims 8 to 10.
Citation Information
Patent Citations
Method, apparatus, server and data processing method for determining timeout duration
CN109144700A
A method and a terminal for dynamically scheduling a thread pool
CN109814994A
Task processing method and device and computer system
CN111104210A
Performance test result analysis method and device
CN112527622A
System optimization method and device for unmanned equipment
CN113759790A
