[go: up one dir, main page]

CN109840141B - Thread control method and device based on cloud monitoring, electronic equipment and storage medium - Google Patents

Thread control method and device based on cloud monitoring, electronic equipment and storage medium Download PDF

Info

Publication number
CN109840141B
CN109840141B CN201811537777.6A CN201811537777A CN109840141B CN 109840141 B CN109840141 B CN 109840141B CN 201811537777 A CN201811537777 A CN 201811537777A CN 109840141 B CN109840141 B CN 109840141B
Authority
CN
China
Prior art keywords
thread
current
preset
application program
process information
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.)
Active
Application number
CN201811537777.6A
Other languages
Chinese (zh)
Other versions
CN109840141A (en
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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201811537777.6A priority Critical patent/CN109840141B/en
Publication of CN109840141A publication Critical patent/CN109840141A/en
Application granted granted Critical
Publication of CN109840141B publication Critical patent/CN109840141B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

A thread control method based on cloud monitoring comprises the following steps: the method comprises the steps of configuring an initial maximum thread number in advance according to an initial configuration file of a system, and determining the initial maximum thread number as the current maximum thread number of the system; acquiring process information of an application program currently operated by a system and the number of bus threads currently used by the application program; calculating the current thread utilization rate according to the current maximum thread number and the current bus thread number; judging whether the current thread utilization rate is larger than a preset thread utilization rate threshold value or not; and when the current thread utilization rate is greater than a preset thread utilization rate threshold value, reconfiguring the current maximum thread number of the system according to a preset thread configuration strategy. The invention further provides a thread control device based on cloud monitoring, electronic equipment and a storage medium. According to the method, the system and the device, the cloud monitoring is used for realizing real-time adjustment of the maximum thread number when the running state of the system changes, so that the system resource can be reasonably utilized to the greatest extent.

Description

Thread control method and device based on cloud monitoring, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of computers, in particular to a thread control method and device based on cloud monitoring, electronic equipment and a storage medium.
Background
In a computer system, various system resources are used for task processing, when a task needs to be processed, the system receives a request for accessing the designated system resources, establishes a thread for the request, and then processes the request by using the established thread. To fully utilize system resources, parallel processing of multiple requests is typically implemented in a multi-threaded manner. However, too high thread number may cause excessive resource consumption on unnecessary task operations due to resource contention, thread switching, etc., so that the system is unstable due to excessive resource consumption, and the efficiency of processing the request is affected. Therefore, the number of threads needs to be controlled to optimize resource utilization.
In the prior art, a maximum thread number is set usually when the system is started, and the currently established thread number is controlled to be not more than the preset maximum thread number, so that thread control is realized.
However, when the system operation load is large, if the maximum number of threads is preset according to the prior art, the threads are built according to the maximum number of threads, the preset maximum number of threads may be large, so that the system is unstable due to the excessive number of built threads, or the preset maximum number of threads is small, so that the system operation is blocked due to the insufficient number of built threads, and the resource utilization rate of the system is affected.
Disclosure of Invention
In view of the above, it is necessary to provide a thread control method, device, electronic device and storage medium based on cloud monitoring, which can realize real-time adjustment of the maximum number of threads when the running state of a system changes through cloud monitoring, so as to ensure that the system resources can be reasonably utilized to the greatest extent.
The first aspect of the invention provides a thread control method based on cloud monitoring, which comprises the following steps:
The method comprises the steps of configuring an initial maximum thread number in advance according to an initial configuration file of a system, and determining the initial maximum thread number as the current maximum thread number of the system;
acquiring process information of an application program currently running in a system;
acquiring the current bus thread number of the application program according to the process information;
Calculating the current thread utilization rate according to the current maximum thread number and the current bus thread number;
judging whether the calculated current thread utilization rate is larger than a preset thread utilization rate threshold value or not;
And when the calculated current thread utilization rate is greater than a preset thread utilization rate threshold value, reconfiguring the current maximum thread number of the system according to a preset thread configuration strategy.
According to a preferred embodiment of the present invention, the preset thread configuration policy is to determine a current maximum thread number range of the system according to a current bus thread number used by the system and a preset thread configuration range.
According to a preferred embodiment of the present invention, the determining the current maximum thread number range of the system according to the current bus thread number used by the system and the preset thread configuration range includes:
determining the maximum value of the current maximum thread number of the system according to the current bus thread number and a first preset value of the preset thread configuration range;
Determining the minimum value of the current maximum thread number of the system according to the current bus thread number and a second preset value of the preset thread configuration range;
An integer value is randomly selected between the minimum value and the maximum value of the determined current maximum thread number of the system, and the selected integer value is configured as the current maximum thread number.
According to a preferred embodiment of the present invention, the obtaining the current number of bus threads used by the application program according to the process information includes:
Acquiring all application programs running currently;
Acquiring the thread number used by each application program from the process information corresponding to each running application program;
And accumulating the thread number used by each application program to obtain the total thread number used by the currently running application program.
According to a preferred embodiment of the present invention, before the acquiring the process information of the application program currently running on the system, the method further includes:
Detecting whether an established thread exists in the system currently;
If the system currently has an established thread, acquiring the process information of an application program currently operated by the system;
if the system does not currently have an established thread, waiting for the next acquisition period to acquire the process information of the application program currently running by the system.
According to a preferred embodiment of the present invention, when the process information of the application program currently running in the system is obtained, the method further includes:
and generating a monitoring information display interface, and displaying the process information of the application program and the thread information correspondingly used.
According to a preferred embodiment of the present invention, acquiring process information of an application currently running in a system includes:
Acquiring an application instance name of an application program from an environment configuration file of the application program;
And acquiring the process information of the application program currently operated by the system according to the application instance name.
The second aspect of the present invention provides a thread control device based on cloud monitoring, the device comprising:
the first configuration module is used for configuring an initial maximum thread number in advance according to an initial configuration file of the system, and determining the initial maximum thread number as the current maximum thread number of the system;
The first acquisition module is used for acquiring the process information of the application program currently operated by the system;
The second acquisition module is used for acquiring the current bus process number of the application program according to the process information;
The calculation module is used for calculating the current thread utilization rate according to the current maximum thread number and the current bus thread number;
the judging module is used for judging whether the calculated current thread utilization rate is larger than a preset thread utilization rate threshold value;
And the second configuration module is used for reconfiguring the current maximum thread number of the system according to a preset thread configuration strategy when the judgment module judges that the calculated current thread usage rate is greater than the preset thread usage rate threshold value.
A third aspect of the present invention provides an electronic device, where the electronic device includes a processor and a memory, where the processor is configured to implement the thread control method based on cloud monitoring when executing a computer program stored in the memory.
A fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which when executed by a processor implements the thread control method based on cloud monitoring.
The embodiment of the invention provides a thread control method, a device, electronic equipment and a storage medium based on cloud monitoring, which are used for acquiring an initial configuration file of a system, taking the initial maximum thread number determined according to the initial configuration file as the current maximum thread number of the system, acquiring process information of an application program currently operated by the system after the system operates the application program, and acquiring the current bus thread number used by the application program from the process information; calculating the current thread utilization rate according to the current maximum thread number and the current bus thread number; upon determining that the calculated current thread usage is greater than the preset thread usage threshold, the maximum number of threads is reconfigured. Through cloud monitoring, when the number of threads used by an application program currently running in the system changes, namely, when the running state of the system changes, the real-time adjustment of the maximum number of threads can be realized, so that the system resources can be reasonably utilized to the greatest extent, the utilization rate of the system resources can be kept optimal, the resource waste caused by the overlarge number of reconfigured threads is avoided, and the unstable running of the system caused by the overlarge number of configured threads is avoided. The reasonable thread number is reconfigured, so that the normal operation of the system can be effectively ensured, and the system resources can be saved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present invention, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of a thread control method based on cloud monitoring according to an embodiment of the present invention.
Fig. 2 is a functional block diagram of a thread control device based on cloud monitoring according to a second embodiment of the present invention.
Fig. 3 is a schematic diagram of an electronic device according to a third embodiment of the present invention.
The invention will be further described in the following detailed description in conjunction with the above-described figures.
Detailed Description
In order that the above-recited objects, features and advantages of the present invention will be more clearly understood, a more particular description of the invention will be rendered by reference to specific embodiments thereof which are illustrated in the appended drawings. It should be noted that, without conflict, the embodiments of the present invention and features in the embodiments may be combined with each other.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention, and the described embodiments are merely some, rather than all, embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
The thread control method based on cloud monitoring in the embodiment of the invention is applied to the electronic equipment, and can also be applied to a hardware environment formed by the electronic equipment and a server connected with the electronic equipment through a network, and the thread control method based on cloud monitoring is executed by the server and the electronic equipment together. Networks include, but are not limited to: a wide area network, a metropolitan area network, or a local area network.
The electronic equipment can be a computing electronic equipment such as a desktop computer, a notebook computer, a palm computer, a cloud server and the like.
The electronic equipment which needs to carry out the thread control method based on cloud monitoring can directly integrate the thread control function based on the cloud monitoring provided by the method of the invention on the electronic equipment or install a client for realizing the method of the invention. For another example, the method provided by the invention can also be operated on electronic equipment such as a server in the form of a software development kit (Software Development Kit, SDK), an interface of the thread control function based on cloud monitoring is provided in the form of the SDK, and the server or other electronic equipment can realize the thread control function based on cloud monitoring through the provided interface.
Example 1
Fig. 1 is a flowchart of a thread control method based on cloud monitoring according to an embodiment of the present invention. The thread control method based on cloud monitoring monitors the current thread number index of the application program in the electronic equipment. The order of execution in the flow chart may be changed, and certain steps may be omitted, according to different needs.
S11: and configuring an initial maximum thread number in advance according to an initial configuration file of the system, and determining the initial maximum thread number as the current maximum thread number of the system.
The system in this embodiment is a computer system, where the computer system is composed of two parts, namely computer hardware and software. The hardware part may include a central processing unit, a memory, an external device, etc., and the software part may be various application programs and corresponding documents running on the computer. The computer system can receive and store information, quickly calculate and judge according to programs, and output processing results. The configuration files are typically stored on a local hard drive of the system, and may typically include a set of settings and files when the user uses the system, and so on.
Specifically, determining the initial maximum number of threads in advance according to the initial configuration file of the system may include: and acquiring initial configuration in the configuration file, and determining the initial thread number in the initial configuration file as the initial maximum thread number.
The configuration files in this embodiment may include an initial configuration file and an intermediate configuration file, where the initial configuration file may be a file preset by the system in a development stage, and the intermediate configuration file may be a history file generated after the system operates for a period of time. The initial configuration file stores preset initial thread number, and the initial thread number can be a reasonable value which is determined by a developer according to the hardware configuration of the system and ensures that the system can bear. Thus, the initial thread count in the initial configuration file may be extracted as the current maximum thread count of the system.
S12: and acquiring the process information of the application program currently running in the system.
The computer system may run one application or may run multiple applications. The application may be a java application.
Each application instance of an application corresponds to a process of the application.
In this embodiment, acquiring the process information of the application program currently running in the system may include:
1) The application instance name of the application program is obtained from the environment configuration file of the application program.
The environment profile may be an env file. After the environment configuration file of the application program is read, the application instance name spri _ lcloud-rmp-prd-ins9740 is obtained from the read environment configuration file.
2) And acquiring the process information of the application program currently operated by the system according to the application instance name.
The collected process information of the application program includes a process identifier (Process Identifier, PID) of the application program process. The process identifier is used to distinguish between individual processes. The process identifier may be a numeric number, such as a four-digit numeric number.
The collected process information of the application program can also comprise the application program to which the application program process belongs and the number of threads included. An application comprises an application process, which may include one thread or multiple threads, i.e., an application may correspond to one or more threads.
The collected process information of the application may also include a state of the application process. The states may include running, sleeping, idle, etc.
The collected process information of the application program can also comprise the starting time and date of the application program process, the priority of the application program process and the like.
And collecting the process information and the thread running condition in the JVM (Java Virtual Machine ) through a springboot-monitor.
The process information of the application program currently running on the computer device can be collected in the operating system command by taking the application instance name as a limiting condition. For example, if the application instance name is spri _ lcloud-rmp-prd-ins9740, then a constraint of the application instance name spri _ lcloud-rmp-prd-ins9740 is added to the operating system command, and the process information of the application program of the application instance name spri _ lcloud-rmp-prd-ins9740 is obtained.
The process information may be collected according to a preset time. For example, a time interval (e.g., once every 10 minutes) at which the process information is collected may be set, at which the process information is collected. For another example, a specific time (e.g., each full point time, e.g., 0 point, 1 point, 2 points) for collecting the process information may be set, and the process information is collected according to the specific time.
The collected process information may be stored to a designated database.
The specified database may be a time series database (instant sequence database), such as OpenTSDB, nfluxDB. The time series database is mainly used to refer to processing time-stamped (time-series-changed in order of time) data, which is also called time series data.
OpenTSDB is a distributed, scalable time series database based on Hbase. The data stored to OpenTSDB is in units of metric, which is 1 monitoring item, such as CPU usage. OpenTSDB uses HBase as storage, and data storage for meta is supported to the second level due to the good design. OpenTSDB support permanent storage of data, i.e., the stored data is not actively deleted; and the original data will be kept all the time (some monitoring systems will aggregate the data of a longer time ago and keep it later).
InfluxDB is an open source distributed timing, event, and metrics database. InfluxDB is written in the Go language, without external dependencies. Its design goal is to achieve distributed and horizontal telescoping expansion. InfluxDB has three main characteristics: time Series (time Series): time-dependent correlation functions (e.g., maximum, minimum, sum, etc.) may be used; metrics (metrics): a large amount of data can be calculated in real time; eevents (event): any event data is supported.
Preferably, when the process information of the application program currently running in the system is acquired, the method may further include: and generating a monitoring information display interface, and displaying the process information of the application program and the thread information correspondingly used.
A monitoring information display interface may be generated, in which process information of the application program and thread information corresponding to the application program used are displayed.
If the number of the application program processes running in the system is multiple, the process information of the multiple application programs and the thread information corresponding to the application programs can be obtained.
In a specific embodiment, the process information of the application program and the thread information used correspondingly may be shown through Grafana. The process information of the application program and the thread information corresponding to the application program can be transmitted to the Grafana platform for display through the collection agent of Grafana.
Grafana is a visualization panel (Dashboard) supporting various charts and layout presentations, supporting Graphite, zabbix, influxDB, prometheus and OpenTSDB as data sources. Grafana has the following characteristics: flexibly rich graphical options; multiple styles can be mixed; support daytime and nighttime modes; multiple data sources are supported.
S13: and acquiring the current bus process number of the application program according to the process information.
In this embodiment, the obtaining, according to the process information, the current number of bus threads used by the application program includes:
Acquiring all application programs running currently;
Acquiring the thread number used by each application program from the process information corresponding to each running application program;
And accumulating the thread number used by each application program to obtain the total thread number used by the currently running application program.
By way of example, assume that the system is currently running 5 applications: application 1, application 2, application 3, application 4 and application 5, wherein application 1 currently uses 1 thread, application 2 currently uses 3 threads, application 3 currently uses 3 threads, application 4 currently uses 2 threads, and application 5 currently uses 1 thread, the number of bus threads currently used by the running application is 1+3+3+2+1=10.
S14: and calculating the current thread utilization rate according to the current maximum thread number and the current bus thread number.
It should be appreciated that the current maximum number of threads, determined from the initial configuration file of the system, is a reasonable value for the number of threads that the system can carry, and that the number of bus threads used by the application running on the system is such that the initial maximum number of threads is not exceeded.
Current thread usage = current number of bus threads used/current maximum number of threads.
S15: and judging whether the calculated current thread use rate is larger than a preset thread use rate threshold value.
In this embodiment, the preset thread usage threshold is a preset thread usage threshold, which is an optimal value capable of ensuring normal and stable operation of the system. Illustratively, the preset thread usage threshold is 80%.
When the calculated current thread usage is greater than the preset thread usage threshold, S16 is performed. When the calculated current thread usage is less than or equal to the preset thread usage threshold, S12 may be repeatedly performed.
S16: and reconfiguring the current maximum number of threads of the system according to a preset thread configuration strategy.
In this embodiment, the preset thread configuration policy is a preset policy for configuring the maximum number of threads.
The preset thread configuration strategy is to determine the current maximum thread number range of the system according to the current bus thread number used by the system and the preset thread configuration range.
The preset thread configuration range is [ a first preset value, a second preset value ], and the first preset value is smaller than the second preset value. The preset thread configuration range is [0.7,0.8]
Specifically, determining the current maximum thread number range of the system according to the current bus thread number used by the system and the preset thread configuration range may include:
1) Determining the maximum value of the current maximum thread number of the system according to the current bus thread number and a first preset value of the preset thread configuration range;
for example, assume that the number of currently used buses is 10, and the first preset value of the preset thread configuration range is 0.7. The maximum number of current maximum threads of the system is determined to be 10/0.7=14.28, rounded to 15.
2) Determining the minimum value of the current maximum thread number of the system according to the current bus thread number and a second preset value of the preset thread configuration range;
illustratively, assume that the number of currently used buses is 10, and the second preset value of the preset thread configuration range is 0.8. The minimum value of the current maximum number of threads of the system is determined to be 10/0.8=12.5, and is rounded to be 13.
3) An integer value is randomly selected between the minimum value and the maximum value of the determined current maximum thread number of the system, and the selected integer value is configured as the current maximum thread number.
Illustratively, if the minimum value of the current maximum thread number of the system is 13 and the maximum value is 15, any integer value of 13,14 and 15 can be selected as the new current maximum thread number.
And determining the range of the thread number which should be reconfigured according to the thread configuration range and the current bus thread number of the system by presetting the thread configuration range, so as to avoid resource waste caused by overlarge reconfiguration thread number and unstable system operation caused by overlarge configuration thread number. The reasonable thread number is reconfigured, so that the normal operation of the system can be effectively ensured, and the system resources can be saved.
Further, before the process information of the application program currently running in the system is obtained, the method may further include:
Detecting whether an established thread exists in the system currently;
If the system currently has an established thread, acquiring the process information of an application program currently operated by the system;
if the system does not currently have an established thread, waiting for the next acquisition period to acquire the process information of the application program currently running by the system.
The process information of the application program currently running in the system is acquired at intervals of a preset time period, and the preset time period is called an acquisition period.
In the embodiment of the invention, the process information of the application program currently operated by the system can be periodically acquired, for example, the process information of the application program currently operated by the system can be acquired every 5 minutes, whether the system currently has an established thread or not can be detected before the process information of the application program currently operated by the system is acquired, and if the thread exists, the process information of the application program currently operated by the system is acquired; if not, the next cycle is awaited. In the embodiment of the invention, the specific time of the period is not limited, and can be set according to actual requirements when the period is specifically realized. Reasonable period duration is set, and the problem that the current maximum thread number is frequently replaced to influence the system operation can be avoided.
In summary, in the thread number control method provided by the first embodiment of the present invention, an initial configuration file of a system may be obtained, an initial maximum thread number determined according to the initial configuration file is used as a current maximum thread number of the system, and meanwhile, after an application program is run by the system, process information of the application program currently run by the system is obtained, and a current bus thread number used by the application program is obtained from the process information; calculating the current thread utilization rate according to the current maximum thread number and the current bus thread number; upon determining that the calculated current thread usage is greater than the preset thread usage threshold, the maximum number of threads is reconfigured. When the number of threads used by the application program currently running in the system changes, namely, when the running state of the system changes, the real-time adjustment of the maximum number of threads can be realized, so that the system resources can be reasonably utilized to the greatest extent, the utilization rate of the system resources can be kept optimal, and the problem that the resource waste is caused by overlarge number of reconfigured threads and the unstable running of the system is caused by overlarge number of configured threads is avoided. The reasonable thread number is reconfigured, so that the normal operation of the system can be effectively ensured, and the system resources can be saved.
In addition, the process of the traditional host layer cannot distinguish the application program process or the operating system process, the method and the device can acquire the process information of the running application program and acquire the thread used by the application program according to the process information of the running application program, thereby improving the accuracy of monitoring the thread use rate of the application program. Thereby improving the accuracy of configuring the maximum number of threads.
While the invention has been described with reference to specific embodiments, it will be understood by those skilled in the art that various changes in form and detail may be made therein without departing from the spirit and scope of the invention.
The following describes, with reference to fig. 2 to 3, a functional module and a hardware structure of an electronic device that implement the above-mentioned thread control method based on cloud monitoring, respectively.
Example two
FIG. 2 is a functional block diagram of a thread control device based on cloud monitoring according to a preferred embodiment of the present invention.
In some embodiments, the cloud monitoring-based thread control device 20 operates in an electronic device. The cloud monitoring-based thread control device 20 may include a plurality of functional modules composed of program code segments. Program code for each program segment in the cloud monitoring-based thread control device 20 may be stored in a memory and executed by at least one processor to perform (see fig. 1 and related description for details) monitoring a current thread count index of an application in an electronic device.
In this embodiment, the thread control device 20 based on cloud monitoring may be divided into a plurality of functional modules according to the functions performed by the thread control device. The functional module may include: a first configuration module 201, a first acquisition module 202, a presentation module 203, a second acquisition module 204, a calculation module 205, and a second configuration module 206. The module referred to in the present invention refers to a series of computer program segments capable of being executed by at least one processor and of performing a fixed function, stored in a memory. In some embodiments, the function of each module will be described in detail in the following embodiments.
The first configuration module 201 is configured to configure an initial maximum thread number in advance according to an initial configuration file of the system, and determine the initial maximum thread number as a current maximum thread number of the system.
The system in this embodiment is a computer system, where the computer system is composed of two parts, namely computer hardware and software. The hardware part may include a central processing unit, a memory, an external device, etc., and the software part may be various application programs and corresponding documents running on the computer. The computer system can receive and store information, quickly calculate and judge according to programs, and output processing results. The configuration files are typically stored on a local hard drive of the system, and may typically include a set of settings and files when the user uses the system, and so on.
Specifically, determining the initial maximum number of threads in advance according to the initial configuration file of the system may include: and acquiring initial configuration in the configuration file, and determining the initial thread number in the initial configuration file as the initial maximum thread number.
The configuration files in this embodiment may include an initial configuration file and an intermediate configuration file, where the initial configuration file may be a file preset by the system in a development stage, and the intermediate configuration file may be a history file generated after the system operates for a period of time. The initial configuration file stores preset initial thread number, and the initial thread number can be a reasonable value which is determined by a developer according to the hardware configuration of the system and ensures that the system can bear. Thus, the initial thread count in the initial configuration file may be extracted as the current maximum thread count of the system.
A first obtaining module 202, configured to obtain process information of an application program currently running in the system.
The computer system may run one application or may run multiple applications. The application may be a java application.
Each application instance of an application corresponds to a process of the application.
In this embodiment, the first obtaining module 202 may obtain the process information of the application program currently running in the system, which includes:
1) The application instance name of the application program is obtained from the environment configuration file of the application program.
The environment profile may be an env file. After the environment configuration file of the application program is read, the application instance name spri _ lcloud-rmp-prd-ins9740 is obtained from the read environment configuration file.
2) And acquiring the process information of the application program currently operated by the system according to the application instance name.
The collected process information of the application program includes a process identifier (Process Identifier, PID) of the application program process. The process identifier is used to distinguish between individual processes. The process identifier may be a numeric number, such as a four-digit numeric number.
The collected process information of the application program can also comprise the application program to which the application program process belongs and the number of threads included. An application comprises an application process, which may include one thread or multiple threads, i.e., an application may correspond to one or more threads.
The collected process information of the application may also include a state of the application process. The states may include running, sleeping, idle, etc.
The collected process information of the application program can also comprise the starting time and date of the application program process, the priority of the application program process and the like.
And collecting the process information and the thread running condition in the JVM (Java Virtual Machine ) through a springboot-monitor.
The process information of the application program currently running on the computer device can be collected in the operating system command by taking the application instance name as a limiting condition. For example, if the application instance name is spri _ lcloud-rmp-prd-ins9740, then a constraint of the application instance name spri _ lcloud-rmp-prd-ins9740 is added to the operating system command, and the process information of the application program of the application instance name spri _ lcloud-rmp-prd-ins9740 is obtained.
The process information may be collected according to a preset time. For example, a time interval (e.g., once every 10 minutes) at which the process information is collected may be set, at which the process information is collected. For another example, a specific time (e.g., each full point time, e.g., 0 point, 1 point, 2 points) for collecting the process information may be set, and the process information is collected according to the specific time.
The collected process information may be stored to a designated database.
The specified database may be a time series database (instant sequence database), such as OpenTSDB, nfluxDB. The time series database is mainly used to refer to processing time-stamped (time-series-changed in order of time) data, which is also called time series data.
OpenTSDB is a distributed, scalable time series database based on Hbase. The data stored to OpenTSDB is in units of metric, which is 1 monitoring item, such as CPU usage. OpenTSDB uses HBase as storage, and data storage for meta is supported to the second level due to the good design. OpenTSDB support permanent storage of data, i.e., the stored data is not actively deleted; and the original data will be kept all the time (some monitoring systems will aggregate the data of a longer time ago and keep it later).
InfluxDB is an open source distributed timing, event, and metrics database. InfluxDB is written in the Go language, without external dependencies. Its design goal is to achieve distributed and horizontal telescoping expansion. InfluxDB has three main characteristics: time Series (time Series): time-dependent correlation functions (e.g., maximum, minimum, sum, etc.) may be used; metrics (metrics): a large amount of data can be calculated in real time; eevents (event): any event data is supported.
Preferably, the thread control device 20 based on cloud monitoring may further include: the display module 203 is configured to generate a monitoring information display interface when the first acquisition module 202 acquires process information of an application program currently running in the system, and display the process information of the application program and thread information corresponding to the application program.
A monitoring information display interface may be generated, in which process information of the application program and thread information corresponding to the application program used are displayed.
If the number of the application program processes running in the system is multiple, the process information of the multiple application programs and the thread information corresponding to the application programs can be obtained.
In a specific embodiment, the process information of the application program and the thread information used correspondingly may be shown through Grafana. The process information of the application program and the thread information corresponding to the application program can be transmitted to the Grafana platform for display through the collection agent of Grafana.
Grafana is a visualization panel (Dashboard) supporting various charts and layout presentations, supporting Graphite, zabbix, influxDB, prometheus and OpenTSDB as data sources. Grafana has the following characteristics: flexibly rich graphical options; multiple styles can be mixed; support daytime and nighttime modes; multiple data sources are supported.
And the second obtaining module 204 is configured to obtain, according to the process information, the number of bus threads currently used by the application program.
In this embodiment, the obtaining, according to the process information, the current number of bus threads used by the application program includes: acquiring all application programs running currently; acquiring the thread number used by each application program from the process information corresponding to each running application program; and accumulating the thread number used by each application program to obtain the total thread number used by the currently running application program.
By way of example, assume that the system is currently running 5 applications: application 1, application 2, application 3, application 4 and application 5, wherein application 1 currently uses 1 thread, application 2 currently uses 3 threads, application 3 currently uses 3 threads, application 4 currently uses 2 threads, and application 5 currently uses 1 thread, the number of bus threads currently used by the running application is 1+3+3+2+1=10.
And the calculating module 205 is configured to calculate a current thread usage rate according to the current maximum thread number and the current bus thread number.
It should be appreciated that the current maximum number of threads, determined from the initial configuration file of the system, is a reasonable value for the number of threads that the system can carry, and that the number of bus threads used by the application running on the system is such that the initial maximum number of threads is not exceeded.
Current thread usage = current number of bus threads used/current maximum number of threads.
The calculating module 205 is further configured to determine whether the calculated current thread usage is greater than a preset thread usage threshold.
In this embodiment, the preset thread usage threshold is a preset thread usage threshold, which is an optimal value capable of ensuring normal and stable operation of the system. Illustratively, the preset thread usage threshold is 80%.
A second configuration module 206, configured to reconfigure the current maximum number of threads of the system according to the preset thread configuration policy when the calculation module 205 determines that the calculated current thread usage is greater than the preset thread usage threshold.
In this embodiment, the preset thread configuration policy is a preset policy for configuring the maximum number of threads.
The preset thread configuration strategy is to determine the current maximum thread number range of the system according to the current bus thread number used by the system and the preset thread configuration range.
The preset thread configuration range is [ a first preset value, a second preset value ], and the first preset value is smaller than the second preset value. The preset thread configuration range is [0.7,0.8]
Specifically, the determining, by the second configuration module 206, the current maximum thread number range of the system according to the current bus thread number used by the system and the preset thread configuration range may include:
1) Determining the maximum value of the current maximum thread number of the system according to the current bus thread number and a first preset value of the preset thread configuration range;
for example, assume that the number of currently used buses is 10, and the first preset value of the preset thread configuration range is 0.7. The maximum number of current maximum threads of the system is determined to be 10/0.7=14.28, rounded to 15.
2) Determining the minimum value of the current maximum thread number of the system according to the current bus thread number and a second preset value of the preset thread configuration range;
illustratively, assume that the number of currently used buses is 10, and the second preset value of the preset thread configuration range is 0.8. The minimum value of the current maximum number of threads of the system is determined to be 10/0.8=12.5, and is rounded to be 13.
3) An integer value is randomly selected between the minimum value and the maximum value of the determined current maximum thread number of the system, and the selected integer value is configured as the current maximum thread number.
Illustratively, if the minimum value of the current maximum thread number of the system is 13 and the maximum value is 15, any integer value of 13,14 and 15 can be selected as the new current maximum thread number.
And determining the range of the thread number which should be reconfigured according to the thread configuration range and the current bus thread number of the system by presetting the thread configuration range, so as to avoid resource waste caused by overlarge reconfiguration thread number and unstable system operation caused by overlarge configuration thread number. The reasonable thread number is reconfigured, so that the normal operation of the system can be effectively ensured, and the system resources can be saved.
The first obtaining module 202 is further configured to obtain process information of an application program currently running in the system when the calculating module 205 determines that the calculated current thread usage is less than or equal to the preset thread usage threshold.
Further, before the first obtaining module 202 obtains the process information of the application program currently running in the system, the thread control device 20 based on cloud monitoring may further include:
The detection module is used for detecting whether the system currently has an established thread or not;
The first obtaining module 202 is further configured to obtain process information of an application program currently running in the system when the detecting module detects that the system currently has an established thread;
the first obtaining module 202 is further configured to detect that the system does not currently have an established thread, and wait for a next obtaining period to obtain a process letter of an application program currently running in the system.
The process information of the application program currently running in the system is acquired at intervals of a preset time period, and the preset time period is called an acquisition period.
In the embodiment of the invention, the process information of the application program currently operated by the system can be periodically acquired, for example, the process information of the application program currently operated by the system can be acquired every 5 minutes, whether the system currently has an established thread or not can be detected before the process information of the application program currently operated by the system is acquired, and if the thread exists, the process information of the application program currently operated by the system is acquired; if not, the next cycle is awaited. In the embodiment of the invention, the specific time of the period is not limited, and can be set according to actual requirements when the period is specifically realized. Reasonable period duration is set, and the problem that the current maximum thread number is frequently replaced to influence the system operation can be avoided.
In summary, the thread number control device provided in the second embodiment of the present invention may obtain an initial configuration file of a system, take an initial maximum thread number determined according to the initial configuration file as a current maximum thread number of the system, and obtain process information of an application program currently operated by the system after the system operates the application program, and obtain a current bus thread number used by the application program from the process information; calculating the current thread utilization rate according to the current maximum thread number and the current bus thread number; upon determining that the calculated current thread usage is greater than the preset thread usage threshold, the maximum number of threads is reconfigured. When the number of threads used by the application program currently running in the system changes, namely, when the running state of the system changes, the real-time adjustment of the maximum number of threads can be realized, so that the system resources can be reasonably utilized to the greatest extent, the utilization rate of the system resources can be kept optimal, and the problem that the resource waste is caused by overlarge number of reconfigured threads and the unstable running of the system is caused by overlarge number of configured threads is avoided. The reasonable thread number is reconfigured, so that the normal operation of the system can be effectively ensured, and the system resources can be saved.
In addition, the process of the traditional host layer cannot distinguish the application program process or the operating system process, the method and the device can acquire the process information of the running application program and acquire the thread used by the application program according to the process information of the running application program, thereby improving the accuracy of monitoring the thread use rate of the application program. Thereby improving the accuracy of configuring the maximum number of threads.
The integrated units implemented in the form of software functional modules described above may be stored in a computer readable storage medium. The software functional modules described above are stored in a storage medium that includes instructions for causing a computer electronic device (which may be a personal computer, a two-screen electronic device, or a network electronic device, etc.) or a processor (processor) to perform portions of the methods described in the various embodiments of the invention.
Example III
Fig. 3 is a schematic diagram of an electronic device according to a third embodiment of the present invention.
The electronic device 3 includes: a memory 31, at least one processor 32, a computer program 33 stored in the memory 31 and executable on the at least one processor 32, and at least one communication bus 34.
The at least one processor 32, when executing the computer program 33, implements the steps of the embodiments of the cloud monitoring-based thread control method described above.
By way of example, the computer program 33 may be divided into one or more modules/units, which are stored in the memory 31 and executed by the at least one processor 32. The one or more modules/units may be a series of computer program instruction segments capable of performing the specified functions for describing the execution of the computer program 33 in the electronic device 3.
The electronic device 3 may be a computing electronic device such as a desktop computer, a notebook computer, a palm computer, a cloud server, etc. It will be appreciated by those skilled in the art that the schematic diagram 3 is merely an example of the electronic device 3 and does not constitute a limitation of the electronic device 3, and may include more or less components than illustrated, or may combine certain components, or different components, e.g. the electronic device 3 may further include input-output electronic devices, network access electronic devices, buses, etc.
The at least one Processor 32 may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (DIGITAL SIGNAL Processor, DSP), application SPECIFIC INTEGRATED Circuit (ASIC), off-the-shelf Programmable gate array (Field-Programmable GATE ARRAY, FPGA) or other Programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like. The processor 32 may be a microprocessor or the processor 32 may be any conventional processor or the like, the processor 32 being a control center of the electronic device 3, the various interfaces and lines being used to connect the various parts of the entire electronic device 3.
The memory 31 may be used to store the computer program 33 and/or modules/units, and the processor 32 may implement various functions of the electronic device 3 by running or executing the computer program and/or modules/units stored in the memory 31 and invoking data stored in the memory 31. The memory 31 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program (such as a sound playing function, an image playing function, etc.) required for at least one function, and the like; the storage data area may store data created according to the use of the electronic device 3 (such as audio data, phonebooks, etc.), and the like. In addition, the memory 31 may include high-speed random access memory, and may also include non-volatile memory, such as a hard disk, memory, plug-in hard disk, smart memory card (SMART MEDIA CARD, SMC), secure Digital (SD) card, flash memory card (FLASH CARD), at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage device.
The modules/units integrated in the electronic device 3 may be stored in a computer readable storage medium if implemented in the form of software functional units and sold or used as separate products. Based on such understanding, the present invention may implement all or part of the flow of the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the computer readable medium contains content that can be appropriately scaled according to the requirements of jurisdictions in which such content is subject to legislation and patent practice, such as in certain jurisdictions in which such content is subject to legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunication signals.
In the several embodiments provided in the present invention, it should be understood that the disclosed server and method may be implemented in other manners. For example, the server embodiments described above are merely illustrative, e.g., the division of the elements is merely a logical functional division, and there may be additional divisions when actually implemented.
In addition, each functional unit in the embodiments of the present invention may be integrated in the same processing unit, or each unit may exist alone physically, or two or more units may be integrated in the same unit. The integrated units can be realized in a form of hardware or a form of hardware and a form of software functional modules.
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 characteristics 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 will be obvious that the term "comprising" does not exclude other elements or that the singular does not exclude a plurality. A plurality of units or means recited in the system claims can also be implemented by means of software or hardware by means of one unit or means. The terms first, second, etc. are used to denote a name, but not any particular order.
Finally, it should be noted that the above-mentioned embodiments are merely for illustrating the technical solution of the present invention and not for limiting the same, and although the present invention has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications and equivalents may be made to the technical solution of the present invention without departing from the spirit and scope of the technical solution of the present invention.

Claims (8)

1. A thread control method based on cloud monitoring, the method comprising:
The method comprises the steps of configuring an initial maximum thread number in advance according to an initial configuration file of a system, and determining the initial maximum thread number as the current maximum thread number of the system;
The process information of the application program currently running in the system is obtained, which comprises the following steps: collecting the process information according to preset time;
acquiring the current bus thread number of the application program according to the process information;
Calculating the current thread utilization rate according to the current maximum thread number and the current bus thread number;
judging whether the calculated current thread utilization rate is larger than a preset thread utilization rate threshold value or not;
When the calculated current thread usage is greater than a preset thread usage threshold, reconfiguring the current maximum number of threads of the system according to a preset thread configuration policy, wherein the preset thread configuration policy is to determine the current maximum number of threads of the system according to the current number of bus threads used by the system and a preset thread configuration range, and the method comprises the following steps: determining the maximum value of the current maximum thread number of the system according to the current bus thread number and a first preset value of the preset thread configuration range; determining the minimum value of the current maximum thread number of the system according to the current bus thread number and a second preset value of the preset thread configuration range; an integer value is randomly selected between the minimum value and the maximum value of the determined current maximum thread number of the system, and the selected integer value is configured as the current maximum thread number.
2. The method of claim 1, wherein the obtaining the current number of bus threads used by the application from the process information comprises:
Acquiring all application programs running currently;
Acquiring the thread number used by each application program from the process information corresponding to each running application program;
And accumulating the thread number used by each application program to obtain the total thread number used by the currently running application program.
3. The method of claim 1, wherein prior to the obtaining process information for an application currently running on the system, the method further comprises:
Detecting whether an established thread exists in the system currently;
If the system currently has an established thread, acquiring the process information of an application program currently operated by the system;
If the system does not currently have an established thread, waiting for the next acquisition period to acquire the process information of the application program currently running by the system.
4. The method of claim 1, wherein in the acquiring process information of an application currently running on the system, the method further comprises:
and generating a monitoring information display interface, and displaying the process information of the application program and the thread information correspondingly used.
5. The method according to any one of claims 1 to 4, wherein acquiring process information of an application currently running in the system includes:
Acquiring an application instance name of an application program from an environment configuration file of the application program;
And acquiring the process information of the application program currently operated by the system according to the application instance name.
6. A thread control device based on cloud monitoring, the device comprising:
the first configuration module is used for configuring an initial maximum thread number in advance according to an initial configuration file of the system, and determining the initial maximum thread number as the current maximum thread number of the system;
The first obtaining module is configured to obtain process information of an application program currently running in the system, and includes: collecting the process information according to preset time;
The second acquisition module is used for acquiring the current bus process number of the application program according to the process information;
The calculation module is used for calculating the current thread utilization rate according to the current maximum thread number and the current bus thread number;
the judging module is used for judging whether the calculated current thread utilization rate is larger than a preset thread utilization rate threshold value;
The second configuration module is configured to reconfigure a current maximum number of threads of the system according to a preset thread configuration policy when the judgment module judges that the calculated current thread usage is greater than a preset thread usage threshold, where the preset thread configuration policy is to determine a current maximum number of threads range of the system according to a current number of bus threads used by the system and a preset thread configuration range, and includes: determining the maximum value of the current maximum thread number of the system according to the current bus thread number and a first preset value of the preset thread configuration range; determining the minimum value of the current maximum thread number of the system according to the current bus thread number and a second preset value of the preset thread configuration range; an integer value is randomly selected between the minimum value and the maximum value of the determined current maximum thread number of the system, and the selected integer value is configured as the current maximum thread number.
7. An electronic device, characterized in that the electronic device comprises a processor and a memory, the processor being configured to implement the cloud monitoring-based thread control method according to any one of claims 1 to 5 when executing a computer program stored in the memory.
8. A computer-readable storage medium, on which a computer program is stored, characterized in that the computer program, when executed by a processor, implements the thread control method based on cloud monitoring as claimed in any one of claims 1 to 5.
CN201811537777.6A 2018-12-15 2018-12-15 Thread control method and device based on cloud monitoring, electronic equipment and storage medium Active CN109840141B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811537777.6A CN109840141B (en) 2018-12-15 2018-12-15 Thread control method and device based on cloud monitoring, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811537777.6A CN109840141B (en) 2018-12-15 2018-12-15 Thread control method and device based on cloud monitoring, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN109840141A CN109840141A (en) 2019-06-04
CN109840141B true CN109840141B (en) 2024-05-03

Family

ID=66883282

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811537777.6A Active CN109840141B (en) 2018-12-15 2018-12-15 Thread control method and device based on cloud monitoring, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109840141B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110377480A (en) * 2019-06-17 2019-10-25 百度(中国)有限公司 Monitoring process method, device, system and computer readable storage medium
CN113064620B (en) * 2021-04-02 2024-12-27 北京天空卫士网络安全技术有限公司 A method and device for processing system data
CN113778824B (en) * 2021-08-23 2024-08-23 深圳市联影高端医疗装备创新研究院 Method and device for detecting real-time performance of operating system, computer equipment and storage medium
CN114003367B (en) * 2022-01-04 2022-03-15 北京新唐思创教育科技有限公司 Risk monitoring method, device, equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9354931B1 (en) * 2015-05-14 2016-05-31 Tmaxsoft, Co., Ltd. Method, server and computer-readable recording medium for managing size of thread pool dynamically
CN106385341A (en) * 2016-08-31 2017-02-08 福建天晴数码有限公司 Thread monitoring method and system of client
CN107220033A (en) * 2017-07-05 2017-09-29 百度在线网络技术(北京)有限公司 Method and apparatus for controlling thread pool thread quantity
CN107463441A (en) * 2017-06-30 2017-12-12 大唐软件技术股份有限公司 A kind of number of threads control method and equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9354931B1 (en) * 2015-05-14 2016-05-31 Tmaxsoft, Co., Ltd. Method, server and computer-readable recording medium for managing size of thread pool dynamically
CN106385341A (en) * 2016-08-31 2017-02-08 福建天晴数码有限公司 Thread monitoring method and system of client
CN107463441A (en) * 2017-06-30 2017-12-12 大唐软件技术股份有限公司 A kind of number of threads control method and equipment
CN107220033A (en) * 2017-07-05 2017-09-29 百度在线网络技术(北京)有限公司 Method and apparatus for controlling thread pool thread quantity

Also Published As

Publication number Publication date
CN109840141A (en) 2019-06-04

Similar Documents

Publication Publication Date Title
CN109840142B (en) Thread control method and device based on cloud monitoring, electronic equipment and storage medium
CN109840141B (en) Thread control method and device based on cloud monitoring, electronic equipment and storage medium
US12155543B2 (en) Automatic capture of detailed analysis information based on remote server analysis
US10523580B2 (en) Automatic cloud provisioning based on related internet news and social network trends
US10419305B2 (en) Visualization of workload distribution on server resources
CN109800261B (en) Dynamic control method and device for double-database connection pool and related equipment
US11436231B2 (en) Continuous query scheduling and splitting in a cluster-based data storage system
CN109815007A (en) Thread control method, device, electronic device and storage medium based on cloud monitoring
CN111796824A (en) Page loading method, device, server and medium
CN110427258B (en) Resource scheduling control method and device based on cloud platform
US20120089724A1 (en) Diagnosis of application server performance problems via thread level pattern analysis
CN112100034A (en) Service monitoring method and device
CN110347546B (en) Dynamic adjustment method, device, medium and electronic equipment for monitoring task
CN109766238B (en) Session number-based operation and maintenance platform performance monitoring method and device and related equipment
CN108809770A (en) A kind of resource monitoring method and system
CN110569114B (en) Service processing method, device, equipment and storage medium
CN113127187A (en) Method and apparatus for cluster scale-up
CN113656173A (en) Cloud desktop resource configuration method and device and electronic equipment
US10896056B2 (en) Cluster expansion method and apparatus, electronic device and storage medium
US20180314615A1 (en) Collecting hardware performance data
CN118331751A (en) Computing resource allocation method, computer program, device and medium
CN112817687A (en) Data synchronization method and device
CN109298974B (en) System control method, device, computer and computer readable storage medium
JP2013239124A (en) Terminal control system, terminal management device, terminal control device, terminal control method, terminal management program, and terminal control program
CN111694628A (en) Page display method based on application program thread and related equipment

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
GR01 Patent grant
GR01 Patent grant