Task processing method and device, electronic equipment and storage medium

By obtaining the task and thread information of the thread pool in the current time window and adjusting the thread pool parameters, the performance degradation and system crash caused by improper configuration of the thread pool parameters is solved, and adaptive task processing is achieved.

CN119473619APending Publication Date: 2025-02-18AGRICULTURAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411687004.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-22
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

In the prior art, improper configuration of thread pool parameters may lead to degradation of thread pool performance or system crash, especially in the process of task processing, it is difficult to adapt to business scenario changes.

Method used

By obtaining the task information and thread information of the thread pool in the current time window, determining the information identification, and adjusting the parameters of the thread pool based on this information, so as to achieve automatic adjustment according to specific business scenarios.

Benefits of technology

Adaptive adjustment of thread pool parameters is realized, the performance and stability of task processing is improved, and the risk of system crash is avoided.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473619A_ABST
    Figure CN119473619A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a task processing method and device, electronic equipment and a storage medium. The method comprises the steps of obtaining task information and thread information of a thread pool in each first bucket in a current first time window; determining an information identifier of the current first time window, the information identifier being obtained based on a thread pool parameter adjustment operation of the thread pool; and adjusting a first parameter of the thread pool based on the information identifier and the task information and the thread information in each first bucket, and performing task processing according to the adjusted thread pool parameter. According to the technical scheme, the technical problem that task processing in related technologies is poor in self-adaptability is solved, and the task is processed by automatically adjusting the thread pool parameters according to the specific service scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of computer technology, and in particular to a task processing method, device, electronic device and storage medium. Background Art

[0002] In the related art, using a thread pool to process tasks usually relies on pre-set thread pool parameters. Once the thread pool parameters are improperly configured, the performance of the thread pool may be degraded, or even cause the system to crash. For example, if the number of core threads is set too small, tasks may not be processed in a timely manner; if the maximum number of threads is set too large, excessive consumption of system resources and competition between threads may occur. Therefore, a task processing method is provided to automatically adjust the thread pool parameters to process tasks according to specific business scenarios. Summary of the invention

[0003] The present invention provides a task processing method, device, electronic device and storage medium to realize automatic adjustment of thread pool parameters to process tasks according to specific business scenarios.

[0004] According to one aspect of the present invention, a task processing method is provided, the method comprising:

[0005] Get the task information and thread information of each first bucket in the thread pool in the current first time window;

[0006] Determine an information identifier of the current first time window, wherein the information identifier is obtained based on a thread pool parameter adjustment operation of the thread pool;

[0007] Based on the information identifier and the task information and thread information in each of the first buckets, the first parameter of the thread pool is adjusted, and task processing is performed according to the adjusted thread pool parameter.

[0008] According to another aspect of the present invention, a task processing device is provided. The device comprises:

[0009] A bucket information acquisition module is used to obtain task information and thread information in each first bucket of the thread pool in the current first time window;

[0010] An identification determination module, used to determine the information identification of the current first time window, wherein the information identification is obtained based on a thread pool parameter adjustment operation of the thread pool;

[0011] The task processing module is used to adjust the first parameter of the thread pool based on the information identifier and the task information and thread information in each of the first buckets, and perform task processing according to the adjusted thread pool parameter.

[0012] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0013] at least one processor; and

[0014] a memory communicatively connected to the at least one processor; wherein,

[0015] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the task processing method described in any embodiment of the present invention.

[0016] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the task processing method described in any embodiment of the present invention when executed.

[0017] The technical solution of the embodiment of the present invention obtains the task information and thread information in each first bucket of the thread pool in the current first time window; determines the information identifier of the current first time window, wherein the information identifier is obtained based on the thread pool parameter adjustment operation of the thread pool; adjusts the first parameter of the thread pool based on the information identifier and the task information and thread information in each first bucket, and performs task processing according to the adjusted thread pool parameter. The technical solution of the embodiment of the present invention solves the technical problem of poor adaptive performance in task processing of related technologies, and realizes automatic adjustment of thread pool parameters to process tasks according to specific business scenarios.

[0018] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0020] Figure 1 A flowchart of a task processing method provided by an embodiment of the present invention;

[0021] Figure 2 A flowchart of a task processing method provided by an embodiment of the present invention;

[0022] Figure 3 A schematic diagram of the structure of a task processing device provided by an embodiment of the present invention;

[0023] Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0024] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0026] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.

[0027] Figure 1 A flow chart of a task processing method provided for an embodiment of the present invention. This embodiment is applicable to the situation where a thread pool is used to process tasks. The method can be executed by a task processing device. The task processing device can be implemented in the form of hardware and / or software. The task processing device can be configured in an electronic device such as a computer or a server.

[0028] like Figure 1 As shown, the method of this embodiment includes:

[0029] S110. Obtain task information and thread information in each first bucket of the thread pool in the current first time window.

[0030] In an embodiment of the present invention, the current first time window can be understood as a time range of the first preset duration from the current moment. The first preset duration can be preset according to actual needs, such as 10 seconds. In an embodiment of the present invention, the current first time window may include multiple continuous first buckets. The first bucket of the current first time window can be understood as a time slice within the current first time window. Exemplarily, the first preset duration can be 10S, and the length of the current first time window is 10S. When the current moment is 9:10:20, the current first time window can be a time period with the current moment as the end point and 10S away from the current moment, that is, 9:10:10 to 9:10:20. The first bucket can be every second in the time period from 9:10:10 to 9:10:20.

[0031] Among them, the task information may include a task identifier and a task execution state corresponding to the task identifier. Among them, the task identifier may be used to distinguish different tasks in the thread pool. The task execution state may include a waiting state, an executing state, and a completed state. The thread information may include the usage of threads in the thread pool. For example, a thread identifier and a thread state corresponding to the thread identifier. The thread identifier may be used to distinguish different threads. The thread state may include an idle state and a non-idle state. In other words, the threads in the thread pool may include idle threads and non-idle threads.

[0032] Specifically, the task information and thread information of the thread pool in the first preset time period from the current moment can be obtained first, and then the task information and thread information of the thread pool in each time slice in the first preset time period from the current moment can be determined.

[0033] S120. Determine an information identifier of the current first time window, wherein the information identifier is obtained based on a thread pool parameter adjustment operation of the thread pool.

[0034] Wherein, the information identification is obtained based on the thread pool parameter adjustment operation of the thread pool. In an embodiment of the present invention, the thread pool parameters may include at least the number of core threads, the maximum number of threads, and the queue capacity. Wherein, the number of core threads can be understood as the number of threads that exist for a long time and will not be destroyed even in an idle state. The maximum number of threads can be understood as the maximum number of threads allowed to be created. It can be understood that the threads in the thread pool that exceed the number of core threads and are less than or equal to the maximum number of threads are non-core threads. In an idle state, non-core threads can be gradually destroyed in a short time and release occupied resources. The queue capacity can be understood as the maximum length allowed for task queuing. Wherein, the thread pool parameter adjustment operation may include at least one of the operations of increasing the queue capacity, reducing the queue capacity, increasing the maximum number of threads, reducing the maximum number of threads, increasing the number of core threads, and reducing the number of core threads.

[0035] Specifically, a storage space for storing the information identifier of the current first time window may be determined first, and then the information identifier of the current first time window may be read from the storage space to obtain the information identifier of the current first time window.

[0036] S130. Based on the information identifier and the task information and thread information in each of the first buckets, adjust the first parameter of the thread pool, and perform task processing according to the adjusted thread pool parameter.

[0037] In an embodiment of the present invention, adjusting the first parameter of the thread pool based on the information identifier and the task information and thread information in each of the first buckets may include: determining the amount of rejected tasks in the first bucket based on the task information and thread information in the first bucket; and adjusting the first parameter of the thread pool based on the amount of rejected tasks in each of the first buckets and the information identifier.

[0038] The rejected task amount can be understood as the task amount that the thread pool refuses to process in the first bucket. The first parameter of the thread pool can be understood as a thread pool parameter that can be adjusted based on the rejected task amount of each first bucket and the information identifier. The first parameter can include a maximum number of threads and / or a queue capacity.

[0039] In the embodiment of the present invention, there are multiple ways to determine the amount of rejected tasks in the first bucket based on the task information and thread information in the first bucket. As an optional implementation in the embodiment of the present invention, the total amount of tasks currently waiting to be processed in the first bucket and the number of threads currently idle and available for processing tasks in the first bucket can be determined based on the task information and thread information in the first bucket. Thus, the amount of rejected tasks in the first bucket is obtained based on the total amount of tasks currently waiting to be processed in the first bucket and the number of threads currently idle and available for processing tasks in the first bucket.

[0040] As another optional implementation in the embodiment of the present invention, the number of threads in the first bucket can be obtained based on the thread information in the first bucket. Then, the number of tasks that the first bucket can process in the current state can be determined based on the number of threads in the first bucket and the resource usage of the threads. Thus, the amount of rejected tasks in the first bucket can be determined based on the total amount of tasks in the task information and the number of tasks that the first bucket can process in the current state.

[0041] Optionally, adjusting the first parameter of the thread pool based on the amount of rejected tasks in each of the first buckets and the information identifier may include: determining a first quantity ratio of the first bucket in which the amount of rejected tasks is greater than zero; and then adjusting the first parameter of the thread pool based on the first quantity ratio, a first ratio threshold and the information identifier.

[0042] Among them, the first quantity ratio can be calculated based on the number of buckets of the first bucket whose rejection task volume is greater than zero and the total number of buckets of all first buckets in the first time window. In an embodiment of the present invention, the first quantity ratio of the first bucket whose rejection task volume is greater than zero is determined. Specifically, the number of buckets of the first bucket whose rejection task volume is greater than zero can be determined first; then, the number of buckets of the first bucket whose rejection task volume is greater than zero and the total number of buckets of all first buckets in the first time window can be calculated as a ratio. Thus, a ratio calculation result can be obtained, that is, the first quantity ratio of the first bucket whose rejection task volume is greater than zero is determined. The first ratio threshold can be a ratio threshold pre-set according to actual needs, for example, 45%, 50% or 55%, etc.

[0043] As an optional implementation of an embodiment of the present invention, the adjustment of the first parameter of the thread pool based on the first quantity proportion, the first proportion threshold and the information identifier may include: when the first quantity proportion exceeds the first proportion threshold and the information identifier is empty, the queue capacity of the thread pool may be increased, and based on the operation of increasing the queue capacity of the thread pool, the information identifier is updated to determine the specific operation on the thread pool parameter within the previous time window based on the updated information identifier.

[0044] Based on the above embodiment, the queue capacity of the thread pool may be increased by the average amount of rejected tasks of the first bucket in the current first time window. A specific method for obtaining the average amount of rejected tasks may be to first obtain the total amount of rejected tasks of all first buckets in the first time window. Afterwards, the total amount of rejected tasks may be divided by the total amount of buckets of the first bucket in the first time window to obtain a division result, that is, the average amount of rejected tasks.

[0045] As an optional implementation of an embodiment of the present invention, the adjustment of the first parameter of the thread pool based on the first quantity proportion, the first proportion threshold and the information identifier may include: when the first quantity proportion exceeds the first proportion threshold and the information identifier is the first identifier, the maximum number of threads in the thread pool may be increased, and the information identifier may be updated based on the operation of increasing the maximum number of threads in the thread pool. The first identifier may be obtained based on the operation of increasing the queue capacity of the thread pool. Furthermore, the average amount of rejected tasks in the first bucket within the current first time window may be increased based on the maximum number of threads in the thread pool.

[0046] As an optional implementation of an embodiment of the present invention, the adjustment of the first parameter of the thread pool based on the first quantity proportion, the first proportion threshold and the information identifier may include: when the first quantity proportion exceeds the first proportion threshold and the information identifier is the second identifier, increasing the maximum number of threads and queue capacity of the thread pool. Wherein, the second identifier is obtained based on the operation of increasing the maximum number of threads of the thread pool. Further, increasing the maximum number of threads and queue capacity of the thread pool may specifically be increasing the queue capacity of the thread pool by the average amount of rejected tasks of the first bucket in the current first time window, and increasing the average amount of rejected tasks of the first bucket in the current first time window based on the maximum number of threads of the thread pool.

[0047] On the basis of the above embodiment, by repeatedly adjusting the maximum number of threads and the queue capacity of the thread pool until the maximum number of threads reaches the preset upper limit of the maximum number of threads and the queue capacity reaches the preset upper limit of the queue capacity, it is possible to effectively cope with traffic peaks, and by rapidly increasing the capacity queue and adding threads to cope with a large number of task submissions, avoid large-scale task rejections, and thus improve task processing efficiency.

[0048] On the basis of the above embodiment, after the traffic peak, the number of tasks that need to be processed decreases accordingly, the non-core threads in the thread pool will be automatically destroyed after a short period of time, and the number of tasks queued in the queue will gradually decrease. At this time, the maximum number of threads surviving in the first bucket within the first time window can be determined. The maximum number of threads in the first time window can then be adjusted to the maximum number of surviving threads. In an embodiment of the present invention, the maximum number of threads cannot be lower than the initial value set by the system. Afterwards, the maximum number of tasks queued in the first bucket within the first time window can be determined. The queue capacity can then be adjusted to the maximum number of queued tasks. It should be noted that the queue capacity cannot be less than the initial queue capacity. After the first parameter adjustment is completed, the information identifier of the first time window can be cleared.

[0049] The technical solution of the embodiment of the present invention obtains the task information and thread information in each first bucket of the thread pool in the current first time window; determines the information identifier of the current first time window, wherein the information identifier is obtained based on the thread pool parameter adjustment operation of the thread pool; adjusts the first parameter of the thread pool based on the information identifier and the task information and thread information in each first bucket, and performs task processing according to the adjusted thread pool parameter. The technical solution of the embodiment of the present invention solves the technical problem of poor adaptive performance in task processing of related technologies, and realizes automatic adjustment of thread pool parameters to process tasks according to specific business scenarios.

[0050] Figure 2 A flowchart of a task processing method provided by an embodiment of the present invention, based on the above embodiment, optionally, the task processing method implemented by the present invention further includes: obtaining task information and thread information in each second bucket in the current second time window, wherein the current first time window is smaller than the current second time window; adjusting the second parameter of the thread pool based on the task information and thread information in the second bucket, and performing task processing according to the adjusted thread pool parameter. Among them, the technical features that are the same or similar to the above embodiment are not repeated here.

[0051] like Figure 2 As shown, the method of this embodiment specifically includes:

[0052] S210: Obtain task information and thread information in each first bucket of the thread pool in the current first time window.

[0053] S220. Determine an information identifier of the current first time window, wherein the information identifier is obtained based on a thread pool parameter adjustment operation of the thread pool.

[0054] S230: Based on the information identifier and the task information and thread information in each of the first buckets, adjust the first parameter of the thread pool, and perform task processing according to the adjusted thread pool parameter.

[0055] S240. Obtain task information and thread information in each second bucket in a current second time window, wherein the current first time window is smaller than the current second time window.

[0056] Among them, the current second time window can be understood as the time range of the second preset duration from the current moment. The second preset duration can be preset according to actual needs, such as 5 minutes. In an embodiment of the present invention, the second preset duration is greater than the first preset duration. That is, the current first time window is smaller than the current second time window, that is, the length of the current first time window is smaller than the length of the current second time window. The current second time window may include multiple continuous second buckets. The second bucket of the current second time window can be understood as a time slice within the current second time window. Exemplarily, the second preset duration can be 5 minutes, and the length of the current first time window is 300S. When the current moment is 9:10:20, the current first time window can be a period of 5 minutes from the current moment with the current moment as the end point, that is, 9:05:20 to 9:10:20. The second bucket can be every second in the period from 9:05:20 to 9:10:20.

[0057] Specifically, the task information and thread information of the thread pool within the second preset time period from the current moment can be obtained first, and then the task information and thread information of the thread pool in each time slice within the second preset time period from the current moment can be determined.

[0058] S250. Adjust the second parameter of the thread pool based on the task information and thread information in the second bucket, and perform task processing according to the adjusted thread pool parameter.

[0059] The second parameter can be understood as a thread pool parameter that needs to be adjusted based on the task information and thread information in the second bucket. In the embodiment of the present invention, by setting the second time window, the core thread can be dynamically adjusted to release the resources occupied by the idle thread when the system is stable.

[0060] As an optional implementation in an embodiment of the present invention, the adjusting the second parameter of the thread pool based on the task information and thread information in the second bucket may include: determining the amount of idle threads in each second bucket based on the task information and thread information in the second bucket, and determining the second number proportion of the second buckets whose idle threads are greater than zero; when the second number proportion exceeds the second proportion threshold, reducing the number of core threads in the thread pool. Further, based on the number of core threads in the thread pool, the average number of idle threads in the second time window may be reduced.

[0061] Among them, the idle thread amount can be understood as the number of idle threads. Among them, the second number ratio can be calculated based on the number of buckets of the second bucket whose idle thread amount is greater than zero and the total number of buckets of all second buckets in the second time window. The second ratio threshold can be pre-set according to actual needs. The ratio threshold, such as 50%. It can be understood that when the second number ratio exceeds 50%, it can be determined that the number of pending tasks in the thread pool is reduced.

[0062] In the embodiment of the present invention, the second quantity ratio of the second bucket with an idle thread quantity greater than zero is determined, specifically, the number of the second bucket with an idle thread quantity greater than zero can be determined first; then, the number of the second bucket with an idle thread quantity greater than zero and the total number of all the second buckets in the second time window can be calculated as a ratio. Thus, the second quantity ratio of the second bucket with an idle thread quantity greater than zero can be obtained.

[0063] As another optional implementation in the embodiment of the present invention, the adjusting the second parameter of the thread pool based on the task information and thread information in the second bucket may include: determining the amount of queued tasks in each of the second buckets based on the task information and thread information in the second bucket, and determining a third quantity proportion of the second buckets in which the amount of queued tasks is greater than zero; when the third quantity proportion exceeds a third proportion threshold, increasing the number of core threads of the thread pool.

[0064] Among them, the queued task volume can be understood as the number of tasks queued in the queue of the thread pool. The third quantity ratio can be calculated based on the same number of second buckets with a queued task volume greater than zero and the total number of all second buckets in the second time window. The third ratio threshold can be a ratio threshold pre-set according to actual needs, such as 50%. It can be understood that when the third quantity ratio exceeds 50%, it can be determined that the number of tasks to be processed in the thread pool has increased. At this time, the tasks can be processed by increasing the number of core threads of the thread pool.

[0065] In the embodiment of the present invention, the third quantity ratio of the second bucket whose queued task volume is greater than zero is determined, specifically, the number of the second bucket whose queued task volume is greater than zero can be determined first; then, the number of the second bucket whose queued task volume is greater than zero and the total number of the second buckets in the second time window can be calculated as a ratio. Thus, the third quantity ratio of the second bucket whose queued task volume is greater than zero can be obtained.

[0066] Further, when the third number ratio exceeds the third ratio threshold, the number of core threads of the thread pool is increased, specifically, the average number of queued tasks is increased on the basis of the number of core threads of the thread pool until the number of core threads does not exceed twice the number of CPU cores. The average number of queued tasks can be understood as the average number of queued tasks in the second time window.

[0067] Based on the embodiment of the present invention, through the first time window and the second time window, not only can the instantaneous peak process be handled, but also when there are fewer tasks, the resources occupied by idle threads can be released, the system utilization efficiency can be improved, and the system stability can be enhanced.

[0068] The technical solution of the embodiment of the present invention is to obtain the task information and thread information in each second bucket in the current second time window, wherein the current first time window is smaller than the current second time window; adjust the second parameter of the thread pool based on the task information and thread information in the second bucket, and perform task processing according to the adjusted thread pool parameters, thereby enabling the thread pool to reasonably release the resources occupied by idle threads when there are fewer tasks.

[0069] Figure 3 A schematic diagram of the structure of a task processing device provided by an embodiment of the present invention. Figure 3 As shown, the device includes: a bucket information acquisition module 310, an identification determination module 320 and a task processing module 330.

[0070] Among them, the bucket information acquisition module 310 is used to obtain the task information and thread information in each first bucket of the thread pool in the current first time window; the identifier determination module 320 is used to determine the information identifier of the current first time window, wherein the information identifier is obtained based on the thread pool parameter adjustment operation of the thread pool; the task processing module 330 is used to adjust the first parameter of the thread pool based on the information identifier and the task information and thread information in each first bucket, and perform task processing according to the adjusted thread pool parameters.

[0071] The technical solution of the embodiment of the present invention obtains the task information and thread information in each first bucket of the thread pool in the current first time window through the bucket information acquisition module; determines the information identifier of the current first time window through the identifier determination module, wherein the information identifier is obtained based on the thread pool parameter adjustment operation of the thread pool; adjusts the first parameter of the thread pool based on the information identifier and the task information and thread information in each first bucket through the task processing module, and performs task processing according to the adjusted thread pool parameter. The technical solution of the embodiment of the present invention solves the technical problem that the task processing of the related technology has poor adaptive performance, and realizes automatic adjustment of thread pool parameters to process tasks according to specific business scenarios.

[0072] Optionally, the task processing module 330 is used to determine the amount of rejected tasks in the first bucket based on the task information and thread information in the first bucket; and adjust the first parameter of the thread pool based on the amount of rejected tasks in each of the first buckets and the information identifier.

[0073] Optionally, the task processing module 330 is used to determine a first quantity ratio of the first bucket in which the amount of rejected tasks is greater than zero; and adjust a first parameter of the thread pool based on the first quantity ratio, a first ratio threshold and the information identifier.

[0074] Optionally, the first parameter includes queue capacity and / or maximum number of threads; accordingly, the task processing module 330 is used to:

[0075] When the first number ratio exceeds a first ratio threshold and the information identifier is empty, increase the queue capacity of the thread pool, and update the information identifier based on the operation of increasing the queue capacity of the thread pool;

[0076] When the first number ratio exceeds a first ratio threshold and the information identifier is a first identifier, increase the maximum number of threads in the thread pool, and update the information identifier based on the operation of increasing the maximum number of threads in the thread pool; wherein the first identifier is obtained based on the operation of increasing the queue capacity of the thread pool;

[0077] When the first number ratio exceeds a first ratio threshold and the information identifier is a second identifier, increase the maximum number of threads and queue capacity of the thread pool; wherein the second identifier is obtained based on the operation of increasing the maximum number of threads of the thread pool.

[0078] Optionally, the device also includes a parameter adjustment module, which is used to obtain task information and thread information in each second bucket in a current second time window, wherein the current first time window is smaller than the current second time window; adjust the second parameter of the thread pool based on the task information and thread information in the second bucket, and perform task processing according to the adjusted thread pool parameters.

[0079] Optionally, a parameter adjustment module is used to determine the number of idle threads in each second bucket based on the task information and thread information in the second bucket, and determine a second quantity proportion of the second buckets in which the number of idle threads is greater than zero; when the second quantity proportion exceeds a second proportion threshold, reduce the number of core threads of the thread pool.

[0080] Optionally, the parameter adjustment module is used to determine the amount of queued tasks in each of the second buckets based on the task information and thread information in the second bucket, and determine a third quantity proportion of the second buckets whose queued task amount is greater than zero; when the third quantity proportion exceeds a third proportion threshold, increase the number of core threads of the thread pool.

[0081] The task processing device provided in the embodiment of the present invention can execute the task processing method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0082] It is worth noting that the various units and modules included in the above-mentioned task processing device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present invention.

[0083] Figure 4 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0084] like Figure 4As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0085] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0086] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as a task processing method.

[0087] In some embodiments, the task processing method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the task processing method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the task processing method in any other appropriate manner (e.g., by means of firmware).

[0088] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0089] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0090] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0091] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0092] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0093] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0094] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0095] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A task processing method, characterized in that: The method comprises: Get the task information and thread information of each first bucket in the thread pool in the current first time window; Determine an information identifier of the current first time window, wherein the information identifier is obtained based on a thread pool parameter adjustment operation of the thread pool; Based on the information identifier and the task information and thread information in each of the first buckets, the first parameter of the thread pool is adjusted, and task processing is performed according to the adjusted thread pool parameter.

2. The method according to claim 1, characterized in that: The adjusting the first parameter of the thread pool based on the information identifier and the task information and thread information in each of the first buckets includes: Determine the amount of rejected tasks in the first bucket based on the task information and thread information in the first bucket; The first parameter of the thread pool is adjusted based on the amount of rejected tasks of each of the first buckets and the information identifier.

3. The method according to claim 2, characterized in that The adjusting the first parameter of the thread pool based on the amount of rejected tasks of each of the first buckets and the information identifier includes: Determine a first quantity ratio of the first bucket whose rejected task quantity is greater than zero; The first parameter of the thread pool is adjusted based on the first quantity proportion, the first proportion threshold and the information identifier.

4. The method according to claim 1, characterized in that: The first parameter includes queue capacity and / or maximum number of threads; The adjusting the first parameter of the thread pool based on the first quantity proportion, the first proportion threshold, and the information identifier includes: When the first number ratio exceeds a first ratio threshold and the information identifier is empty, increase the queue capacity of the thread pool, and update the information identifier based on the operation of increasing the queue capacity of the thread pool; When the first number ratio exceeds a first ratio threshold and the information identifier is a first identifier, increase the maximum number of threads in the thread pool, and update the information identifier based on the operation of increasing the maximum number of threads in the thread pool; wherein the first identifier is obtained based on the operation of increasing the queue capacity of the thread pool; When the first number ratio exceeds a first ratio threshold and the information identifier is a second identifier, increase the maximum number of threads and queue capacity of the thread pool; wherein the second identifier is obtained based on the operation of increasing the maximum number of threads of the thread pool.

5. The task processing method according to claim 1, characterized in that: The method further comprises: Obtaining task information and thread information in each second bucket in a current second time window, wherein the current first time window is smaller than the current second time window; The second parameter of the thread pool is adjusted based on the task information and thread information in the second bucket, and the task is processed according to the adjusted thread pool parameter.

6. The method according to claim 5, characterized in that The adjusting the second parameter of the thread pool based on the task information and thread information in the second bucket includes: Determine the amount of idle threads in each second bucket based on the task information and thread information in the second bucket, and determine a second quantity ratio of the second buckets in which the amount of idle threads is greater than zero; When the second number ratio exceeds a second ratio threshold, the number of core threads in the thread pool is reduced.

7. The method according to claim 5, characterized in that The adjusting the second parameter of the thread pool based on the task information and thread information in the second bucket includes: Based on the task information and thread information in the second bucket, determine the amount of queued tasks in each of the second buckets, and determine a third quantity ratio of the second buckets whose amount of queued tasks is greater than zero; When the third number ratio exceeds a third ratio threshold, the number of core threads in the thread pool is increased.

8. A task processing device, characterized in that: The device comprises: A bucket information acquisition module is used to obtain task information and thread information in each first bucket of the thread pool in the current first time window; An identification determination module, used to determine the information identification of the current first time window, wherein the information identification is obtained based on a thread pool parameter adjustment operation of the thread pool; The task processing module is used to adjust the first parameter of the thread pool based on the information identifier and the task information and thread information in each of the first buckets, and perform task processing according to the adjusted thread pool parameter.

9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the task processing method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the task processing method according to any one of claims 1 to 7 when executed.