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

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

Info

Publication number
CN109840141A
CN109840141A CN201811537777.6A CN201811537777A CN109840141A CN 109840141 A CN109840141 A CN 109840141A CN 201811537777 A CN201811537777 A CN 201811537777A CN 109840141 A CN109840141 A CN 109840141A
Authority
CN
China
Prior art keywords
thread
application program
current
count
progress 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.)
Pending
Application number
CN201811537777.6A
Other languages
Chinese (zh)
Inventor
陈东杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
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/CN109840141A/en
Publication of CN109840141A publication Critical patent/CN109840141A/en
Pending legal-status Critical Current

Links

Abstract

A kind of thread control method based on cloud monitoring, comprising: configure initial maximum Thread Count previously according to the initial configuration file of system, the initial maximum Thread Count is determined as the current maximum thread of system;The progress information of the currently running application program of acquisition system and the currently used total Thread Count of the application program;According to current maximum thread and currently used total Thread Count, current thread utilization rate is calculated;Judge whether current thread utilization rate is greater than default thread utilization rate threshold value;When current thread utilization rate is greater than default thread utilization rate threshold value, according to default thread configuration strategy, the current maximum thread of system is reconfigured.The present invention also provides a kind of thread control device, electronic equipment and storage mediums based on cloud monitoring.The present invention can be monitored by cloud, when the operating status of system changes, realized the real-time adjusting of maximum thread, be ensure that the utilization that system resource can utmostly be rationalized.

Description

Thread control method, device, electronic equipment and storage medium based on cloud monitoring
Technical field
The present invention relates to field of computer technology, and in particular to it is a kind of based on cloud monitoring thread control method, device, electricity Sub- equipment and storage medium.
Background technique
In computer system, it will use various system resources and carry out task processing, when there is task to need to handle, system meeting The request of access appointing system resource is received, system establishes thread to the request, then utilizes established thread to the request It is handled.In order to make full use of system resource, it will usually realize the parallel processing to multiple requests using multithreading.So And excessively high number of threads can cause excessive resource consumption on inessential task operating because of contention for resources, thread switching etc., So that system causes system unstable because resource consumption is excessive, the efficiency handled request is influenced.Therefore, it is necessary to line Number of passes amount is controlled such that the utilization of resources is optimal.
In the prior art, a maximum thread amount usually is set, and controls currently-established when system starts Number of threads realizes thread control no more than the pre-set maximum thread amount of institute.
However, when system operation load is larger, if continue basis presets maximum thread in the prior art Number, establishes thread according to maximum thread, it is possible that pre-set maximum thread is larger, leads to the thread established Quantity excessively causes system unstable, or will appear that pre-set maximum thread is smaller, leads to the number of threads established It is very few to cause system operation stuck, and then influence the resource utilization of system.
Summary of the invention
In view of the foregoing, it is necessary to propose a kind of thread control method based on cloud monitoring, device, electronic equipment and deposit Storage media can be monitored by cloud, when the operating status of system changes, realize the real-time adjusting of maximum thread, be protected The utilization that system resource can utmostly be rationalized is demonstrate,proved.
The first aspect of the present invention provides a kind of thread control method based on cloud monitoring, which comprises
Initial maximum Thread Count is configured previously according to the initial configuration file of system, the initial maximum Thread Count is determined For the current maximum thread of system;
The progress information of the currently running application program of acquisition system;
The currently used total Thread Count of the application program is obtained according to the progress information;
According to the current maximum thread and currently used total Thread Count, current thread utilization rate is calculated;
Judge whether current thread utilization rate calculated is greater than default thread utilization rate threshold value;
When current thread utilization rate calculated is greater than default thread utilization rate threshold value, according to default thread configuration plan Slightly, the current maximum thread of system is reconfigured.
According to a preferred embodiment of the present invention, the default thread configuration strategy is according to currently used total of system Thread Count and default thread configuration range determine the current maximum thread range of system.
According to a preferred embodiment of the present invention, described to be matched according to the currently used total Thread Count of system and default thread It sets range and determines that the current maximum thread range of system includes:
According to currently used total Thread Count and the first preset value of the default thread configuration range, system is determined The maximum value of current maximum thread;
According to currently used total Thread Count and the second preset value of the default thread configuration range, system is determined The minimum value of current maximum thread;
Select an integer value at random between the minimum value and maximum value of the current maximum thread of identified system, it will The integer value selected is configured to the current maximum thread.
According to a preferred embodiment of the present invention, described currently to be made according to the progress information acquisition application program Include: with total Thread Count
Obtain currently running all application programs;
The Thread Count that each application program uses is obtained from the corresponding progress information of application program of each operation;
The Thread Count that each application program uses is added up, total thread that currently running application program uses is obtained Number.
According to a preferred embodiment of the present invention, in the progress information of the currently running application program of acquisition system Before, the method also includes:
Detection system currently whether there is established thread;
If there is currently established threads for system, the progress information of the currently running application program of system is obtained;
If there is currently no established threads for system, next acquisition period is waited to obtain system currently running The process of application program is believed.
According to a preferred embodiment of the present invention, in the progress information of the currently running application program of acquisition system When, the method also includes:
It generates monitoring information and shows interface, show the progress information and corresponding used thread letter of the application program Breath.
According to a preferred embodiment of the present invention, the progress information of the currently running application program of acquisition system includes:
The application example title of the application program is obtained from the environment profile of application program;
According to the progress information of the currently running application program of application example title acquisition system.
Second aspect of the present invention provides a kind of thread control device based on cloud monitoring, and described device includes:
First configuration module configures initial maximum Thread Count for the initial configuration file previously according to system, will be described Initial maximum Thread Count is determined as the current maximum thread of system;
First obtains module, for obtaining the progress information of the currently running application program of system;
Second obtains module, for obtaining the currently used total Thread Count of the application program according to the progress information;
Computing module, for calculating current according to the current maximum thread and currently used total Thread Count Thread utilization rate;
Judgment module, for judging whether current thread utilization rate calculated is greater than default thread utilization rate threshold value;
Second configuration module, for judging that current thread utilization rate calculated is greater than default thread when the judgment module When utilization rate threshold value, according to default thread configuration strategy, the current maximum thread of system is reconfigured.
The third aspect of the present invention provides a kind of electronic equipment, and the electronic equipment includes processor and memory, described Processor realizes the thread controlling party based on cloud monitoring when being used to execute the computer program stored in the memory Method.
The fourth aspect of the present invention provides a kind of computer readable storage medium, deposits on the computer readable storage medium Computer program is contained, the thread controlling party based on cloud monitoring is realized when the computer program is executed by processor Method.
Thread control method, device, electronic equipment and storage medium provided in an embodiment of the present invention based on cloud monitoring, is obtained The initial configuration file for taking system, using the initial maximum Thread Count determined according to initial configuration file the maximum current as system Thread Count, meanwhile, after system runs application program, the progress information of the currently running application program of system is obtained, from process The currently used total Thread Count of the application program is obtained in information;According to the current maximum thread and described currently used Total Thread Count, calculate current thread utilization rate;Determining, calculated current thread utilization rate is greater than default thread and uses When rate threshold value, maximum thread is reconfigured.It can be monitored by cloud, the line used in the currently running application program of system When number of passes changes, that is, it can be achieved that the real-time adjusting of maximum thread, ensure that system when the operating status of system changes The utilization that resource can utmostly be rationalized is able to maintain resource utilization ratio optimal, avoids reconfiguring Thread Count is excessive to result in waste of resources, and the Thread Count of configuration is too small to cause system fluctuation of service.Reconfigure reasonable thread Number can effectively ensure that system operates normally and can save system resource.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this The embodiment of invention for those of ordinary skill in the art without creative efforts, can also basis The attached drawing of offer obtains other attached drawings.
Fig. 1 is the flow chart for the thread control method based on cloud monitoring that the embodiment of the present invention one provides.
Fig. 2 is the functional block diagram of the thread control device provided by Embodiment 2 of the present invention based on cloud monitoring.
Fig. 3 is the schematic diagram for the electronic equipment that the embodiment of the present invention three provides.
The present invention that the following detailed description will be further explained with reference to the above drawings.
Specific embodiment
To better understand the objects, features and advantages of the present invention, with reference to the accompanying drawing and specific real Applying example, the present invention will be described in detail.It should be noted that in the absence of conflict, the embodiment of the present invention and embodiment In feature can be combined with each other.
In the following description, numerous specific details are set forth in order to facilitate a full understanding of the present invention, described embodiment is only It is only a part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, ordinary skill Personnel's every other embodiment obtained without making creative work, shall fall within the protection scope of the present invention.
Unless otherwise defined, all technical and scientific terms used herein and belong to technical field of the invention The normally understood meaning of technical staff is identical.Term as used herein in the specification of the present invention is intended merely to description tool The purpose of the embodiment of body, it is not intended that in the limitation present invention.
The thread control method application based on cloud monitoring of the embodiment of the present invention in the electronic device, can also be applied in electricity In sub- equipment and the hardware environment being made up of the server that network and the electronic equipment are attached, by server and electricity Sub- equipment executes jointly.Network includes but is not limited to: wide area network, Metropolitan Area Network (MAN) or local area network.
The electronic equipment can be desktop PC, notebook, palm PC and cloud server etc. and calculate electronics Equipment.
The electronic equipment of the thread control method for monitor based on cloud for needs, can be directly in electronic equipment On integrate thread control function based on cloud monitoring provided by method of the invention, or installation is for realizing side of the invention The client of method.For another example, method provided by the present invention can also be with Software Development Kit (Software Development Kit, SDK) form operate on the electronic equipments such as server, thread control function monitor based on cloud is provided in the form of SDK The thread control function monitored based on cloud can be realized by the interface provided in the interface of energy, server or other electronic equipments.
Embodiment one
Fig. 1 is the flow chart for the thread control method based on cloud monitoring that the embodiment of the present invention one provides.It is described to be based on cloud The thread control method of monitoring is monitored the current thread number index of the application program in electronic equipment.According to different need It asks, the execution sequence in the flow chart can change, and certain steps can be omitted.
S11: initial maximum Thread Count is configured previously according to the initial configuration file of system, by the initial maximum Thread Count It is determined as the current maximum thread of system.
System in the present embodiment is computer system, wherein the computer system is by computer hardware and software two It is grouped as.Hardware components may include CPU, memory and external equipment etc., and software section can be computer operation Types of applications program and corresponding document.Computer system can receive and store information, quickly calculated and judged by program And export processing result.Wherein, configuration file is generally stored in the local hard drive of system, usually may include user The set etc. of setting and file when using system.
Specifically, the initial configuration file previously according to system determines that initial maximum Thread Count may include: to obtain configuration Initial line number of passes in initial configuration file is determined as initial maximum Thread Count by the initial configuration in file.
Configuration file in the present embodiment may include initial configuration file and intermediate configurations file, wherein initial configuration File can be system in development phase pre-set file, and intermediate configurations file produces after can be system operation a period of time Raw history file.Pre-set initial line number of passes is stored in the initial configuration file, which can be out For hair personnel according to the hardware configuration of system, determining one ensures the reasonable value that system can carry.Therefore, it is possible to will initially match The initial line number of passes set in file extracts, as the current maximum thread of system.
S12: the progress information of the currently running application program of system is obtained.
Computer system can run an application program, can also run multiple application programs.The application program can To be java application program.
Each application example of application program corresponds to a process of application program.
In the present embodiment, the progress information of the currently running application program of acquisition system may include:
1) the application example title of application program is obtained from the environment profile of application program.
The environment profile can be env file.After the environment profile for reading application program, from the ring of reading Application example title spri_lcloud-rmp-prd-ins9740 is obtained in the configuration file of border.
2) according to the progress information of the currently running application program of application example title acquisition system.
The progress information of the application program of acquisition includes the Process identifier (Process of program process Identifier, PID).Process identifier is for distinguishing each process.Process identifier can be a digital number, and such as four The digital number of position.
The progress information of the application program of acquisition can also include program process belonging to application program and including Thread Count.One application program includes a program process, and a program process may include a thread, can also To include multiple threads, i.e., an application program can correspond to one or more thread.
The progress information of the application program of acquisition can also include the state of program process.The state may include Operation, sleep, free time etc..
The progress information of the application program of acquisition can also include the starting time and date of program process, using journey The priority etc. of sequence process.
By springboot-monitor.jar envelope curve journey acquisition method, JVM (Java Virtual is collected Machine, Java Virtual Machine) the inner progress information and thread operating condition.
Qualifications, collecting computer device can be referred to as with the application example name in the operating system command The progress information of currently running application program.For example, the entitled spri_lcloud-rmp-prd-ins9740 of application example, The qualifications that the entitled spri_lcloud-rmp-prd-ins9740 of application example is then added in operating system command, obtain To the progress information of the application program of the entitled spri_lcloud-rmp-prd-ins9740 of application example.
The progress information can be acquired according to preset time.For example, the time for acquiring the progress information can be set Interval (such as every 10 minutes primary) acquires the progress information according to the time interval.For another example, it can be set described in acquisition The specific time (such as each integral point time, such as 0 point, 1 point, 2 points) of progress information, according to the specific time acquisition it is described into Journey information.
The progress information of acquisition is possibly stored to specified database.
The specified database can be time series databases (i.e. time series database), such as OpenTSDB, nfluxDB.Time series databases are mainly used for referring to that processing (changes, i.e. time series with time tag according to the sequence of time Change) data, the data with time tag are also referred to as time series data.
OpenTSDB is distributed, the telescopic time series databases based on Hbase.Store OpenTSDB's Data are as unit of metric, and metric is exactly 1 monitored item, such as CPU usage.OpenTSDB is made using HBase The data storage of metric is supported to second rank due to there is good design for storage.OpenTSDB supports data forever Storage, that is, the data saved will not be deleted actively long;And initial data can save always (some monitoring systems can will relatively long it It is saved after preceding data aggregate).
InfluxDB is the distributed timing of an open source, event and achievement data library.InfluxDB is write using Go language, It is relied on without outside.Its design object is to realize the extension of distributed and horizontal extension.InfluxDB has three big characteristics: 1.Time Series (time series): correlation function related to time (minimum as maximum, summation etc.) can be used;2.Metrics (measurement): mass data can be calculated in real time;3.Eevents (event): arbitrary event data is supported.
Preferably, in the progress information of the currently running application program of acquisition system, the method can also be wrapped It includes: generating monitoring information and show interface, show the progress information and corresponding used thread information of the application program.
Can be generated monitoring information show interface, the monitoring information show interface in show the application program into Journey information and corresponding used thread information.
If the program process run in system is multiple, the progress information of available multiple application programs and right Answer used thread information.
In one embodiment, the progress information and correspondence that the application program can be shown by Grafana are made Thread information.The progress information and correspondence that by the acquisition agent of Grafana, can transmit the application program are made Thread information is shown to Grafana platform.
Grafana is a visualization panel (Dashboard), supports various charts and layout to show, supports Graphite, zabbix, InfluxDB, Prometheus and OpenTSDB are as data source.Grafana has characteristics that Flexible graphical option abundant;A variety of styles can be mixed;Support daytime and Night;Support multiple data sources.
S13: the currently used total Thread Count of the application program is obtained according to the progress information.
It is described to include: according to the progress information acquisition currently used total Thread Count of application program in the present embodiment
Obtain currently running all application programs;
The Thread Count that each application program uses is obtained from the corresponding progress information of application program of each operation;
The Thread Count that each application program uses is added up, total thread that currently running application program uses is obtained Number.
Illustratively, it is assumed that system has currently run 5 application programs: application program 1, application program 2, application program 3, Application program 4 and application program 5, wherein 1 currently used 1 thread of application program, 2 currently used 3 threads of application program, 3 currently used 3 threads of application program, 4 currently used 2 threads of application program, 5 currently used 1 threads of application program, then The currently used total Thread Count of the application program of operation is 1+3+3+2+1=10.
S14: it according to the current maximum thread and currently used total Thread Count, calculates current thread and uses Rate.
It should be understood that being that system can carry according to the current maximum thread that the initial configuration file of system determines Thread Count reasonable value, total Thread Count for using of application program of system operation is not exceed the initial maximum Thread Count 's.
Total Thread Count/current maximum thread of current thread utilization rate=currently used.
S15: judge whether current thread utilization rate calculated is greater than default thread utilization rate threshold value.
In the present embodiment, it is energy that the default thread utilization rate threshold value, which is the critical value of pre-set thread utilization rate, Enough guarantee that system is normal and the optimum value of stable operation.Illustratively, the default thread utilization rate threshold value is 80%.
When current thread utilization rate calculated is greater than default thread utilization rate threshold value, S16 is executed.Work as when calculated When preceding thread utilization rate is less than or equal to the default thread utilization rate threshold value, above-mentioned S12 can be repeated.
S16: according to default thread configuration strategy, the current maximum thread of system is reconfigured.
The strategy that thread configuration strategy is pre-set configuration maximum thread is preset in the present embodiment.
The default thread configuration strategy is true according to the currently used total Thread Count of system and default thread configuration range Determine the current maximum thread range of system.
Default thread configuration range is [the first preset value, the second preset value value], and the first preset value is less than the second preset value. Illustratively, the default thread configuration range is [0.7,0.8]
Specifically, the current max line of system is determined according to the currently used total Thread Count of system and default thread configuration range Number of passes range may include:
1) according to currently used total Thread Count and the first preset value of the default thread configuration range, system is determined It unites the maximum value of current maximum thread;
Illustratively, it is assumed that currently used total Thread Count is 10, the first preset value of the default thread configuration range It is 0.7.The maximum value for then determining the current maximum thread of system is 10/0.7=14.28, and being rounded is 15.
2) according to currently used total Thread Count and the second preset value of the default thread configuration range, system is determined It unites the minimum value of current maximum thread;
Illustratively, it is assumed that currently used total Thread Count is 10, the second preset value of the default thread configuration range It is 0.8.The minimum value for then determining the current maximum thread of system is 10/0.8=12.5, and being rounded is 13.
3) integer value is selected at random between the minimum value and maximum value of the current maximum thread of identified system, The current maximum thread is configured by the integer value selected.
Illustratively, the minimum value of the current maximum thread of system is 13, and maximum value 15 can then select 13,14 Hes Any one integer value in 15, as new current maximum thread.
Institute is determined according to the currently used total Thread Count of thread configuration range and system by default thread configuration range The range for the Thread Count that should be reconfigured avoids the Thread Count reconfigured is excessive from resulting in waste of resources, the Thread Count of configuration It is too small to cause system fluctuation of service.Reconfiguring reasonable Thread Count can effectively ensure that system operates normally and can save System resource.
Further, before the progress information of the currently running application program of acquisition system, the method may be used also To include:
Detection system currently whether there is established thread;
If there is currently established threads for system, the progress information of the currently running application program of system is obtained;
If there is currently no established threads for system, next acquisition period is waited to obtain system currently running The process of application program is believed.
Every preset time period obtains the progress information of the currently running application program of system, which is referred to as One acquisition period.
In the embodiment of the present invention, it can be the progress information of the periodic currently running application program of acquisition system, show Example, the progress information of the currently running application program of current system can be obtained at interval of 5 minutes, currently transported in acquisition system Before the progress information of capable application program, can first detection system currently whether there is established thread, if it is present The progress information of the currently running application program of acquisition system;If it does not exist, then waiting next period.The embodiment of the present invention In, the specific time in period is not construed as limiting, when specific implementation, can be set according to actual needs.Setting is reasonable Cycle duration, can be to avoid frequently replacing the problem of current maximum thread influences system work.
In conclusion the number of threads control method that the embodiment of the present invention one provides, the initial configuration of available system File, the initial maximum Thread Count maximum thread current as system that will be determined according to initial configuration file, meanwhile, when being After system operation application program, the progress information of the currently running application program of system is obtained, is answered described in acquisition from progress information With the currently used total Thread Count of program;According to the current maximum thread and currently used total Thread Count, calculate Current thread utilization rate;When determining, calculated current thread utilization rate is greater than default thread utilization rate threshold value, match again Set maximum thread.Can the Thread Count used in the currently running application program of system variation when, that is, the operation shape of system , it can be achieved that the real-time adjusting of maximum thread, ensure that system resource can utmostly be rationalized when state changes Utilization, be able to maintain resource utilization ratio optimal, avoid the Thread Count reconfigured is excessive from resulting in waste of resources, configure Thread Count too small cause system fluctuation of service.Reconfiguring reasonable Thread Count can effectively ensure that system operates normally System resource can be saved again.
In addition, it is program process or operating system process, this hair that the process of traditional host level, which cannot be distinguished, The progress information of the application program of bright available operation obtains application program institute according to the progress information of the application program of operation The thread used, to improve the accuracy of monitoring application program threads utilization rate.To improve configuration maximum thread Accuracy.
The above is only a specific embodiment of the invention, but scope of protection of the present invention is not limited thereto, for For those skilled in the art, without departing from the concept of the premise of the invention, improvement, but these can also be made It all belongs to the scope of protection of the present invention.
Below with reference to the 2nd to 3 figure, respectively to realize it is above-mentioned based on cloud monitoring thread control method electronic equipment function Energy module and hardware configuration are introduced.
Embodiment two
Fig. 2 is the functional block diagram in the thread control device preferred embodiment monitored the present invention is based on cloud.
In some embodiments, the thread control device 20 based on cloud monitoring is run in electronic equipment.The base In cloud monitoring thread control device 20 may include multiple functional modules as composed by program code segments.It is described to be supervised based on cloud The program code of each program segment in the thread control device 20 of control can store in memory, and by least one processing Performed by device, with execution (being detailed in Fig. 1 and its associated description) to the current thread number index of the application program in electronic equipment into Row monitoring.
In the present embodiment, function of the thread control device 20 based on cloud monitoring according to performed by it can be drawn It is divided into multiple functional modules.The functional module may include: that the first configuration module 201, first obtains module 202, shows mould Block 203, second obtains module 204, computing module 205 and the second configuration module 206.The so-called module of the present invention refers to a kind of energy The series of computation machine program segment that reaches performed by least one processor and can complete fixed function, is stored in storage In device.In some embodiments, it will be described in detail in subsequent embodiment about the function of each module.
First configuration module 201 configures initial maximum Thread Count for the initial configuration file previously according to system, by institute It states initial maximum Thread Count and is determined as the current maximum thread of system.
System in the present embodiment is computer system, wherein the computer system is by computer hardware and software two It is grouped as.Hardware components may include CPU, memory and external equipment etc., and software section can be computer operation Types of applications program and corresponding document.Computer system can receive and store information, quickly calculated and judged by program And export processing result.Wherein, configuration file is generally stored in the local hard drive of system, usually may include user The set etc. of setting and file when using system.
Specifically, the initial configuration file previously according to system determines that initial maximum Thread Count may include: to obtain configuration Initial line number of passes in initial configuration file is determined as initial maximum Thread Count by the initial configuration in file.
Configuration file in the present embodiment may include initial configuration file and intermediate configurations file, wherein initial configuration File can be system in development phase pre-set file, and intermediate configurations file produces after can be system operation a period of time Raw history file.Pre-set initial line number of passes is stored in the initial configuration file, which can be out For hair personnel according to the hardware configuration of system, determining one ensures the reasonable value that system can carry.Therefore, it is possible to will initially match The initial line number of passes set in file extracts, as the current maximum thread of system.
First obtains module 202, for obtaining the progress information of the currently running application program of system.
Computer system can run an application program, can also run multiple application programs.The application program can To be java application program.
Each application example of application program corresponds to a process of application program.
In the present embodiment, described first the progress information that module 202 obtains the currently running application program of system is obtained May include:
1) the application example title of application program is obtained from the environment profile of application program.
The environment profile can be env file.After the environment profile for reading application program, from the ring of reading Application example title spri_lcloud-rmp-prd-ins9740 is obtained in the configuration file of border.
2) according to the progress information of the currently running application program of application example title acquisition system.
The progress information of the application program of acquisition includes the Process identifier (Process of program process Identifier, PID).Process identifier is for distinguishing each process.Process identifier can be a digital number, and such as four The digital number of position.
The progress information of the application program of acquisition can also include program process belonging to application program and including Thread Count.One application program includes a program process, and a program process may include a thread, can also To include multiple threads, i.e., an application program can correspond to one or more thread.
The progress information of the application program of acquisition can also include the state of program process.The state may include Operation, sleep, free time etc..
The progress information of the application program of acquisition can also include the starting time and date of program process, using journey The priority etc. of sequence process.
By springboot-monitor.jar envelope curve journey acquisition method, JVM (Java Virtual is collected Machine, Java Virtual Machine) the inner progress information and thread operating condition.
Qualifications, collecting computer device can be referred to as with the application example name in the operating system command The progress information of currently running application program.For example, the entitled spri_lcloud-rmp-prd-ins9740 of application example, The qualifications that the entitled spri_lcloud-rmp-prd-ins9740 of application example is then added in operating system command, obtain To the progress information of the application program of the entitled spri_lcloud-rmp-prd-ins9740 of application example.
The progress information can be acquired according to preset time.For example, the time for acquiring the progress information can be set Interval (such as every 10 minutes primary) acquires the progress information according to the time interval.For another example, it can be set described in acquisition The specific time (such as each integral point time, such as 0 point, 1 point, 2 points) of progress information, according to the specific time acquisition it is described into Journey information.
The progress information of acquisition is possibly stored to specified database.
The specified database can be time series databases (i.e. time series database), such as OpenTSDB, nfluxDB.Time series databases are mainly used for referring to that processing (changes, i.e. time series with time tag according to the sequence of time Change) data, the data with time tag are also referred to as time series data.
OpenTSDB is distributed, the telescopic time series databases based on Hbase.Store OpenTSDB's Data are as unit of metric, and metric is exactly 1 monitored item, such as CPU usage.OpenTSDB is made using HBase The data storage of metric is supported to second rank due to there is good design for storage.OpenTSDB supports data forever Storage, that is, the data saved will not be deleted actively long;And initial data can save always (some monitoring systems can will relatively long it It is saved after preceding data aggregate).
InfluxDB is the distributed timing of an open source, event and achievement data library.InfluxDB is write using Go language, It is relied on without outside.Its design object is to realize the extension of distributed and horizontal extension.InfluxDB has three big characteristics: 1.Time Series (time series): correlation function related to time (minimum as maximum, summation etc.) can be used;2.Metrics (measurement): mass data can be calculated in real time;3.Eevents (event): arbitrary event data is supported.
Preferably, the thread control device 20 based on cloud monitoring can also include: display module 203, in institute When stating the progress information of the 202 currently running application program of acquisition system of the first acquisition module, generates monitoring information and shows interface, Show the progress information and corresponding used thread information of the application program.
Can be generated monitoring information show interface, the monitoring information show interface in show the application program into Journey information and corresponding used thread information.
If the program process run in system is multiple, the progress information of available multiple application programs and right Answer used thread information.
In one embodiment, the progress information and correspondence that the application program can be shown by Grafana are made Thread information.The progress information and correspondence that by the acquisition agent of Grafana, can transmit the application program are made Thread information is shown to Grafana platform.
Grafana is a visualization panel (Dashboard), supports various charts and layout to show, supports Graphite, zabbix, InfluxDB, Prometheus and OpenTSDB are as data source.Grafana has characteristics that Flexible graphical option abundant;A variety of styles can be mixed;Support daytime and Night;Support multiple data sources.
Second obtains module 204, for obtaining the currently used total thread of the application program according to the progress information Number.
It is described to include: according to the progress information acquisition currently used total Thread Count of application program in the present embodiment Obtain currently running all application programs;It is obtained from the corresponding progress information of application program of each operation each using journey The Thread Count that sequence uses;The Thread Count that each application program uses is added up, currently running application program is obtained and uses Total Thread Count.
Illustratively, it is assumed that system has currently run 5 application programs: application program 1, application program 2, application program 3, Application program 4 and application program 5, wherein 1 currently used 1 thread of application program, 2 currently used 3 threads of application program, 3 currently used 3 threads of application program, 4 currently used 2 threads of application program, 5 currently used 1 threads of application program, then The currently used total Thread Count of the application program of operation is 1+3+3+2+1=10.
Computing module 205, for according to the current maximum thread and currently used total Thread Count, calculating to be worked as Preceding thread utilization rate.
It should be understood that being that system can carry according to the current maximum thread that the initial configuration file of system determines Thread Count reasonable value, total Thread Count for using of application program of system operation is not exceed the initial maximum Thread Count 's.
Total Thread Count/current maximum thread of current thread utilization rate=currently used.
Computing module 205, is also used to judge whether current thread utilization rate calculated is greater than default thread utilization rate threshold Value.
In the present embodiment, it is energy that the default thread utilization rate threshold value, which is the critical value of pre-set thread utilization rate, Enough guarantee that system is normal and the optimum value of stable operation.Illustratively, the default thread utilization rate threshold value is 80%.
Second configuration module 206, for judging that current thread utilization rate calculated is greater than default line when computing module 205 When journey utilization rate threshold value, according to default thread configuration strategy, the current maximum thread of system is reconfigured.
The strategy that thread configuration strategy is pre-set configuration maximum thread is preset in the present embodiment.
The default thread configuration strategy is true according to the currently used total Thread Count of system and default thread configuration range Determine the current maximum thread range of system.
Default thread configuration range is [the first preset value, the second preset value value], and the first preset value is less than the second preset value. Illustratively, the default thread configuration range is [0.7,0.8]
Specifically, second configuration module 206 is according to the currently used total Thread Count of system and default thread configuration model Enclosing the current maximum thread range of determining system may include:
1) according to currently used total Thread Count and the first preset value of the default thread configuration range, system is determined It unites the maximum value of current maximum thread;
Illustratively, it is assumed that currently used total Thread Count is 10, the first preset value of the default thread configuration range It is 0.7.The maximum value for then determining the current maximum thread of system is 10/0.7=14.28, and being rounded is 15.
2) according to currently used total Thread Count and the second preset value of the default thread configuration range, system is determined It unites the minimum value of current maximum thread;
Illustratively, it is assumed that currently used total Thread Count is 10, the second preset value of the default thread configuration range It is 0.8.The minimum value for then determining the current maximum thread of system is 10/0.8=12.5, and being rounded is 13.
3) integer value is selected at random between the minimum value and maximum value of the current maximum thread of identified system, The current maximum thread is configured by the integer value selected.
Illustratively, the minimum value of the current maximum thread of system is 13, and maximum value 15 can then select 13,14 Hes Any one integer value in 15, as new current maximum thread.
Institute is determined according to the currently used total Thread Count of thread configuration range and system by default thread configuration range The range for the Thread Count that should be reconfigured avoids the Thread Count reconfigured is excessive from resulting in waste of resources, the Thread Count of configuration It is too small to cause system fluctuation of service.Reconfiguring reasonable Thread Count can effectively ensure that system operates normally and can save System resource.
First obtain module 202, be also used to when computing module 205 judge current thread utilization rate calculated be less than or When equal to the default thread utilization rate threshold value, the progress information of the currently running application program of system is obtained.
Further, it is described first obtain module 202 obtain the currently running application program of system progress information it Before, the thread control device 20 based on cloud monitoring can also include:
Detection module currently whether there is established thread for detection system;
Described first obtains module 202, is also used to when there is currently established threads for the detection module detection system When, obtain the progress information of the currently running application program of system;
Described first obtains module 202, is also used to the detection module detection system there is currently no established thread, Next acquisition period is waited to obtain the process letter of the currently running application program of system.
Every preset time period obtains the progress information of the currently running application program of system, which is referred to as One acquisition period.
In the embodiment of the present invention, it can be the progress information of the periodic currently running application program of acquisition system, show Example, the progress information of the currently running application program of current system can be obtained at interval of 5 minutes, currently transported in acquisition system Before the progress information of capable application program, can first detection system currently whether there is established thread, if it is present The progress information of the currently running application program of acquisition system;If it does not exist, then waiting next period.The embodiment of the present invention In, the specific time in period is not construed as limiting, when specific implementation, can be set according to actual needs.Setting is reasonable Cycle duration, can be to avoid frequently replacing the problem of current maximum thread influences system work.
In conclusion number of threads control device provided by Embodiment 2 of the present invention, the initial configuration of available system File, the initial maximum Thread Count maximum thread current as system that will be determined according to initial configuration file, meanwhile, when being After system operation application program, the progress information of the currently running application program of system is obtained, is answered described in acquisition from progress information With the currently used total Thread Count of program;According to the current maximum thread and currently used total Thread Count, calculate Current thread utilization rate;When determining, calculated current thread utilization rate is greater than default thread utilization rate threshold value, match again Set maximum thread.Can the Thread Count used in the currently running application program of system variation when, that is, the operation shape of system , it can be achieved that the real-time adjusting of maximum thread, ensure that system resource can utmostly be rationalized when state changes Utilization, be able to maintain resource utilization ratio optimal, avoid the Thread Count reconfigured is excessive from resulting in waste of resources, configure Thread Count too small cause system fluctuation of service.Reconfiguring reasonable Thread Count can effectively ensure that system operates normally System resource can be saved again.
In addition, it is program process or operating system process, this hair that the process of traditional host level, which cannot be distinguished, The progress information of the application program of bright available operation obtains application program institute according to the progress information of the application program of operation The thread used, to improve the accuracy of monitoring application program threads utilization rate.To improve configuration maximum thread Accuracy.
The above-mentioned integrated unit realized in the form of software function module, can store and computer-readable deposit at one In storage media.Above-mentioned software function module is stored in a storage medium, including some instructions are used so that a computer Electronic equipment (can be personal computer, dual-screen electronic device or network electronic devices etc.) or processor (processor) Execute the part of each embodiment the method for the present invention.
Embodiment three
Fig. 3 is the schematic diagram for the electronic equipment that the embodiment of the present invention three provides.
The electronic equipment 3 includes: memory 31, at least one processor 32, is stored in the memory 31 and can The computer program 33 and at least one communication bus 34 run at least one described processor 32.
At least one described processor 32 realizes the above-mentioned thread control based on cloud monitoring when executing the computer program 33 Step in embodiment of the method processed.
Illustratively, the computer program 33 can be divided into one or more module/units, it is one or Multiple module/units are stored in the memory 31, and are executed by least one described processor 32.It is one or more A module/unit can be the series of computation machine program instruction section that can complete specific function, and the instruction segment is for describing institute State implementation procedure of the computer program 33 in the electronic equipment 3.
The electronic equipment 3 can be desktop PC, notebook, palm PC and cloud server etc. and calculate electronics Equipment.It will be understood by those skilled in the art that the schematic diagram 3 is only the example of electronic equipment 3, structure paired electrons is not set Standby 3 restriction may include components more more or fewer than diagram, perhaps combine certain components or different components, such as The electronic equipment 3 can also include input/output electronic equipment, network insertion electronic equipment, bus etc..
At least one described processor 32 can be central processing unit (Central Processing Unit, CPU), It can also be other general processors, digital signal processor (Digital Signal Processor, DSP), dedicated integrated Circuit (Application Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field- Programmable Gate Array, FPGA) either other programmable logic device, discrete gate or transistor logic, Discrete hardware components etc..The processor 32 can be microprocessor or the processor 32 is also possible to any conventional processor Deng the processor 32 is the control centre of the electronic equipment 3, utilizes various interfaces and the entire electronic equipment 3 of connection Various pieces.
The memory 31 can be used for storing the computer program 33 and/or module/unit, and the processor 32 passes through Operation executes the computer program and/or module/unit being stored in the memory 31, and calls and be stored in memory Data in 31 realize the various functions of the electronic equipment 3.The memory 31 can mainly include storing program area and storage Data field, wherein storing program area can application program needed for storage program area, at least one function (for example sound plays Function, image player function etc.) etc.;Storage data area, which can be stored, uses created data (such as sound according to electronic equipment 3 Frequency evidence, phone directory etc.) etc..In addition, memory 31 may include high-speed random access memory, it can also include non-volatile Memory, such as hard disk, memory, plug-in type hard disk, intelligent memory card (Smart Media Card, SMC), secure digital (Secure Digital, SD) card, flash card (Flash Card), at least one disk memory, flush memory device or other Volatile solid-state part.
If the integrated module/unit of the electronic equipment 3 is realized in the form of SFU software functional unit and as independent Product when selling or using, can store in a computer readable storage medium.Based on this understanding, the present invention is real All or part of the process in existing above-described embodiment method, can also instruct relevant hardware come complete by computer program At the computer program can be stored in a computer readable storage medium, which is being executed by processor When, it can be achieved that the step of above-mentioned each embodiment of the method.Wherein, the computer program includes computer program code, described Computer program code can be source code form, object identification code form, executable file or certain intermediate forms etc..The meter Calculation machine readable medium may include: can carry the computer program code any entity or device, recording medium, USB flash disk, Mobile hard disk, magnetic disk, CD, computer storage, read-only memory (ROM, Read-Only Memory), random access memory Device (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium etc..It needs to illustrate It is that the content that the computer-readable medium includes can be fitted according to the requirement made laws in jurisdiction with patent practice When increase and decrease, such as in certain jurisdictions, according to legislation and patent practice, computer-readable medium does not include electric carrier wave letter Number and telecommunication signal.
In several embodiments provided by the present invention, it should be understood that disclosed server and method can pass through Other modes are realized.For example, server example described above is only schematical, for example, the unit is drawn Point, only a kind of logical function partition, there may be another division manner in actual implementation.
It, can also be in addition, each functional unit in each embodiment of the present invention can integrate in same treatment unit It is that each unit physically exists alone, can also be integrated in same unit with two or more units.Above-mentioned integrated list Member both can take the form of hardware realization, can also realize in the form of hardware adds software function module.
It is obvious to a person skilled in the art that invention is not limited to the details of the above exemplary embodiments, Er Qie In the case where without departing substantially from spirit or essential attributes of the invention, the present invention can be realized in other specific forms.Therefore, no matter From the point of view of which point, the present embodiments are to be considered as illustrative and not restrictive, and the scope of the present invention is by appended power Benefit requires rather than above description limits, it is intended that all by what is fallen within the meaning and scope of the equivalent elements of the claims Variation is included in the present invention.Any reference signs in the claims should not be construed as limiting the involved claims.This Outside, it is clear that one word of " comprising " is not excluded for other units or, odd number is not excluded for plural number.The multiple units stated in system claims Or device can also be implemented through software or hardware by a unit or device.The first, the second equal words are used to indicate name Claim, and does not indicate any particular order.
Finally it should be noted that the above examples are only used to illustrate the technical scheme of the present invention and are not limiting, although reference Preferred embodiment describes the invention in detail, those skilled in the art should understand that, it can be to of the invention Technical solution is modified or equivalent replacement, without departing from the spirit of the technical scheme of the invention range.

Claims (10)

1. a kind of thread control method based on cloud monitoring, which is characterized in that the described method includes:
Previously according to system initial configuration file configure initial maximum Thread Count, the initial maximum Thread Count is determined as be It unites current maximum thread;
The progress information of the currently running application program of acquisition system;
The currently used total Thread Count of the application program is obtained according to the progress information;
According to the current maximum thread and currently used total Thread Count, current thread utilization rate is calculated;
Judge whether current thread utilization rate calculated is greater than default thread utilization rate threshold value;
When current thread utilization rate calculated is greater than default thread utilization rate threshold value, according to default thread configuration strategy, weight The new configuration current maximum thread of system.
2. the method as described in claim 1, which is characterized in that the default thread configuration strategy is currently used according to system Total Thread Count and default thread configuration range determine the current maximum thread range of system.
3. method according to claim 2, which is characterized in that the total Thread Count and default line currently used according to system Journey configuration range determines that the current maximum thread range of system includes:
According to currently used total Thread Count and the first preset value of the default thread configuration range, determine that system is current The maximum value of maximum thread;
According to currently used total Thread Count and the second preset value of the default thread configuration range, determine that system is current The minimum value of maximum thread;
It selects an integer value at random between the minimum value and maximum value of the current maximum thread of identified system, will be chosen The integer value of choosing is configured to the current maximum thread.
4. the method as described in claim 1, which is characterized in that described to be worked as according to the progress information acquisition application program It is preceding to include: using total Thread Count
Obtain currently running all application programs;
The Thread Count that each application program uses is obtained from the corresponding progress information of application program of each operation;
The Thread Count that each application program uses is added up, total Thread Count that currently running application program uses is obtained.
5. the method as described in claim 1, which is characterized in that in the process of the currently running application program of acquisition system Before information, the method also includes:
Detection system currently whether there is established thread;
If there is currently established threads for system, the progress information of the currently running application program of system is obtained;
If there is currently no established threads for system, next acquisition period is waited to obtain the currently running application of system The progress information of program.
6. the method as described in claim 1, which is characterized in that in the process of the currently running application program of acquisition system When information, the method also includes:
It generates monitoring information and shows interface, show the progress information and corresponding used thread information of the application program.
7. the method as described in any one of claim 1 to 6, which is characterized in that it is currently running using journey to obtain system The progress information of sequence includes:
The application example title of the application program is obtained from the environment profile of application program;
According to the progress information of the currently running application program of application example title acquisition system.
8. a kind of thread control device based on cloud monitoring, which is characterized in that described device includes:
First configuration module configures initial maximum Thread Count for the initial configuration file previously according to system, will be described initial Maximum thread is determined as the current maximum thread of system;
First obtains module, for obtaining the progress information of the currently running application program of system;
Second obtains module, for obtaining the currently used total Thread Count of the application program according to the progress information;
Computing module, for calculating current thread according to the current maximum thread and currently used total Thread Count Utilization rate;
Judgment module, for judging whether current thread utilization rate calculated is greater than default thread utilization rate threshold value;
Second configuration module, for judging that current thread utilization rate calculated is greater than default thread and uses when the judgment module When rate threshold value, according to default thread configuration strategy, the current maximum thread of system is reconfigured.
9. a kind of electronic equipment, which is characterized in that the electronic equipment includes processor and memory, and the processor is for holding It realizes when the computer program stored in the row memory and is monitored as claimed in any of claims 1 to 7 in one of claims based on cloud Thread control method.
10. a kind of computer readable storage medium, computer program, feature are stored on the computer readable storage medium It is, realizes when the computer program is executed by processor and monitored as claimed in any of claims 1 to 7 in one of claims based on cloud Thread control method.
CN201811537777.6A 2018-12-15 2018-12-15 Thread control method, device, electronic equipment and storage medium based on cloud monitoring Pending CN109840141A (en)

Priority Applications (1)

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

Applications Claiming Priority (1)

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

Publications (1)

Publication Number Publication Date
CN109840141A true CN109840141A (en) 2019-06-04

Family

ID=66883282

Family Applications (1)

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

Country Status (1)

Country Link
CN (1) CN109840141A (en)

Cited By (3)

* 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
CN113064620A (en) * 2021-04-02 2021-07-02 北京天空卫士网络安全技术有限公司 Method and device for processing system data
CN114003367A (en) * 2022-01-04 2022-02-01 北京新唐思创教育科技有限公司 Risk monitoring method, device, equipment and storage medium

Citations (3)

* 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
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 (3)

* 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
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

Cited By (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
CN113064620A (en) * 2021-04-02 2021-07-02 北京天空卫士网络安全技术有限公司 Method and device for processing system data
CN114003367A (en) * 2022-01-04 2022-02-01 北京新唐思创教育科技有限公司 Risk monitoring method, device, equipment and storage medium
CN114003367B (en) * 2022-01-04 2022-03-15 北京新唐思创教育科技有限公司 Risk monitoring method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN109840142A (en) Thread control method, device, electronic equipment and storage medium based on cloud monitoring
CN109815007A (en) Thread control method, device, electronic equipment and storage medium based on cloud monitoring
Zhu et al. Scheduling stochastic multi-stage jobs to elastic hybrid cloud resources
CN105359057B (en) Setting computer parameters to operate the power supply within a range based on a peak power efficiency of the power supply
CN111738446B (en) Scheduling method, device, equipment and medium of deep learning reasoning engine
CN106557369A (en) A kind of management method and system of multithreading
CN109840141A (en) Thread control method, device, electronic equipment and storage medium based on cloud monitoring
CN111694646A (en) Resource scheduling method and device, electronic equipment and computer readable storage medium
CN103873587B (en) A kind of method and device that scheduling is realized based on cloud platform
CN109800067A (en) Database connection optimization method, device and relevant device based on cloud monitoring
CN108255607A (en) Task processing method, device, electric terminal and readable storage medium storing program for executing
CN109614227A (en) Task resource concocting method, device, electronic equipment and computer-readable medium
CN115373835A (en) Task resource adjusting method and device for Flink cluster and electronic equipment
CN109800261A (en) Dynamic control method, device and the relevant device of double data library connection pool
US20210406053A1 (en) Rightsizing virtual machine deployments in a cloud computing environment
CN115033352A (en) Task scheduling method, device and equipment for multi-core processor and storage medium
CN112801331B (en) Shaping of computational loads with virtual capacity and preferred location real-time scheduling
CN111209333B (en) Data updating method, device, terminal and storage medium
CN115562846A (en) Resource scheduling method and device and computing node
CN115373860B (en) Scheduling method, device and equipment of GPU (graphics processing Unit) tasks and storage medium
CN115952054A (en) Simulation task resource management method, device, equipment and medium
CN116185578A (en) Scheduling method of computing task and executing method of computing task
CN109634812A (en) Process CPU usage control method, terminal device and the storage medium of linux system
CN113296907B (en) Task scheduling processing method, system and computer equipment based on clusters
CN109144838A (en) Method for monitoring application program and device, computer installation and computer storage medium

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