Specific embodiment
Below in conjunction with the attached drawing in the embodiment of the present application, technical solutions in the embodiments of the present application carries out clear, complete
Site preparation description, it is clear that described embodiment is some embodiments of the present application, instead of all the embodiments.Based on this Shen
Please in embodiment, every other implementation obtained by those of ordinary skill in the art without making creative efforts
Example, shall fall in the protection scope of this application.
It should be appreciated that ought use in this specification and in the appended claims, term " includes " and "comprising" instruction
Described feature, entirety, step, operation, the presence of element and/or component, but one or more of the other feature, whole is not precluded
Body, step, operation, the presence or addition of element, component and/or its set.
It is also understood that mesh of the term used in this present specification merely for the sake of description specific embodiment
And be not intended to limit the application.As present specification and it is used in the attached claims, unless on
Other situations are hereafter clearly indicated, otherwise " one " of singular, "one" and "the" are intended to include plural form.
It will be further appreciated that the term "and/or" used in present specification and the appended claims is
Refer to any combination and all possible combinations of one or more of associated item listed, and including these combinations.
The embodiment of the present application provides a kind of delay statistics method, apparatus, distributed system and storage medium.
In order to make it easy to understand, the composition for the distributed system that first the delay statistics method of the embodiment of the present application is applicable in into
Row is introduced.As shown in Figure 1, the distributed system includes multiple servers, also referred to as host.Wherein, server can be independence
Server, be also possible to the server cluster of multiple servers composition.The distributed system includes being deployed on multiple host
Application program (software program) cooperate realize specific function software systems.
Specifically, realize that the delay statistics method includes that two class software entities are completed jointly in a distributed system, two classes
Software entity includes time delay collection module and latency measurement component, and wherein the time delay collection module is deployed in the application of each host
In program, the latency measurement deployment of components is in a wherein host, or individually in server.Wherein latency measurement group
Part can do load segmentation according to collection point, dispose multiple latency measurement components, collection point control time delay according to the data of collection point
Acquisition module, multiple latency measurement components are respectively used to receive the data that different collection points sends over, when which includes
Between stab information, by this way improve time delay acquisition speed.
Referring to Fig. 2, Fig. 2 is a kind of schematic flow diagram for delay statistics method that one embodiment of the application provides.This when
Prolong Application of Statistic Methods in above-mentioned distributed system, as shown in Figure 1, the delay statistics method includes step S101~S105.
S101, acquisition are input to the Data Identification of the target data of the distributed system.
Specifically, the time delay collection module obtains the Data Identification for being input to the target data of the distributed system.
Target data refers to that the data from external input to the distributed system, the data need the master by the distributed system
Application program in machine is processed, and is circulated between each application program, and is possible to generate external output.It is wherein every
A target data includes a Data Identification, for example is identified with D1, D2...Dn, for identification the target data, certainly
It can also be identified with other Data Identifications, it is not limited here.
Default collection point when S102, the acquisition target data are handled by application program by the application program is corresponding
Timestamp and acquisition point identification, the application program is distributed in the different nodes of the distributed system.
Specifically, the time delay collection module acquires when the target data is handled by application program by described using journey
The corresponding timestamp in default collection point and acquisition point identification of sequence.Wherein the default collection point is in advance in the application program
Multiple time collection points are set, and the time collection point is identified, for example application program 1 includes 100 time collection points,
Its corresponding acquisition point identification is respectively T1, T2...T100.Can certainly other modes be identified, it is not limited here.
S103, timestamp information is generated according to the Data Identification, acquisition point identification and timestamp.
Specifically, the time delay collection module generates timestamp according to the Data Identification, acquisition point identification and timestamp
The Data Identification, acquisition point identification and timestamp are specifically packaged as a timestamp information by information together, and when by this
Between stamp information be sent to the latency measurement component.The timestamp information is such as are as follows: D1 T1 9:30:00.123456.Wherein,
D1 is Data Identification, and T1 is acquisition point identification, and 9:30:00.123456 is timestamp.
In one embodiment, described that the timestamp information is sent to after the latency measurement component, further includes: when described
Prolong measurement component to receive the timestamp information after the timestamp information according to the Data Identification and acquisition point identification
In timestamp correspondence be stored in preset data table to generate the timestamp information table.
Specifically, the latency measurement component according to the Data Identification and acquires point identification for the timestamp according to number
It is stored according to identifying and acquiring point identification correspondence to generate timestamp information table in preset data table, the timestamp information table is specific
As shown in table 1, it is more convenient for reading data.
Table 1 is timestamp information table
|
T1 |
T2 |
T3 |
T4 |
D1 |
9:30:00.123456 |
9:30:00.123478 |
9:30:00.126000 |
9:30:00.126456 |
D2 |
9:30:00.234567 |
9:30:00.234678 |
9:30:00.236000 |
9:30:00.236678 |
D3 |
…… |
…… |
…… |
…… |
D4 |
…… |
…… |
…… |
…… |
S104, time delay index allocation file is read, includes time delay indicator-specific statistics rule in the time delay index allocation file.
Specifically, the latency measurement component reads time delay index allocation file, wraps in the time delay index allocation file
Include time delay indicator-specific statistics rule.Wherein the time delay indicator-specific statistics rule is to be pre-configured in the server, can be pre-configured in
In the server that the latency measurement component is located at.The time delay indicator-specific statistics rule is according to timestamp information to the distribution
The statistical rules of system.
For example, the latency measurement component is constantly according to timestamp information according to default statistical rules, such as by the time
End point timestamp and starting point timestamp in stamp information do subtraction to obtain the time delay index value of the data.Certainly
Every time delay index value of different data can also be calculated using other preset rules.In addition, the latency measurement component
Can count in the period every time delay index value by the specified period, including average value, minimum value, maximum value, 50%, 90%,
95%, the percentiles such as 99%, while also counting the throughput in the specified period on each time delay collection point.
S105, it is based on the time delay indicator-specific statistics rule, the distributed system is counted according to the timestamp information
Time delay.
Specifically, the latency measurement component is based on the time delay indicator-specific statistics rule, is united according to the timestamp information
Count the time delay of the distributed system.The time delay indicator-specific statistics rule includes multiple time delay index calculation formula, for example, end point
Timestamp and starting point timestamp do the time delay index of subtraction, naturally it is also possible to including average value, minimum value, maximum value,
50%, the percentiles such as 90%, 95%, 99%.
Based on this, step S105 includes S1051 and S105b.As shown in figure 3, S105a, the acquisition time delay indicator-specific statistics
Time delay index calculation formula in rule;S105b, it is corresponded to according to the time delay index calculation formula calculating timestamp information
Time delay index.It is possible thereby to calculate various time delay achievement datas.
In one embodiment, the timestamp information table includes time delay index position, described according to the time delay index meter
Calculation formula calculates after the corresponding time delay index of the timestamp information, further includes: when the time delay index is indexed to described
Between stab information table in time delay index position the time delay index is stored in the timestamp information table.This is checked so as to subsequent
Time delay index, or do picture using the time delay index and show.
Specifically, the time delay index is stored in the timestamp information table, is expressed as information index table, such as 2 institute of table
Show.
Table 2 is information index table
Referring to Fig. 4, Fig. 4 is a kind of application scenarios schematic diagram of delay statistics method provided by the embodiments of the present application.Fig. 4
It is the schematic diagram of a scenario of the one of host of distributed system, includes application program, the time delay collection template in the host
In the application, target data is input to by isolated operation in the latency measurement deployment of components server in outside for deployment
When the application program of distributed system, time delay collection template obtains the data mark for being input to the target data of the distributed system
Know, such as Data Identification D1 or D2;Target data acquires when the target data is handled by application program by described using journey
The corresponding timestamp in default collection point and acquisition point identification of sequence, acquisition point identification is such as are as follows: T1 and T2, corresponding timestamp ratio
Such as are as follows: 9:30:00.123456 and 9:30:00.123478;Time delay collection template according to the Data Identification, acquisition point identification and
The Data Identification, acquisition point identification and timestamp are generated timestamp information by timestamp, and the collection point is determined will
The timestamp information is sent to multiple time delay collection components or a time delay collection component, thus improves time delay processing speed;
Time delay collection module reads time delay index allocation file, includes time delay indicator-specific statistics rule in the time delay index allocation file,
And based on the time delay indicator-specific statistics rule, the time delay of the distributed system is counted according to the timestamp information, is calculated
Various time delay indexs are checked so as to subsequent output.
In the present embodiment, which is input to the number of the target data of the distributed system by obtaining
According to mark;Acquire the default collection point corresponding time when target data is handled by application program by the application program
Stamp and acquisition point identification, the application program are distributed in the different nodes of the distributed system;According to the Data Identification, adopt
Collect point identification and timestamp generates timestamp information;Time delay index allocation file is read, is wrapped in the time delay index allocation file
Include time delay indicator-specific statistics rule;Based on the time delay indicator-specific statistics rule, the distribution is counted according to the timestamp information
The time delay of system.The delay statistics method may be implemented the time delay of distributed system and the automatic collection of handling capacity, measurement and
Statistics.
Referring to Fig. 5, Fig. 5 is a kind of schematic flow diagram for delay statistics method that one embodiment of the application provides.This when
Prolong Application of Statistic Methods in above-mentioned distributed system, as shown in figure 5, the delay statistics method includes step S201~S208.
S201, the sample data for being input to the distributed system is filtered out according to default screening rule.
Wherein, step S201 includes the steps that data screening, as shown in fig. 6, the step specifically includes the following contents:
S201a, the data for being input to the distributed system are counted according to default counter;S201b, judge the counting pair
Whether the count number answered meets preset condition;If S201c, the count number meet the preset condition, it is determined that described
The corresponding data of count number are to input the sample data of the distributed system.
Specifically, a counter is set in the application in advance, by the calculator to being input to the distribution
The data of system carry out calculating label.Judge whether the corresponding count number of the counting meets preset condition.For example, to calculating
Quantity carries out modular arithmetic to 100, and n is count number, and n%100=0 is to meet the preset condition.For another example, number of computations is
It can be to meet the preset condition when odd number or even number etc..If the count number meets the preset condition, it is determined that institute
Stating the corresponding data of count number is to input the sample data of the distributed system.The step of passing through data screening can have choosing
Delay statistics and measurement are carried out to partial data with selecting, avoid acquiring excessive data and resulting in waste of resources.
Certainly, in other embodiments, data can also be screened otherwise, for example, it is specified to certain data into
Row acquisition.
S202, the sample data is set as to target data, and adds data mark in the message header of the target data
Know.
Specifically, it using determining sample data as target data, while being added in the message header of the target data
Data Identification, to obtain the Data Identification for being input to the target data of the distributed system in step S103.
S203, acquisition are input to the Data Identification of the target data of the distributed system.
Specifically, the target data refers to the data from external input to the distributed system, the data need through
The application program crossed in the host of the distributed system is processed, and is circulated between each application program, and having can
Externally output can be generated, wherein each target data includes a Data Identification.
Default collection point when S204, the acquisition target data are handled by application program by the application program is corresponding
Timestamp and acquisition point identification, the application program is distributed in the different nodes of the distributed system.
Specifically, the time delay collection module acquires when the target data is handled by application program by described using journey
The corresponding timestamp in default collection point and acquisition point identification of sequence.Wherein the default collection point is in advance in the application program
Multiple time collection points are set, and the time collection point is identified.
S205, timestamp information is generated according to the Data Identification, acquisition point identification and timestamp.
Specifically, the time delay collection module generates timestamp according to the Data Identification, acquisition point identification and timestamp
The Data Identification, acquisition point identification and timestamp are specifically packaged as a timestamp information by information together, and when by this
Between stamp information be sent to the latency measurement component.
S206, time delay index allocation file is read, includes time delay indicator-specific statistics rule in the time delay index allocation file.
Specifically, the latency measurement component reads time delay index allocation file, wraps in the time delay index allocation file
Include time delay indicator-specific statistics rule.Wherein the time delay indicator-specific statistics rule is to be pre-configured in the server, can be pre-configured in
In the server that the latency measurement component is located at.The time delay indicator-specific statistics rule is according to timestamp information to the distribution
The statistical rules of system.
S207, it is based on the time delay indicator-specific statistics rule, the distributed system is counted according to the timestamp information
Time delay.
Specifically, the latency measurement component is based on the time delay indicator-specific statistics rule, is united according to the timestamp information
Count the time delay of the distributed system.The time delay indicator-specific statistics rule includes multiple time delay index calculation formula, for example, end point
Timestamp and starting point timestamp do the time delay index of subtraction, naturally it is also possible to including average value, minimum value, maximum value,
50%, the percentiles such as 90%, 95%, 99%.
S208, the corresponding statistical result of time delay that the distributed system is counted according to default output rule output.
Specifically, the default output rule, which refers to, exports the statistical result according to default output form, should
Default output form includes three kinds of form outputs, is respectively as follows: 1, statistical result rolling is output to order line console;It 2, will system
Meter result is output to file, and the statistical value of every time delay index of each measurement period of additional record, can also remember in this document
Record every time delay index value of every data;3, latency measurement component embed Http server, can receive from browser or its
The Http access request of his program, according to the access request the backward reference in the form of Json character string of current statistical result
Person.
Fig. 7 is a kind of schematic block diagram of delay statistics device provided by the embodiments of the present application.As shown in fig. 7, corresponding to
The above delay statistics method, the application also provide a kind of delay statistics device.The delay statistics device includes above-mentioned for executing
The unit of delay statistics method, the device can be configured in server.
Wherein, as shown in fig. 7, delay statistics device 400 includes: data screening unit 401, mark adding unit 402, mark
Know acquiring unit 403, information acquisition unit 404, information generating unit 405, document reading unit 406, delay statistics unit 407
With result output unit 408.
Data screening unit 401, for filtering out the sample for being input to the distributed system according to default screening rule
Data.
Adding unit 402 is identified, for the sample data to be set as target data, and in the message of the target data
Data Identification is added in head.
Mark acquiring unit 403, for obtaining the Data Identification for being input to the target data of the distributed system.
Information acquisition unit 404, for acquiring when the target data is handled by application program by the application program
The corresponding timestamp in default collection point and acquisition point identification, the application program is distributed in the different sections of the distributed system
Point.
Information generating unit 405, for generating timestamp letter according to the Data Identification, acquisition point identification and timestamp
Breath.
Document reading unit 406, for reading time delay index allocation file, when including in the time delay index allocation file
Prolong indicator-specific statistics rule.
Delay statistics unit 407, for counting institute according to the timestamp information based on the time delay indicator-specific statistics rule
State the time delay of distributed system.
As a result output unit 408, the time delay for counting the distributed system according to default output rule output are corresponding
Statistical result.
It is apparent to those skilled in the art that for convenience of description and succinctly, foregoing description when
The specific work process for prolonging statistic device and unit, can refer to corresponding processes in the foregoing method embodiment, no longer superfluous herein
It states.
Above-mentioned apparatus can be implemented as a kind of form of computer program, and computer program can be in meter as shown in Figure 8
It calculates and is run on machine equipment.
Referring to Fig. 8, Fig. 8 is a kind of schematic block diagram of computer equipment provided by the embodiments of the present application.The computer
Equipment 700 can be server.
Referring to Fig. 8, which includes processor 720, memory and the net connected by system bus 710
Network interface 750, wherein memory may include non-volatile memory medium 730 and built-in storage 740.
The non-volatile memory medium 730 can storage program area 731 and computer program 732.The computer program 732
It is performed, processor 720 may make to execute any one delay statistics method.
The processor 720 supports the operation of entire computer equipment 700 for providing calculating and control ability.
The built-in storage 740 provides environment for the operation of the computer program 732 in non-volatile memory medium 730, should
When computer program 732 is executed by processor 720, processor 720 may make to execute any one delay statistics method.
The network interface 750 such as sends the task dispatching of distribution for carrying out network communication.Those skilled in the art can manage
It solves, structure shown in Fig. 8, only the block diagram of part-structure relevant to application scheme, is not constituted to the application side
The restriction for the computer equipment 700 that case is applied thereon, specific computer equipment 700 may include more than as shown in the figure
Or less component, perhaps combine certain components or with different component layouts.Wherein, the processor 720 is for transporting
Row program code stored in memory, to realize following steps:
Obtain the Data Identification for being input to the target data of the distributed system;The target data is acquired by using journey
The corresponding timestamp in default collection point and acquisition point identification when sequence processing by the application program, the application program distribution
In the different nodes of the distributed system;Timestamp information is generated according to the Data Identification, acquisition point identification and timestamp;
Time delay index allocation file is read, includes time delay indicator-specific statistics rule in the time delay index allocation file;Based on the time delay
Indicator-specific statistics rule, the time delay of the distributed system is counted according to the timestamp information.
In one embodiment, the processor 720 obtains described in program code realization stored in memory for running
Before the Data Identification for taking the target data for being input to the distributed system, following steps are also realized:
The sample data for being input to the distributed system is filtered out according to default screening rule;The sample data is set
For target data, and Data Identification is added in the message header of the target data.
In one embodiment, the processor 720 realizes described for running program code stored in memory
The sample data for being input to the distributed system is filtered out according to default screening rule, is implemented as follows step:
The data for being input to the distributed system are counted according to default counter;Judge that the counting is corresponding
Whether count number meets preset condition;If the count number meets the preset condition, it is determined that the count number pair
The data answered are to input the sample data of the distributed system.
In one embodiment, the processor 720 realizes the base for running program code stored in memory
In the time delay indicator-specific statistics rule, the when delay of the distributed system is counted according to the timestamp information, is implemented
Following steps:
Obtain the time delay index calculation formula in the time delay indicator-specific statistics rule;According to the time delay index calculation formula
Calculate the corresponding time delay index of the timestamp information.
In one embodiment, the processor 720 realizes described for running program code stored in memory
When generating timestamp information according to the Data Identification, acquisition point identification and timestamp, it is implemented as follows step:
According to the Data Identification with acquisition point identification by the timestamp it is corresponding be stored in preset data table with generation
The timestamp information table.
In one embodiment, the processor 720 realizes the base for running program code stored in memory
After the time delay indicator-specific statistics rule, the time delay that the distributed system is counted according to the timestamp information, also realize
Following steps:
The corresponding statistical result of time delay of the distributed system is counted according to default output rule output.
In one embodiment, the processor 720 realizes described for running program code stored in memory
When statistical result corresponding according to the time delay of the default output rule output statistics distributed system, it is implemented as follows step:
Receive Http access request, according to the Http access request by the statistical result with Json character string forms into
Row returns.
It should be appreciated that in the embodiment of the present application, processor 720 can be central processing unit (Central
Processing Unit, CPU), which can also be other general processors, digital signal processor (Digital
Signal Processor, DSP), specific integrated circuit (Application Specific Integrated Circuit,
ASIC), ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic
Device, discrete gate or transistor logic, discrete hardware components etc..Wherein, general processor can be microprocessor or
Person's processor is also possible to any conventional processor etc..
It will be understood by those skilled in the art that 700 structure of computer equipment shown in Fig. 8 is not constituted and is set to computer
Standby 700 restriction may include perhaps combining certain components or different component cloth than illustrating more or fewer components
It sets.
Those of ordinary skill in the art will appreciate that be realize above-described embodiment method in all or part of the process, be
Relevant hardware can be instructed to complete by computer program, computer program can be stored in a storage medium, this is deposited
Storage media is computer readable storage medium.In the embodiment of the present invention, which can be stored in computer system
It in storage medium, and is executed by least one processor in the computer system, includes the reality such as above-mentioned each method with realization
Apply the process step of example.
The computer readable storage medium can be magnetic disk, CD, USB flash disk, mobile hard disk, read-only memory (ROM, Read-
Only Memory), the various media that can store program code such as magnetic or disk.
Those of ordinary skill in the art may be aware that list described in conjunction with the examples disclosed in the embodiments of the present disclosure
Member and algorithm steps, can be realized with electronic hardware, computer software, or a combination of the two, in order to clearly demonstrate hardware
With the interchangeability of software, each exemplary composition and step are generally described according to function in the above description.This
A little functions are implemented in hardware or software actually, the specific application and design constraint depending on technical solution.Specially
Industry technical staff can use different methods to achieve the described function each specific application, but this realization is not
It is considered as beyond scope of the present application.
In several embodiments provided herein, it should be understood that disclosed delay statistics device and method, it can
To realize by another way.For example, delay statistics Installation practice described above is only schematical.For example,
The division of each unit, only a kind of logical function partition, there may be another division manner in actual implementation.Such as it is multiple
Unit or assembly can be combined or can be integrated into another system, or some features can be ignored or not executed.
Step in the embodiment of the present application method can be sequentially adjusted, merged and deleted according to actual needs.
Unit in the embodiment of the present application device can be combined, divided and deleted according to actual needs.
It, can also be in addition, each functional unit in each embodiment of the application can integrate in one processing unit
It is that each unit physically exists alone, is also possible to two or more units and is integrated in one unit.It is above-mentioned integrated
Unit both can take the form of hardware realization, can also realize in the form of software functional units.
If the integrated unit is realized in the form of SFU software functional unit and when sold or used as an independent product,
It can store in a computer readable storage medium.Based on this understanding, the technical solution of the application substantially or
Person says that all or part of the part that contributes to existing technology or the technical solution can body in the form of software products
Reveal and, which is stored in a storage medium, including some instructions are with so that a computer is set
Standby (can be personal computer, terminal or the network equipment etc.) execute each embodiment the method for the application whole or
Part steps.
The above, the only specific embodiment of the application, but the protection scope of the application is not limited thereto, it is any
Those familiar with the art within the technical scope of the present application, can readily occur in various equivalent modifications or replace
It changes, these modifications or substitutions should all cover within the scope of protection of this application.Therefore, the protection scope of the application should be with right
It is required that protection scope subject to.