CN113590285A - Method, system and equipment for dynamically setting thread pool parameters - Google Patents

Method, system and equipment for dynamically setting thread pool parameters Download PDF

Info

Publication number
CN113590285A
CN113590285A CN202110838179.8A CN202110838179A CN113590285A CN 113590285 A CN113590285 A CN 113590285A CN 202110838179 A CN202110838179 A CN 202110838179A CN 113590285 A CN113590285 A CN 113590285A
Authority
CN
China
Prior art keywords
thread pool
parameters
task
thread
setting
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110838179.8A
Other languages
Chinese (zh)
Inventor
冯留振
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Wanwu Xinsheng Environmental Technology Group Co
Original Assignee
Shanghai Wanwu Xinsheng Environmental Technology Group Co
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Wanwu Xinsheng Environmental Technology Group Co filed Critical Shanghai Wanwu Xinsheng Environmental Technology Group Co
Priority to CN202110838179.8A priority Critical patent/CN113590285A/en
Publication of CN113590285A publication Critical patent/CN113590285A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5011Pool
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5018Thread allocation

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application provides a technical scheme for dynamically setting thread pool parameters, wherein a thread pool is created and started, wherein the thread pool parameters of the thread pool are defined as variable parameters and set initial values; acquiring the operation index of the thread pool; determining whether the thread pool parameters of the thread pool need to be adjusted based on the operation indexes of the thread pool; and if necessary, dynamically setting the thread pool parameters through a distributed configuration center. In the program running process, whether the thread pool parameters need to be dynamically set can be determined according to the obtained running indexes of the thread pool. The technical scheme can realize the dynamic setting of the thread pool parameters, and can avoid the problems of program failure or service influence or unpredictable occurrence caused by unreasonable initial setting of the thread pool parameters.

Description

Method, system and equipment for dynamically setting thread pool parameters
Technical Field
The application relates to the technical field of computers, in particular to a technology for dynamically setting thread pool parameters.
Background
The computer program executes related tasks and processes data through threads, and when concurrent tasks or batch data are processed, the single-thread scheme has low processing efficiency, and a multi-thread scheme is generally selected for processing.
For a multi-thread scheme, a computer program usually manages each thread by using a thread pool, the thread pool and configurable parameters thereof are set in program development, and after the program development is completed, related parameters can be set before an application program is started. When a task is submitted to the thread pool, the processing flow of the thread pool is as shown in fig. 1: firstly, judging whether a core thread pool is full, if so, creating/distributing a working thread to process a task; if the task blocking queue is full, judging whether the task blocking queue is full, and if the task blocking queue is not full, storing a newly submitted task in the queue according to a first-in first-out principle to wait for execution; if yes, judging whether the whole thread pool is full, and if not, creating/allocating a working thread to process the task; if full, the task is processed according to a rejection policy.
Therefore, the most core of the thread pool is the parameter configuration of the thread pool, and if the parameter configuration of the thread pool is not reasonable, a fault is caused, so that an unpredictable problem is brought to the system. At present, the parameter setting of the thread pool is disposable, and after an application program is started, the configuration parameters of the thread pool cannot be dynamically set. For example, a JDK is used to develop a computer program, the configuration of the parameters of the thread pool is completed in the thread pool using method provided by the JDK, and after the program is run, the parameters of the number of core threads, the maximum number of threads, the size of the task blocking queue, etc. of the thread pool are determined when the thread pool is started.
On one hand, the running mechanism of the thread pool is not well understood, so that the reasonable configuration of the parameters is highly dependent on the personal experience and knowledge of developers; on the other hand, the thread pool has a large correlation between the execution condition and the task type, and the operating conditions of the tasks intensive for IO and intensive for CPU are very different, so that no mature thread pool parameter configuration experience strategy is provided for developers in the technical field. If the parameter setting is not reasonable in the program execution process, the program can only be closed, and the program is restarted after the thread pool parameters are reset to solve the problem, so that the service interruption is caused.
Disclosure of Invention
The application aims to provide a technical scheme for dynamically configuring thread pool parameters, which is used for solving the technical problem that the thread pool parameters cannot be dynamically set in the prior art.
According to an aspect of the present application, a method for dynamic configuration of thread pool parameters is provided, wherein the method comprises:
creating and starting a thread pool, wherein the thread pool parameters of the thread pool are defined as variable parameters and set initial values;
acquiring the operation index of the thread pool;
determining whether the thread pool parameters of the thread pool need to be adjusted based on the operation indexes of the thread pool;
and if necessary, dynamically setting the thread pool parameters through a distributed configuration center.
Optionally, the thread pool parameters include:
the number of core threads;
maximum number of threads;
the task blocks the queue length.
Optionally, the operation index of the thread pool includes:
task latency in a task block queue of the thread pool and/or whether the task block queue is full.
Optionally, the determining, based on the operation index of the thread pool, whether the thread pool parameter of the thread pool needs to be adjusted includes:
and determining whether the thread pool parameters of the thread pool need to be adjusted or not based on whether the task waiting time of the thread pool is larger than a preset threshold value and/or whether the task blocking queue is full.
Optionally, the dynamically setting the thread pool parameters through the distributed configuration center includes:
if the task waiting time is larger than a preset threshold value, setting a target parameter value of the core thread number through the distributed configuration center, and setting the core thread number and/or the maximum thread number of the thread pool as the target parameter value based on a BeforeExecute method in the thread pool class;
if the task blocking queue is full, setting a target parameter value of the length of the task blocking queue through the distributed configuration center, and setting the length of the task blocking queue as the target parameter value based on a setCapacity method in a blocking queue class.
Optionally, the method for dynamically setting the thread pool parameters further includes:
and sending out alarm information.
According to another aspect of the present application, there is also provided a system for dynamically setting thread pool parameters, wherein the system includes:
the system comprises a first module, a second module and a third module, wherein the first module is used for creating and starting a thread pool, and thread pool parameters of the thread pool are defined as variable parameters and set initial values;
the second module is used for acquiring the operation index of the thread pool;
a third module, configured to determine whether a thread pool parameter of the thread pool needs to be adjusted based on an operation index of the thread pool;
and the fourth module is used for dynamically setting the thread pool parameters through a distributed configuration center if the adjustment is needed.
Compared with the prior art, the technical scheme for dynamically setting the thread pool parameters is provided, and the thread pool is created and started, wherein the thread pool parameters of the thread pool are defined as variable parameters and set initial values; acquiring the operation index of the thread pool; determining whether the thread pool parameters of the thread pool need to be adjusted based on the operation indexes of the thread pool; and if necessary, dynamically setting the thread pool parameters through a distributed configuration center. In the program running process, whether the thread pool parameters need to be dynamically set can be determined according to the obtained running indexes of the thread pool. The technical scheme can realize the dynamic setting of the thread pool parameters, and can avoid the problems of program failure or service influence or unpredictable occurrence caused by unreasonable initial setting of the thread pool parameters.
Drawings
Other features, objects and advantages of the invention will become more apparent upon reading of the detailed description of non-limiting embodiments made with reference to the following drawings:
FIG. 1 illustrates a task processing flow diagram for a thread pool;
FIG. 2 illustrates a flow diagram of a method for dynamic setting of thread pool parameters, in accordance with an aspect of the subject application;
FIG. 3 is a diagram illustrating interface inheritance and class implementation of a custom thread pool in accordance with an alternative embodiment;
FIG. 4 is a schematic diagram illustrating interface inheritance and class implementation of a custom task block queue in accordance with an alternative embodiment;
FIG. 5 illustrates a system diagram of dynamic thread pool parameter setting in accordance with another aspect of the subject application;
the same or similar reference numbers in the drawings identify the same or similar elements.
Detailed Description
The present invention is described in further detail below with reference to the attached drawing figures.
In a typical configuration of the present application, the device, the system modules, and the trusted party each include one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include non-transitory computer readable media (transient media), such as modulated data signals and carrier waves.
In order to further explain the technical means and effects adopted by the present application, the following description clearly and completely describes the technical solution of the present application with reference to the accompanying drawings and preferred embodiments.
FIG. 2 illustrates a flow diagram of a method for dynamic thread pool parameter setting in one aspect of the subject application, wherein the method of an embodiment comprises:
s21, creating and starting a thread pool, wherein the thread pool parameters of the thread pool are defined as variable parameters and set initial values;
s22, acquiring the operation index of the thread pool;
s23, determining whether the thread pool parameters of the thread pool need to be adjusted based on the operation indexes of the thread pool;
and S24, if necessary, dynamically setting the thread pool parameters through a distributed configuration center.
In the present application, the method is performed by a device 100, where the device 100 is an intelligent terminal device, a computer device and/or a cloud installed with a computer program using a thread pool, and the intelligent terminal device includes, but is not limited to, a smart phone, a PAD; the computer device includes but is not limited to a personal computer, a notebook computer, an industrial computer, a network host, a single network server, a plurality of network server sets; the Cloud is made up of a large number of computers or web servers based on Cloud Computing (Cloud Computing), which is a type of distributed Computing, a virtual supercomputer consisting of a collection of loosely coupled computers.
The computer device and/or cloud are merely examples, and other existing or future devices and/or resource sharing platforms, as applicable to the present application, are also intended to be included within the scope of the present application and are hereby incorporated by reference.
In this embodiment, the computer program running on the device 100 may be developed based on JDK, and a method for using a thread pool is adopted when developing the computer program, or may be developed based on other development tools such as openJDK and the like and a method for using a thread pool is adopted when developing the computer program.
In step S21, the relevant computer program of the apparatus 100 creates a thread pool during initialization according to the usage method of the thread pool, wherein the thread pool parameters of the thread pool can be defined as variable parameters and set initial values, and a program developer can set the initial values of the thread pool parameters of the thread pool according to the task type of the thread pool processing task and some mature thread pool parameter configuration experience policies in the technical field. The thread pool may be enabled when an associated computer program in the apparatus 100 is running, and when a task is submitted to the thread pool, the task enters the thread pool and is executed.
In an application scenario of this embodiment, as shown in fig. 3, a custom thread pool class of a thread pool class threadpool executing or may be created based on inheritance and class implementation of each level of interfaces of the thread pool using method provided by JDK, for example, a thread pool class mythreadpool executing is customized to create a thread pool, and a thread pool parameter may be defined as a variable parameter and an initial value is set. The running index of the thread pool can be obtained in real time based on an Execute method in a thread pool using method provided by JDK, the running index of the thread pool obtained in real time is stored in a database in a persistent mode based on an Afterexecute method in the thread pool using method provided by JDK, and if the running index of the thread pool is abnormal, thread pool parameters such as the number of core threads and the maximum number of threads of the thread pool can be dynamically set based on a BeforExexecute method in the thread pool using method provided by JDK; and/or as shown in fig. 4, referring to inheritance and class implementation of each level of interfaces of Iterable- > Collection- > Queue- > LinkedBlockingQueue provided by JDK, constructing a custom task blocking Queue of a blocking Queue LinkedBlockingQueue, eliminating thread pool running index abnormality by dynamically setting the length of the custom task blocking Queue, for example, referring to LinkedBlockingQueue to customize a task blocking Queue canreselinkedblockingqueue, wherein a modifier final of capacity in the LinkedBlockingQueue is removed, and a setcapicity method is provided, so that the size of the Queue of the task blocking Queue of resilinedblockqueue can be dynamically set. When the computer program runs, the custom thread pool mythreadpoioleexecutor is enabled, including the custom task blocking queue canresilinedblockingqueue therein, and processes tasks as they are submitted into the thread pool mythreadpoioleexecutor, which may refer to the process flow shown in fig. 1. In fig. 3 and 4, the dotted line box represents interface inheritance, and the solid line box represents class implementation.
Optionally, the thread pool parameters include:
the number of core threads;
maximum number of threads;
the task blocks the queue length.
The thread pool parameters that can be set at the time of thread pool creation include: the method comprises the steps of core thread number, maximum thread number, task blocking queue length, idle thread survival time number and time unit, thread factory generating threads, rejection strategy and the like, wherein thread pool parameters such as the core thread number, the maximum thread number, the task blocking queue length and the like have great influence on the performance of processing tasks by a thread pool, namely the operation index of the thread pool.
In this embodiment, in the running process of the computer program, in the step S22, the apparatus 100 obtains the running index of the thread pool in real time to monitor the running performance status of the processing task of the thread pool in real time.
Optionally, the operation index of the thread pool includes:
task latency in a task block queue of the thread pool and/or whether the task block queue is full.
When a task is submitted to a thread pool, if the task is pushed to a task blocking queue, the waiting time of the task entering the task blocking queue and/or the judgment whether the task blocking queue is full can be determined as the running index of the thread pool, and the running performance state of the thread pool for processing the task is monitored by acquiring the waiting time of the task in the task blocking queue of the thread pool and/or the completion of the task blocking queue in real time.
In this embodiment, in the step S23, the apparatus 100 determines whether the thread pool parameters of the thread pool need to be adjusted according to the operation index of the thread pool obtained in real time.
Optionally, wherein the S23 includes:
and determining whether the thread pool parameters of the thread pool need to be adjusted or not based on whether the task waiting time of the thread pool is larger than a preset threshold value and/or whether the task blocking queue is full.
For example, when a task is provided to a thread pool, if the task enters the thread pool and is immediately executed without waiting, it indicates that a thread is available in the thread pool, and the operation index is considered to be normal; if the task enters the thread pool and is not executed immediately but is sent to the task blocking queue to wait, it indicates that no core thread is available when the task is submitted to the thread pool, the waiting time of the task can be obtained, if the waiting time is less than a preset threshold, it indicates that the time for the task previously queued in the task blocking queue to be executed is not very long, and the task can be executed after waiting for the tolerable time, it is considered that the program or service is not affected, but if the waiting time is greater than the preset threshold, it indicates that more tasks previously queued in the task blocking queue or the time for the task to be executed is long, the waiting time is too long, which not only affects the program or service corresponding to the task, but also affects the execution of the task subsequently submitted to the thread pool, such operation index is considered as abnormal, the thread pool parameters should be adjusted to improve the operation performance state of the thread pool, so that tasks that have entered the thread pool and/or subsequently entered the thread pool can be executed as soon as possible within a time that is desirable, such as dynamically increasing the number of core threads and/or the maximum number of threads; if the task cannot be pushed into the task blocking queue after the task enters the thread pool, it indicates that too many tasks waiting to be executed in the thread pool affect the execution of the program or service corresponding to the task and the task subsequently submitted to the thread pool, and it is considered that such an operation index is also abnormal, and the thread pool parameters should be adjusted to improve the operation performance state of the thread pool, so that the task entering the thread pool can be executed as soon as possible, for example, the length of the task blocking queue is dynamically increased.
Continuing in this embodiment, if it is determined that the thread pool parameter needs to be adjusted based on the operation index of the thread pool, in step S24, the apparatus 100 dynamically sets the thread pool parameter through a distributed configuration center.
For example, in the above application scenario, the device 100 obtains the operation index of the thread pool in real time by an Execute method, and stores the operation index of the thread pool in a persistent manner in the database by an after Execute method. The program or the system is usually configured with a background management subsystem, which can monitor the operation index of the thread pool stored in the database in real time, if the operation index is abnormal, the background management subsystem triggers a related instruction, and the Zookeeper in the distributed configuration center in the device 100 establishes a communication connection with the thread pool according to the name of the thread pool and the related instruction, and dynamically sets the thread pool parameters.
Optionally, the dynamically setting the thread pool parameters through the distributed configuration center includes:
if the task waiting time is larger than a preset threshold value, setting a target parameter value of the core thread number through the distributed configuration center, and setting the core thread number and/or the maximum thread number of the thread pool as the target parameter value based on a BeforeExecute method in the thread pool class;
if the task blocking queue is full, setting a target parameter value of the length of the task blocking queue through the distributed configuration center, and setting the length of the task blocking queue as the target parameter value based on a setCapacity method in a blocking queue class.
For example, in the foregoing application scenario, if the waiting time of the task in the thread pool acquired by the device 100 is greater than the preset threshold, the target parameter value of the core thread number of the thread pool mythreadpoiolexecutor may be set by the distributed configuration center Zookeeper, and the core thread number of the thread pool mythreadpoiolexecutor is set as the target parameter value based on the BeforeExecute method in the thread pool mythreadpooxecutor. If the waiting time of the task to be processed in the thread pool after the core thread number is dynamically set is still larger than the preset threshold value, and a larger core thread number cannot be dynamically set, a target parameter value of the maximum thread number of the MyThreadPoolleExecutor can be dynamically set, and the maximum thread number of the MyThreadPoolleExecutor in the thread pool is set as the target parameter value based on a BeforeExecute method in the MyThreadPoolleExecutor to increase the maximum thread number in the thread pool.
If the custom task blocking queue CanResizeLinkedBlockingQueue is full, a target parameter value of the queue length of the task blocking queue CanResizeLinkedBlockingQueue is set through the distributed configuration center Zookeeper, and the queue length of the task blocking queue CanResizeLinkedBlockingQueue is set as the target parameter value based on a setCapacity method in the task blocking queue CanResizeLinkeLinkedBlockingQueue.
Computer programs are usually configured with a background management subsystem, which can provide functions such as task management, parameter adjustment, authority setting and the like, and can also monitor the running indexes of a thread pool in real time. Optionally, if the background management subsystem monitors that the operation index is abnormal, an alarm message may be sent, where the alarm message may be sent through a visual interface, or may be combined with an audible and visual alarm message.
In another optional embodiment, the operation indexes of the thread pool in the foregoing embodiment may further include a usage status of a core thread pool of the thread pool and a usage status of a maximum thread pool, and the apparatus 100 may determine whether to dynamically set the thread pool parameters according to different operation indexes of the thread pool obtained in real time.
FIG. 5 is a schematic diagram of a system for dynamically setting thread pool parameters according to another aspect of the present application, where the system includes:
a first module 51, configured to create and enable a thread pool, where a thread pool parameter of the thread pool is defined as a variable parameter and sets an initial value;
a second module 52, configured to obtain an operation index of the thread pool;
a third module 53, configured to determine whether a thread pool parameter of the thread pool needs to be adjusted based on an operation index of the thread pool;
a fourth module 54, configured to dynamically set the thread pool parameters through the distributed configuration center if adjustment is needed.
In this embodiment, the system is used to implement the method of the previous embodiment, and is integrated in the same device as the software and hardware configuration environment of the previous device 100.
The first module 51 of the system creates a thread pool according to the usage method of the thread pool, wherein the thread pool parameters of the thread pool can be defined as variable parameters and set initial values, and a program developer can set the initial values of the thread pool parameters of the thread pool according to the task type of the thread pool processing task and some mature thread pool parameter configuration experience strategies in the technical field. After the thread pool is enabled, when the task is submitted to the thread pool, the task enters the thread pool and is executed.
The second module 52 of the system obtains the running index of the thread pool in real time to monitor the running performance state of the processing task of the thread pool in real time.
A third module 53 of the system determines whether the thread pool parameters of the thread pool need to be adjusted according to the running index of the thread pool obtained in real time.
The fourth module 54 of the system dynamically sets the thread pool parameters through a distributed configuration center.
According to yet another aspect of the present application, there is also provided a computer readable medium having stored thereon computer readable instructions executable by a processor to implement the foregoing method.
It should be noted that the present application may be implemented in software and/or a combination of software and hardware, for example, implemented using Application Specific Integrated Circuits (ASICs), general purpose computers or any other similar hardware devices. In one embodiment, the software programs referred to in the present application may be executed by a processor to implement the steps or functions described above. Also, the software programs (including associated data structures) of the present application may be stored in a computer-readable recording medium. Additionally, some of the steps or functions of the present application may be implemented in hardware, for example, as circuitry that cooperates with the processor to perform various steps or functions.
In addition, some of the present application may be implemented as a computer program product, such as computer program instructions, which when executed by a computer, may invoke or provide methods and/or techniques in accordance with the present application through the operation of the computer. Program instructions which invoke the methods of the present application may be stored on a fixed or removable recording medium and/or transmitted via a data stream on a broadcast or other signal-bearing medium and/or stored within a working memory of a computer device operating in accordance with the program instructions. An embodiment according to the present application comprises a device comprising a memory for storing computer program instructions and a processor for executing the program instructions, wherein the computer program instructions, when executed by the processor, trigger the device to perform a method and/or a solution according to the aforementioned embodiments of the present application.
According to another aspect of the present application, there is also provided an apparatus for dynamically setting thread pool parameters, wherein the apparatus includes:
one or more processors; and
a memory storing computer readable instructions that, when executed, cause the processor to perform operations of the method as previously described.
For example, the computer readable instructions, when executed, cause the one or more processors to: creating and starting a thread pool, wherein the thread pool parameters of the thread pool are defined as variable parameters and set initial values; acquiring the operation index of the thread pool; determining whether the thread pool parameters of the thread pool need to be adjusted based on the operation indexes of the thread pool; and if necessary, dynamically setting the thread pool parameters through a distributed configuration center.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the apparatus claims may also be implemented by one unit or means in software and/or hardware. The terms first, second, etc. are used to denote names, but not any particular order.

Claims (9)

1. A method for dynamic setting of thread pool parameters, the method comprising:
creating and starting a thread pool, wherein the thread pool parameters of the thread pool are defined as variable parameters and set initial values;
acquiring the operation index of the thread pool;
determining whether the thread pool parameters of the thread pool need to be adjusted based on the operation indexes of the thread pool;
and if necessary, dynamically setting the thread pool parameters through a distributed configuration center.
2. The method of claim 1, wherein the thread pool parameters comprise:
the number of core threads;
maximum number of threads;
the task blocks the queue length.
3. The method of claim 2, wherein the run metrics for the thread pool comprise:
task latency in a task block queue of the thread pool and/or whether the task block queue is full.
4. The method of claim 3, wherein determining whether a thread pool parameter of the thread pool needs to be adjusted based on the operation metric of the thread pool comprises:
and determining whether the thread pool parameters of the thread pool need to be adjusted or not based on whether the task waiting time of the thread pool is larger than a preset threshold value and/or whether the task blocking queue is full.
5. The method of claim 4, wherein dynamically setting the thread pool parameters via a distributed configuration center comprises:
if the task waiting time is larger than a preset threshold value, setting a target parameter value of the core thread number through the distributed configuration center, and setting the core thread number and/or the maximum thread number of the thread pool as the target parameter value based on a BeforeExecute method in the thread pool class;
if the task blocking queue is full, setting a target parameter value of the length of the task blocking queue through the distributed configuration center, and setting the length of the task blocking queue as the target parameter value based on a setCapacity method in a blocking queue class.
6. The method according to any one of claims 1 to 5, further comprising:
and sending out alarm information.
7. A system for dynamic setting of thread pool parameters, the system comprising:
the system comprises a first module, a second module and a third module, wherein the first module is used for creating and starting a thread pool, and thread pool parameters of the thread pool are defined as variable parameters and set initial values;
the second module is used for acquiring the operation index of the thread pool;
a third module, configured to determine whether a thread pool parameter of the thread pool needs to be adjusted based on an operation index of the thread pool;
and the fourth module is used for dynamically setting the thread pool parameters through a distributed configuration center if the adjustment is needed.
8. A computer-readable medium comprising, in combination,
stored thereon computer readable instructions to be executed by a processor to implement the method of any one of claims 1 to 6.
9. An apparatus for dynamic setting of thread pool parameters, the apparatus comprising:
one or more processors; and
memory storing computer readable instructions that, when executed, cause the processor to perform the operations of the method of any of claims 1 to 6.
CN202110838179.8A 2021-07-23 2021-07-23 Method, system and equipment for dynamically setting thread pool parameters Pending CN113590285A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110838179.8A CN113590285A (en) 2021-07-23 2021-07-23 Method, system and equipment for dynamically setting thread pool parameters

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110838179.8A CN113590285A (en) 2021-07-23 2021-07-23 Method, system and equipment for dynamically setting thread pool parameters

Publications (1)

Publication Number Publication Date
CN113590285A true CN113590285A (en) 2021-11-02

Family

ID=78249287

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110838179.8A Pending CN113590285A (en) 2021-07-23 2021-07-23 Method, system and equipment for dynamically setting thread pool parameters

Country Status (1)

Country Link
CN (1) CN113590285A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114422498A (en) * 2021-12-14 2022-04-29 杭州安恒信息技术股份有限公司 Big data real-time processing method and system, computer equipment and storage medium
CN117093640A (en) * 2023-10-18 2023-11-21 上海柯林布瑞信息技术有限公司 Data extraction method and device based on pooling technology

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170034310A1 (en) * 2015-07-29 2017-02-02 Netapp Inc. Remote procedure call management
CN108762913A (en) * 2018-03-23 2018-11-06 阿里巴巴集团控股有限公司 service processing method and device
US20200192725A1 (en) * 2018-12-18 2020-06-18 At&T Intellectual Property I, L.P. Distributed Load Balancing for Processing of High-Volume Data Streams
CN112000455A (en) * 2020-09-10 2020-11-27 华云数据控股集团有限公司 Multithreading task processing method and device and electronic equipment
CN112817719A (en) * 2021-01-28 2021-05-18 平安普惠企业管理有限公司 Method, device and equipment for adjusting parameters of thread pool and readable storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170034310A1 (en) * 2015-07-29 2017-02-02 Netapp Inc. Remote procedure call management
CN108762913A (en) * 2018-03-23 2018-11-06 阿里巴巴集团控股有限公司 service processing method and device
US20200192725A1 (en) * 2018-12-18 2020-06-18 At&T Intellectual Property I, L.P. Distributed Load Balancing for Processing of High-Volume Data Streams
CN112000455A (en) * 2020-09-10 2020-11-27 华云数据控股集团有限公司 Multithreading task processing method and device and electronic equipment
CN112817719A (en) * 2021-01-28 2021-05-18 平安普惠企业管理有限公司 Method, device and equipment for adjusting parameters of thread pool and readable storage medium

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
有思想的搬运工: "可动态调节参数的线程池实现", pages 1 - 11, Retrieved from the Internet <URL:https://developer.aliyun.com/article/778751?utm_content=g_1000219727> *
致远 陆晨: "Java线程池实现原理及其在美团业务中的实践", pages 1 - 41, Retrieved from the Internet <URL:https://tech.meituan.com/2020/04/02/java-pooling-pratice-in-meituan.html> *
试剑江湖。: "【并发编程】线程池参数设置与动态调整", pages 1 - 31, Retrieved from the Internet <URL:https://blog.csdn.net/qq_41893274/article/details/112424767> *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114422498A (en) * 2021-12-14 2022-04-29 杭州安恒信息技术股份有限公司 Big data real-time processing method and system, computer equipment and storage medium
CN117093640A (en) * 2023-10-18 2023-11-21 上海柯林布瑞信息技术有限公司 Data extraction method and device based on pooling technology
CN117093640B (en) * 2023-10-18 2024-01-23 上海柯林布瑞信息技术有限公司 Data extraction method and device based on pooling technology

Similar Documents

Publication Publication Date Title
US11640465B2 (en) Methods and systems for troubleshooting applications using streaming anomaly detection
US9934098B2 (en) Automatic serial order starting of resource groups on failover systems based on resource group usage prediction
US9876673B2 (en) Self-learning automated remediation of changes that cause performance degradation of applications
US9092247B2 (en) Persistent and resilient worker processes
US20190026459A1 (en) Methods and systems to analyze event sources with extracted properties, detect anomalies, and generate recommendations to correct anomalies
US10783002B1 (en) Cost determination of a service call
US9535754B1 (en) Dynamic provisioning of computing resources
US20190163550A1 (en) Automated methods and systems to classify and troubleshoot problems in information technology systems and services
US20200052993A1 (en) Methods and Systems that Diagnose and Manage Undesirable Operational States of Computing Facilities
US20180165693A1 (en) Methods and systems to determine correlated-extreme behavior consumers of data center resources
US11372871B1 (en) Programmable framework for distributed computation of statistical functions over time-based data
US20210119878A1 (en) Detection and remediation of virtual environment performance issues
CN113590285A (en) Method, system and equipment for dynamically setting thread pool parameters
US9386087B2 (en) Workload placement in a computer system
CN113067875A (en) Access method, device and equipment based on dynamic flow control of micro-service gateway
Di Sanzo et al. Machine learning for achieving self-* properties and seamless execution of applications in the cloud
CN113760658A (en) Monitoring method, device and equipment
US9501321B1 (en) Weighted service requests throttling
CN107958414B (en) Method and system for eliminating long transactions of CICS (common integrated circuit chip) system
US9244736B2 (en) Thinning operating systems
CN115422010A (en) Node management method and device in data cluster and storage medium
US9772877B2 (en) Managing I/O operations in a shared file system
CN114968552A (en) Cache allocation method, apparatus, device, storage medium and program product
CN112612578A (en) Virtual machine monitoring method and device
CN113396392A (en) Increasing processing power of virtual machines for exception events

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination