Thread pool optimization processing method, device, storage medium and equipment

By monitoring the memory occupancy rate of virtual machines and triggering thread pool control strategies, dynamically adjusting thread pool parameters, solving the problem of complex thread pool optimization in the existing technology and the inability to avoid memory overflow, realizing the reduction of memory occupancy rate and improving system stability Effect.

CN114281505BActive Publication Date: 2024-12-27CHINA TELECOM CORP LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111603656.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-24
Publication Date
2024-12-27
Estimated Expiration
2041-12-24

AI Technical Summary

Technical Problem

In the prior art, the thread pool optimization processing method is implemented in a complex manner and cannot completely avoid memory overflow, resulting in system crashes.

Method used

By obtaining the virtual machine memory occupancy rate of the software system, if it is detected that it exceeds the warning line, the thread pool control strategy will be triggered, the thread pool parameters will be dynamically adjusted to reduce the memory occupancy rate, and the maximum thread of the thread pool will be updated when the memory occupancy rate returns to normal. , turn off the control policy.

Benefits of technology

It realizes dynamic adjustment of thread pool parameters based on memory usage, reduces the memory share of virtual machines, avoids system crashes, and improves the system's concurrent processing capabilities and stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114281505B_ABST
    Figure CN114281505B_ABST
Patent Text Reader

Abstract

The present invention discloses a thread pool optimization processing method, device, storage medium and equipment. The method includes: obtaining the memory occupancy rate of the virtual machine of the software system; if it is detected that the memory occupancy rate exceeds the warning line, triggering the thread pool control strategy for the software system, wherein the thread pool control strategy is used to dynamically adjust the parameters of each thread pool in the software system to reduce the memory occupancy rate of the virtual machine; when it is detected that the memory occupancy rate of the virtual machine drops to within the warning line, updating the maximum number of threads of the thread pool in the software system, and closing the thread pool control strategy. The present invention solves the technical problem that the thread pool optimization processing method in the prior art is relatively complex to implement and cannot completely avoid the occurrence of memory overflow.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a thread pool optimization processing method, device, storage medium and equipment. Background Art

[0002] With the continuous development of communication technology, the increasing amount of information has led to many platforms facing the pressure of high-concurrency information processing. In the process of high-concurrency processing, multi-threaded execution is often used extensively. When the system is running under multi-threaded high-load, if the thread occupies too much memory resources, it may cause memory overflow. Once the system overflows, it will be unable to continue to provide services, and ultimately a manual restart is required to restore the system's service status.

[0003] At present, most companies avoid system crashes caused by system memory usage overflow by optimizing the JVM (Java Virtual Machine operating environment, hereinafter referred to as JVM). However, the optimization method in the prior art is relatively complicated to implement and cannot completely avoid memory overflow.

[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0005] The embodiments of the present invention provide a thread pool optimization processing method, device, storage medium and equipment to at least solve the technical problems that the thread pool optimization processing method in the prior art is relatively complex to implement and cannot completely avoid memory overflow.

[0006] According to one aspect of an embodiment of the present invention, a thread pool optimization processing method is provided, comprising: obtaining the memory occupancy rate of a virtual machine of a software system; if it is detected that the memory occupancy rate exceeds a warning line, triggering a thread pool control strategy for the software system, wherein the thread pool control strategy is used to dynamically adjust parameters of each thread pool in the software system to reduce the memory occupancy rate of the virtual machine; when it is detected that the memory occupancy rate of the virtual machine drops to within the warning line, updating the maximum number of threads of the thread pool in the software system, and closing the thread pool control strategy.

[0007] Optionally, the above-mentioned obtaining of the memory occupancy rate of the virtual machine of the software system includes: obtaining the current operating status of the above-mentioned software system and the hardware information of the server where the above-mentioned software system is located; obtaining the memory configuration information of the above-mentioned virtual machine; and determining the memory occupancy rate of the above-mentioned virtual machine based on the above-mentioned current operating status, the above-mentioned hardware information and the above-mentioned memory configuration information.

[0008] Optionally, the method further includes: if it is detected that the memory usage rate does not exceed the warning line, obtaining the current number of threads in the thread pool; if the current number of threads is not equal to the maximum number of threads, setting the maximum number of threads to the current number of threads.

[0009] Optionally, the above-mentioned triggering of the thread pool control strategy for the above-mentioned software system includes: adjusting the above-mentioned maximum number of threads of each of the above-mentioned thread pools in the above-mentioned software system in an intermittent and gradual manner to control the above-mentioned software system to reduce the number of thread pools that actually exist currently.

[0010] Optionally, the maximum number of threads in each of the thread pools in the software system is adjusted in an intermittent and gradual manner, including: obtaining the duration of the memory occupancy rate exceeding the warning line; and using preset warning rules to adjust the maximum number of threads in each of the thread pools by a predetermined percentage each time based on the duration in seconds.

[0011] Optionally, after triggering the thread pool control policy for the software system, the method further includes: determining alarm prompt information based on the triggering frequency and severity of the thread pool control policy; outputting the alarm prompt information to the management personnel, wherein the alarm prompt information is used to prompt the management personnel to determine whether it is necessary to manually increase the physical memory to meet the memory requirements of the software system.

[0012] According to another aspect of an embodiment of the present invention, a thread pool optimization processing device is also provided, including: an acquisition module, used to obtain the memory occupancy rate of the virtual machine of the software system; a first processing module, used to trigger the thread pool control strategy for the above-mentioned software system if it is detected that the above-mentioned memory occupancy rate exceeds the warning line, wherein the above-mentioned thread pool control strategy is used to dynamically adjust the parameters of each thread pool in the above-mentioned software system to reduce the memory occupancy rate of the above-mentioned virtual machine; a second processing module, used to update the maximum number of threads of the above-mentioned thread pool in the above-mentioned software system and close the above-mentioned thread pool control strategy when it is detected that the memory occupancy rate of the above-mentioned virtual machine drops to within the above-mentioned warning line.

[0013] Optionally, the above-mentioned acquisition module includes: a first acquisition unit, used to obtain the current operating status of the above-mentioned software system and the hardware information of the server where the above-mentioned software system is located; a second acquisition unit, used to obtain the memory configuration information of the above-mentioned virtual machine; and a determination unit, used to determine the memory occupancy rate of the above-mentioned virtual machine based on the above-mentioned current operating status, the above-mentioned hardware information and the above-mentioned memory configuration information.

[0014] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is further provided, wherein the computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing any one of the above-mentioned thread pool optimization processing methods.

[0015] According to another aspect of an embodiment of the present invention, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute any one of the above-mentioned thread pool optimization processing methods.

[0016] In an embodiment of the present invention, the memory occupancy rate of the virtual machine of the software system is obtained; if it is detected that the above memory occupancy rate exceeds the warning line, the thread pool control strategy for the above software system is triggered, wherein the above thread pool control strategy is used to dynamically adjust the parameters of each thread pool in the above software system to reduce the memory occupancy rate of the above virtual machine; when it is detected that the memory occupancy rate of the above virtual machine drops to not exceeding the above warning line, the maximum number of threads of the above thread pool in the above software system is updated, and the above thread pool control strategy is closed, thereby achieving the purpose of triggering the thread pool control strategy according to the memory occupancy rate and then dynamically adjusting the operating parameters, thereby achieving the technical effect of reducing the memory occupancy rate of the virtual machine, and then solving the technical problem that the thread pool optimization processing method in the prior art is relatively complex to implement and cannot completely avoid the memory overflow situation. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0018] Figure 1 is a flow chart of a thread pool optimization processing method according to an embodiment of the present invention;

[0019] Figure 2 is a schematic diagram of an optional thread pool optimization process according to an embodiment of the present invention;

[0020] Figure 3 is a schematic diagram of an optional memory occupancy confirmation process according to an embodiment of the present invention;

[0021] Figure 4 It is a structural schematic diagram of a thread pool optimization processing device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0022] 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.

[0023] 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.

[0024] Example 1

[0025] According to an embodiment of the present invention, an embodiment of a thread pool optimization processing method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0026] Figure 1 is a flow chart of a thread pool optimization processing method according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:

[0027] Step S102, obtaining the memory occupancy rate of the virtual machine of the software system;

[0028] Step S104: if it is detected that the memory occupancy rate exceeds the warning line, a thread pool control strategy for the software system is triggered, wherein the thread pool control strategy is used to dynamically adjust parameters of each thread pool in the software system to reduce the memory occupancy rate of the virtual machine;

[0029] Step S106, when it is detected that the memory occupancy rate of the virtual machine drops to within the warning line, the maximum number of threads of the thread pool in the software system is updated, and the thread pool control strategy is closed.

[0030] In an embodiment of the present invention, the execution subject of the thread pool optimization processing solution provided in the above steps S102 to S106 is a server, that is, the above server of the software system is used to obtain the memory occupancy rate of the virtual machine of the software system; and determine whether the above memory occupancy rate exceeds the warning line. If it is detected that the above memory occupancy rate exceeds the above warning line, the thread pool control strategy for the above software system is triggered to reduce the memory occupancy rate of the above virtual machine; when the memory occupancy rate of the above virtual machine drops to within the above warning line, the maximum number of threads of the above thread pool in the above software system is updated, and the above thread pool control strategy is closed.

[0031] It should be noted that the above-mentioned server can be built into the above-mentioned software system to obtain relevant hardware data such as memory, number of processor CPU cores, etc.; the above-mentioned thread pool control strategy is used to dynamically adjust the parameters of each thread pool in the above-mentioned software system to reduce the memory occupancy of the above-mentioned virtual machine.

[0032] As an optional embodiment, the above server is used to obtain the memory of the software system, the number of processor CPU cores and other related hardware data, and the memory size of the JVM (Java virtual machine operating environment, hereinafter referred to as JVM) is calculated; and the optimal number of threads is calculated by taking multiples of two through the thread control strategy formula. In the above progressive process, the memory and CPU occupancy rates are monitored. The high memory occupancy threshold can be set to 75%, and the high CPU occupancy threshold can be set to 80%. The calculation formula is as follows:

[0033]

[0034] Wherein, N = the number of CPUs; U = the utilization rate of the target CPU, 0<=U<=1; W / E = the ratio of waiting time to computing time; the number of increments is n.

[0035] Optionally, when the occupancy rate of the software system exceeds the high occupancy rate threshold, the optimal number of threads is calculated by subtracting 1 from the number of progressions n.

[0036] As an optional embodiment, the memory warning water level of the virtual machine (i.e., the warning line) can be calculated based on the memory occupancy variance v using the jvm memory variance calculation formula: When the above variance is less than 5, it means that the disturbance of the memory usage is small, and the warning water level can be set to 90%; when the above variance is greater than 5, the calculation method of the warning water level is: The optimal memory warning water level is obtained through the above algorithm.

[0037] Through the embodiments of the present invention, Figure 2The thread pool optimization process flow diagram shown in the figure analyzes and calculates the virtual machine memory occupancy rate in real time according to the current software system operation status, and obtains the optimal parameters of the current software system thread pool to improve the concurrent processing capability of the system. By setting the virtual machine memory occupancy standard, if the memory occupancy rate is too large and reaches the corresponding warning line, the thread pool restriction strategy is immediately triggered, and the various thread pool parameters are dynamically adjusted to reduce the virtual machine memory occupancy rate. After the memory occupancy rate drops to a normal level, the algorithm will re-modify the maximum number of threads in the thread pool and turn off the thread control strategy to ensure that the service will not be completely lost in the case of a surge in system pressure, and maximize the use of system resources when the system memory occupancy rate allows, improve the concurrent processing speed of the system, and at the same time, if the restriction strategy is triggered, an alarm will be sent to the administrator. According to the severity of the frequency of the restriction strategy triggering, the administrator will determine whether it is necessary to manually increase the physical memory to meet the system requirements.

[0038] Through the embodiments of the present invention, the purpose of triggering the thread pool control strategy according to the memory occupancy rate and then dynamically adjusting the operating parameters is achieved, thereby achieving the technical effect of reducing the memory occupancy rate of the virtual machine, and further solving the technical problem that the thread pool optimization processing method in the prior art is relatively complex to implement and cannot completely avoid the occurrence of memory overflow.

[0039] In an optional embodiment, the obtaining of the memory occupancy rate of the virtual machine of the software system includes:

[0040] Step S202, obtaining the current running status of the software system and the hardware information of the server where the software system is located;

[0041] Step S204, obtaining memory configuration information of the virtual machine;

[0042] Step S206: determining the memory occupancy rate of the virtual machine according to the current operating status, the hardware information and the memory configuration information.

[0043] In the embodiment of the present invention, Figure 3 The memory occupancy confirmation process diagram shown in the figure adopts the above-mentioned server to obtain the current operating status of the above-mentioned software system and the hardware information of the server where the above-mentioned software system is located; obtains the memory configuration information of the above-mentioned virtual machine; and determines the memory occupancy of the above-mentioned virtual machine based on the above-mentioned current operating status, the above-mentioned hardware information and the above-mentioned memory configuration information.

[0044] As an optional embodiment, after obtaining relevant hardware data such as the software system's memory and the number of processor CPU cores, the memory occupancy rate of the jvm is calculated according to the software system's hardware conditions and the jvm memory configuration.

[0045] In an optional embodiment, the above method further includes:

[0046] Step S302, if it is detected that the memory usage rate does not exceed the warning line, the current number of threads in the thread pool is obtained;

[0047] Step S304: if the current number of threads is not equal to the maximum number of threads, the maximum number of threads is set to be the current number of threads.

[0048] In an embodiment of the present invention, if it is detected that the memory occupancy rate does not exceed the set warning line, the current number of threads in the thread pool is obtained, and it is determined whether the current number of threads is equal to the calculated maximum number of threads. If they are not equal, the maximum number of threads is set to the current number of threads.

[0049] As an optional embodiment, during the operation of the software system, if the memory usage rate does not reach the warning level, the thread parameter of the current system thread pool is set to the calculated maximum number of threads to ensure high concurrency of the system.

[0050] In an optional embodiment, the triggering of the thread pool control strategy for the software system includes:

[0051] Step S402: The maximum number of threads in each of the thread pools in the software system is adjusted in an intermittent and gradual manner to control the software system to reduce the number of thread pools that actually exist.

[0052] As an optional embodiment, when a pressure peak occurs during the operation of the software system, that is, when the server monitors that the memory usage of the current software system has reached the warning line, the server will immediately implement the above-mentioned thread pool control strategy, and continuously and intermittently and gradually reduce the operating parameters such as the maximum number of threads in each thread pool in the system, and slowly reduce the actual number of threads in the software system.

[0053] In an optional embodiment, the maximum number of threads in each of the thread pools in the software system is adjusted in an intermittent and gradual manner, including:

[0054] Step S502, obtaining the duration of the memory usage exceeding the warning line;

[0055] Step S504: using a preset warning rule and taking seconds as the unit according to the duration, each time adjusting the maximum number of threads in each of the thread pools to decrease by a predetermined percentage.

[0056] In an embodiment of the present invention, in the process of adjusting the above-mentioned maximum number of threads of each of the above-mentioned thread pools in the above-mentioned software system in an intermittent and gradual manner, the duration that the above-mentioned memory occupancy rate exceeds the above-mentioned warning line is first obtained in seconds, and the above-mentioned maximum number of threads of each of the above-mentioned thread pools is adjusted to decrease by a predetermined percentage each time.

[0057] As an optional embodiment, during the above slow decrease, the number of threads may be decreased once per second based on the time that the memory usage rate exceeds the warning line, which may be in seconds, and each time adjusted to 75% of the maximum number of threads.

[0058] In an optional embodiment, after triggering the thread pool control strategy for the software system, the method further includes:

[0059] Step S602, determining alarm prompt information based on the triggering frequency and severity of the thread pool control strategy;

[0060] Step S604: output the above-mentioned alarm prompt information to the management personnel, wherein the above-mentioned alarm prompt information is used to prompt the above-mentioned management personnel to determine whether it is necessary to manually increase the physical memory to meet the memory demand of the above-mentioned software system.

[0061] In an embodiment of the present invention, the above-mentioned server can determine the alarm prompt information based on the triggering frequency and severity of the above-mentioned thread pool control strategy, and send the alarm prompt information to an electronic device associated with the management personnel, so as to prompt the above-mentioned management personnel to determine whether it is necessary to manually increase the physical memory to meet the memory requirements of the above-mentioned software system.

[0062] As an optional embodiment, the server may record the time of triggering each time the thread pool control strategy is triggered, and analyze and process the time and number of multiple triggerings. If the situation is judged to be more serious, an alarm text message may be sent to the administrator based on the trigger warning. The administrator may judge whether it is necessary to manually increase the physical memory to meet the system requirements based on the frequency and severity of the thread control strategy.

[0063] Optionally, after the above alarm prompt information is triggered, the actual number of running threads of the software system will gradually decrease. When the software system memory returns to a normal level, the server will stop the thread pool control strategy. At this time, the actual number of software system threads meets the high concurrency, and the current software system is in the optimal number of threads for stable operation, which can ensure the maximum concurrency that can be provided while the software system is running stably.

[0064] As an optional embodiment, after the peak of memory occupancy pressure of the above-mentioned software system has passed, when the server monitors that the current system memory occupancy has dropped to a lower level (the lower limit of the memory warning line is 40%), the server will dynamically modify the parameters of each thread pool of the software system to the calculated maximum number of threads that can be sustained under the condition of high-efficiency operation of the current business.

[0065] Optionally, after the process control strategy stops, if the memory usage reaches the warning line again, the thread pool control strategy will be triggered again, which can ensure that the system will not crash due to memory overflow.

[0066] Through the above steps, it is possible to balance the stability and high concurrency of the software system. According to the optimal number of threads between stability and high concurrency, the overall data processing efficiency of the system is greatly improved while ensuring the stable operation of the software system, and the performance of the server hardware is maximized. The stability of the system is guaranteed, so that the thread pool parameters are in the optimal state in real time, and manual pressure measurement is no longer required to determine the size of the core parameters of the thread pool. The purpose of triggering the thread pool control strategy according to the memory occupancy rate and then dynamically adjusting the operating parameters is achieved, thereby achieving the technical effect of reducing the memory occupancy rate of the virtual machine, and then solving the technical problem that the thread pool optimization processing method in the prior art is relatively complicated to implement and cannot completely avoid the memory overflow.

[0067] Example 2

[0068] According to an embodiment of the present invention, a device embodiment for implementing the above thread pool optimization processing method is also provided. Figure 4 is a structural diagram of a thread pool optimization processing device according to an embodiment of the present invention. Figure 4 As shown, the above device includes: an acquisition module 40, a first processing module 42 and a second processing module 44, wherein:

[0069] An acquisition module 40 is used to acquire the memory occupancy rate of the virtual machine of the software system;

[0070] A first processing module 42 is configured to trigger a thread pool control strategy for the software system if it is detected that the memory occupancy rate exceeds a warning line, wherein the thread pool control strategy is configured to dynamically adjust parameters of each thread pool in the software system to reduce the memory occupancy rate of the virtual machine;

[0071] The second processing module 44 is used to update the maximum number of threads in the thread pool in the software system and close the thread pool control strategy when it is detected that the memory occupancy rate of the virtual machine drops to within the warning line.

[0072] Optionally, the above-mentioned acquisition module includes: a first acquisition unit, used to obtain the current operating status of the above-mentioned software system and the hardware information of the server where the above-mentioned software system is located; a second acquisition unit, used to obtain the memory configuration information of the above-mentioned virtual machine; and a determination unit, used to determine the memory occupancy rate of the above-mentioned virtual machine based on the above-mentioned current operating status, the above-mentioned hardware information and the above-mentioned memory configuration information.

[0073] It should be noted here that the above-mentioned acquisition module 40, first processing module 42 and second processing module 44 correspond to steps S102 to S106 in Example 1, and the three modules and the corresponding steps implement the same instances and application scenarios, but are not limited to the contents disclosed in the above-mentioned Example 1.

[0074] It should be noted that the preferred implementation of this embodiment can refer to the relevant description in Example 1, which will not be repeated here.

[0075] According to an embodiment of the present invention, an embodiment of a computer-readable storage medium is also provided. Optionally, in this embodiment, the computer-readable storage medium can be used to store the program code executed by the thread pool optimization processing method provided in the above embodiment 1.

[0076] Optionally, in this embodiment, the computer-readable storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group.

[0077] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for executing the following steps: obtaining the memory occupancy rate of the virtual machine of the software system; if it is detected that the above memory occupancy rate exceeds the warning line, triggering the thread pool control policy for the above software system, wherein the above thread pool control policy is used to dynamically adjust the parameters of each thread pool in the above software system to reduce the memory occupancy rate of the above virtual machine; when it is detected that the memory occupancy rate of the above virtual machine drops to within the above warning line, updating the maximum number of threads of the above thread pool in the above software system, and closing the above thread pool control policy.

[0078] Optionally, the computer-readable storage medium may also execute program code for the following steps: obtaining the current operating status of the software system and the hardware information of the server where the software system is located; obtaining the memory configuration information of the virtual machine; and determining the memory occupancy rate of the virtual machine based on the current operating status, the hardware information and the memory configuration information.

[0079] Optionally, the computer-readable storage medium may also execute program code of the following steps: if it is detected that the memory usage rate does not exceed the warning line, the current number of threads in the thread pool is obtained; if the current number of threads is not equal to the maximum number of threads, the maximum number of threads is set to the current number of threads.

[0080] Optionally, the computer-readable storage medium may also execute program code of the following steps: adjusting the maximum number of threads of each of the thread pools in the software system in an intermittent and progressive manner to control the software system to reduce the number of thread pools actually existing at present.

[0081] Optionally, the computer-readable storage medium may also execute program code of the following steps: obtaining the duration that the memory usage rate exceeds the warning line; and using preset warning rules to adjust the maximum number of threads of each thread pool by a predetermined percentage each time based on the duration, in seconds.

[0082] Optionally, the computer-readable storage medium may also execute program code of the following steps: determining alarm prompt information based on the triggering frequency and severity of the thread pool control strategy; and outputting the alarm prompt information to management personnel, wherein the alarm prompt information is used to prompt the management personnel to determine whether it is necessary to manually increase the physical memory to meet the memory requirements of the software system.

[0083] According to an embodiment of the present invention, an embodiment of a processor is also provided. Optionally, in this embodiment, the computer-readable storage medium can be used to store the program code executed by the thread pool optimization processing method provided in the above embodiment 1.

[0084] An embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, the following steps are implemented: obtaining the memory occupancy rate of a virtual machine of a software system; if it is detected that the memory occupancy rate exceeds a warning line, triggering a thread pool control strategy for the software system, wherein the thread pool control strategy is used to dynamically adjust parameters of each thread pool in the software system to reduce the memory occupancy rate of the virtual machine; when it is detected that the memory occupancy rate of the virtual machine drops to within the warning line, updating the maximum number of threads in the thread pool in the software system, and shutting down the thread pool control strategy.

[0085] Optionally, the electronic device may also execute the program code of the following steps: obtaining the current operating status of the software system and the hardware information of the server where the software system is located; obtaining the memory configuration information of the virtual machine; and determining the memory occupancy rate of the virtual machine based on the current operating status, the hardware information and the memory configuration information.

[0086] Optionally, the electronic device may also execute the following program code: if it is detected that the memory occupancy rate does not exceed the warning line, the current number of threads in the thread pool is obtained; if the current number of threads is not equal to the maximum number of threads, the maximum number of threads is set to the current number of threads.

[0087] Optionally, the electronic device may also execute the program code of the following steps: adjusting the maximum number of threads of each of the thread pools in the software system in an intermittent and progressive manner to control the software system to reduce the number of thread pools actually existing currently.

[0088] Optionally, the electronic device may also execute the program code of the following steps: obtaining the duration that the memory occupancy rate exceeds the warning line; and using preset warning rules to adjust the maximum number of threads of each thread pool by a predetermined percentage each time based on the duration, in seconds.

[0089] Optionally, the electronic device may also execute the following program code steps: determining alarm prompt information based on the triggering frequency and severity of the thread pool control strategy; outputting the alarm prompt information to a management personnel, wherein the alarm prompt information is used to prompt the management personnel to determine whether it is necessary to manually increase the physical memory to meet the memory requirements of the software system.

[0090] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that is initialized with the following method steps: obtaining the memory occupancy rate of the virtual machine of the software system; if it is detected that the above memory occupancy rate exceeds the warning line, triggering a thread pool control strategy for the above software system, wherein the above thread pool control strategy is used to dynamically adjust the parameters of each thread pool in the above software system to reduce the memory occupancy rate of the above virtual machine; when it is detected that the memory occupancy rate of the above virtual machine drops to within the above warning line, updating the maximum number of threads of the above thread pool in the above software system, and closing the above thread pool control strategy.

[0091] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0092] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0093] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0094] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0095] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0096] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

[0097] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A thread pool optimization processing method, characterized in that: include: Obtain the memory usage of the virtual machine of the software system; If it is detected that the memory occupancy rate exceeds the warning line, a thread pool control strategy for the software system is triggered, wherein the thread pool control strategy is used to dynamically adjust the parameters of each thread pool in the software system to reduce the memory occupancy rate of the virtual machine; wherein, triggering the thread pool control strategy for the software system includes: adjusting the maximum number of threads of each thread pool in the software system in an intermittent and progressive manner to control the software system to reduce the number of thread pools currently actually existing, and the intermittent and progressive manner to adjust the maximum number of threads of each thread pool in the software system includes: Obtain the duration of time that the memory usage rate exceeds the warning line; and use a preset warning rule to adjust the maximum number of threads in each thread pool by a predetermined percentage in seconds according to the duration; When it is detected that the memory occupancy rate of the virtual machine drops to within the warning line, the maximum number of threads of the thread pool in the software system is updated, and the thread pool control strategy is closed; If it is detected that the memory occupancy rate does not exceed the warning line, the current number of threads of the thread pool is obtained; if the current number of threads is not equal to the maximum number of threads, the maximum number of threads is set to the current number of threads.

2. The method according to claim 1, characterized in that The obtaining of the memory occupancy rate of the virtual machine of the software system includes: Obtaining the current running status of the software system and the hardware information of the server where the software system is located; Obtaining memory configuration information of the virtual machine; The memory occupancy rate of the virtual machine is determined according to the current operating status, the hardware information and the memory configuration information.

3. The method according to claim 1, characterized in that After triggering the thread pool control strategy for the software system, the method further includes: Determine the alarm prompt information based on the trigger frequency and severity of the thread pool control strategy; The alarm prompt information is output to a management personnel, wherein the alarm prompt information is used to prompt the management personnel to determine whether it is necessary to manually increase the physical memory to meet the memory requirement of the software system.

4. A thread pool optimization processing device, characterized in that: include: An acquisition module, used to obtain the memory occupancy rate of the virtual machine of the software system; The first processing module is used to trigger the thread pool control strategy for the software system if it is detected that the memory occupancy rate exceeds the warning line, wherein the thread pool control strategy is used to dynamically adjust the parameters of each thread pool in the software system to reduce the memory occupancy rate of the virtual machine; wherein, triggering the thread pool control strategy for the software system includes: adjusting the maximum number of threads of each thread pool in the software system in an intermittent and progressive manner to control the software system to reduce the number of thread pools currently actually existing, and the intermittent and progressive manner to adjust the maximum number of threads of each thread pool in the software system includes: obtaining the duration of the memory occupancy rate exceeding the warning line; using a preset warning rule to adjust the maximum number of threads of each thread pool by a predetermined percentage each time according to the duration, in seconds; A second processing module is used to update the maximum number of threads in the thread pool in the software system and close the thread pool control strategy when detecting that the memory occupancy rate of the virtual machine drops to within the warning line; The thread pool optimization processing device is also used to obtain the current number of threads in the thread pool when it is detected that the memory occupancy rate does not exceed the warning line; if the current number of threads is not equal to the maximum number of threads, the maximum number of threads is set to the current number of threads.

5. The device according to claim 4, characterized in that The acquisition module comprises: A first acquisition unit, used to acquire the current running status of the software system and the hardware information of the server where the software system is located; A second acquisition unit, used to acquire memory configuration information of the virtual machine; A determination unit is used to determine the memory occupancy rate of the virtual machine according to the current operating status, the hardware information and the memory configuration information.

6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the thread pool optimization processing method described in any one of claims 1 to 3.

7. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to execute the thread pool optimization processing method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Self-tuning method, device and equipment of application server thread pool

    CN109885385A