Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
it is also to be understood that the terminology used in the description of the present application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the specification of the present application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
it should be further understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
the embodiment of the application provides a time delay statistical method, a time delay statistical device, a distributed system and a storage medium.
for convenience of understanding, the components of the distributed system to which the latency statistics method of the embodiment of the present application is applied will be described first. As shown in fig. 1, the distributed system includes a plurality of servers, also referred to as hosts. The server may be an independent server or a server cluster composed of a plurality of servers. The distributed system includes a software system in which application programs (software programs) deployed on a plurality of hosts cooperate to realize specific functions.
specifically, the method for implementing the time delay statistics in the distributed system includes that two types of software entities are jointly completed, and each type of software entity includes a time delay acquisition module and a time delay measurement component, wherein the time delay acquisition module is deployed in an application program of each host, and the time delay measurement component is deployed in one of the hosts or in a separate server. The time delay measurement assembly can be used for load segmentation according to the acquisition points, a plurality of time delay measurement assemblies are deployed according to data of the acquisition points, the acquisition points control the time delay acquisition module, the time delay measurement assemblies are respectively used for receiving data sent by different acquisition points, the data comprise timestamp information, and the time delay acquisition speed is improved through the method.
Referring to fig. 2, fig. 2 is a schematic flow chart of a delay statistics method according to an embodiment of the present application. The time delay statistical method is applied to the distributed system, as shown in fig. 1, and includes steps S101 to S105.
S101, acquiring a data identifier of target data input into the distributed system.
specifically, the time delay acquisition module acquires a data identifier of target data input to the distributed system. The target data is data input from the outside to the distributed system, and the data needs to be processed by an application program in a host of the distributed system, flows among the application programs, and is possible to generate external output. Each target data includes a data identifier, such as D1, D2... Dn, for identifying the target data, but may also be identified by other data identifiers, which is not limited herein.
s102, collecting a timestamp and a collection point identifier corresponding to a preset collection point of an application program when the target data is processed by the application program, wherein the application program is distributed in different nodes of the distributed system.
specifically, the time delay acquisition module acquires a timestamp and an acquisition point identifier corresponding to a preset acquisition point of the application program when the target data is processed by the application program. The preset acquisition points are a plurality of time acquisition points preset in the application program, and the time acquisition points are identified, for example, the application program 1 includes 100 time acquisition points, and the corresponding acquisition point identifications are T1 and T2.. T100, respectively. The identification may be performed in other ways, and is not limited herein.
And S103, generating time stamp information according to the data identification, the acquisition point identification and the time stamp.
Specifically, the time delay acquisition module generates time stamp information according to the data identifier, the acquisition point identifier and the time stamp, specifically packs the data identifier, the acquisition point identifier and the time stamp together into time stamp information, and sends the time stamp information to the time delay measurement component. The timestamp information is, for example: D1T 19: 30: 00.123456. D1 is a data identifier, T1 is an acquisition point identifier, and 9:30:00.123456 is a time stamp.
In an embodiment, after sending the timestamp information to the latency measurement component, the method further includes: and after receiving the timestamp information, the time delay measurement component correspondingly stores the timestamp in the timestamp information in a preset data table according to the data identifier and the acquisition point identifier so as to generate the timestamp information table.
Specifically, the time delay measurement component correspondingly stores the time stamp in a preset data table according to the data identifier and the collection point identifier to generate a time stamp information table, and the time stamp information table is specifically shown in table 1, so that data reading is facilitated.
TABLE 1 is a time stamp 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, reading a time delay index configuration file, wherein the time delay index configuration file comprises a time delay index statistical rule.
Specifically, the delay measurement component reads a delay index configuration file, where the delay index configuration file includes a delay index statistical rule. The statistical rule of the delay index is pre-configured in a server, and can be pre-configured in the server where the delay measurement component is located. And the time delay index statistical rule is a statistical rule of the distributed system according to the timestamp information.
For example, the delay measurement component continuously subtracts the end point time stamp and the start point time stamp in the time stamp information according to a predetermined statistical rule based on the time stamp information to obtain the delay index value of the data. Of course, other preset rules may be adopted to calculate various delay index values of different data. In addition, the delay measurement component can count various delay index values in a specified period, including percentage bit values such as an average value, a minimum value, a maximum value, 50%, 90%, 95%, 99% and the like, and also count the throughput rate of various delay acquisition points in the specified period.
and S105, counting the time delay of the distributed system according to the timestamp information based on the time delay index counting rule.
specifically, the delay measurement component counts the delay of the distributed system according to the timestamp information based on the delay index statistical rule. The delay index statistical rule includes a plurality of delay index calculation formulas, for example, a delay index obtained by subtracting the end point timestamp and the start point timestamp, and may also include percentile values such as an average value, a minimum value, a maximum value, 50%, 90%, 95%, and 99%.
Based on this, step S105 includes S1051 and S105 b. As shown in fig. 3, S105a, obtaining a calculation formula of the delay index in the statistical rule of the delay index; s105, 105b, calculating the time delay index corresponding to the timestamp information according to the time delay index calculation formula. From which various delay indicator data can be calculated.
In an embodiment, the timestamp information table includes a delay indicator bit, and after the time delay indicator corresponding to the timestamp information is calculated according to the time delay indicator calculation formula, the method further includes: and indexing the time delay index to a time delay index bit in the time stamp information table so as to store the time delay index in the time stamp information table. So as to view the delay index later or use the delay index to make drawing display.
Specifically, the delay index is stored in the timestamp information table and is represented as an information index table, as shown in table 2.
Table 2 is an information index table
Referring to fig. 4, fig. 4 is a schematic view of an application scenario of a latency statistics method according to an embodiment of the present application. Fig. 4 is a schematic view of a scenario of one of the hosts of the distributed system, where the host includes an application program, the latency acquisition template is deployed in the application program, the latency measurement component deployment server runs separately, and when target data is input to the application program of the distributed system from outside, the latency acquisition template acquires a data identifier of the target data input to the distributed system, such as a data identifier D1 or D2; when target data is acquired and processed by an application program, the target data passes through a timestamp and an acquisition point identifier corresponding to a preset acquisition point of the application program, where the acquisition point identifier is, for example: t1 and T2, corresponding timestamps are, for example: 9:30:00.123456 and 9:30: 00.123478; the time delay acquisition template generates time stamp information by using the data identification, the acquisition point identification and the time stamp according to the data identification, the acquisition point identification and the time stamp, and determines the acquisition point to send the time stamp information to a plurality of time delay acquisition components or one time delay acquisition component, so that the time delay processing speed is improved; and the time delay acquisition module reads a time delay index configuration file, wherein the time delay index configuration file comprises a time delay index statistical rule, and based on the time delay index statistical rule, the time delay of the distributed system is counted according to the timestamp information, and various time delay indexes are calculated for subsequent output and viewing.
In this embodiment, the delay statistical method obtains a data identifier of target data input to the distributed system; acquiring a timestamp and an acquisition point identifier corresponding to a preset acquisition point of an application program when the target data is processed by the application program, wherein the application program is distributed at different nodes of the distributed system; generating time stamp information according to the data identification, the acquisition point identification and the time stamp; reading a time delay index configuration file, wherein the time delay index configuration file comprises a time delay index statistical rule; and based on the time delay index statistical rule, the time delay of the distributed system is counted according to the timestamp information. The time delay statistical method can realize automatic acquisition, measurement and statistics of time delay and throughput of a distributed system.
referring to fig. 5, fig. 5 is a schematic flowchart of a delay statistics method according to an embodiment of the present application. The delay statistical method is applied to the distributed system, as shown in fig. 5, and includes steps S201 to S208.
s201, screening out sample data input to the distributed system according to a preset screening rule.
Step S201 includes a step of data screening, as shown in fig. 6, the step specifically includes the following steps: s201a, counting the data input into the distributed system according to a preset counter; s201b, judging whether the number of counts corresponding to the counts meets a preset condition; s201c, if the counting number meets the preset condition, determining that the data corresponding to the counting number is the sample data input into the distributed system.
Specifically, a counter is set in advance in an application program, and a calculation flag is made on data input to the distributed system by the counter. And judging whether the counting number corresponding to the counting meets a preset condition. For example, the calculation number is modulo 100, n is the count number, and the preset condition is satisfied when n% 100 is 0. For another example, the predetermined condition may be satisfied when the calculated number is an odd number or an even number. And if the counting number meets the preset condition, determining that the data corresponding to the counting number is the sample data input into the distributed system. The time delay statistics and measurement can be selectively carried out on partial data through the data screening step, and resource waste caused by excessive data acquisition is avoided.
Of course, in other embodiments, the data may be filtered in other ways, such as by specifying that certain data be collected.
S202, setting the sample data as target data, and adding a data identifier in a message header of the target data.
specifically, the determined sample data is used as target data, and a data identifier is added to a message header of the target data, so that the data identifier of the target data input to the distributed system is acquired in step S103.
s203, acquiring a data identifier of the target data input to the distributed system.
specifically, the target data refers to data input from the outside to the distributed system, and the data needs to be processed by an application program in a host of the distributed system, flows between the application programs, and may be output to the outside, where each target data includes a data identifier.
S204, collecting a timestamp and a collection point identifier corresponding to a preset collection point of the application program when the target data is processed by the application program, wherein the application program is distributed in different nodes of the distributed system.
Specifically, the time delay acquisition module acquires a timestamp and an acquisition point identifier corresponding to a preset acquisition point of the application program when the target data is processed by the application program. The preset acquisition points are a plurality of time acquisition points which are preset in the application program and are identified.
and S205, generating time stamp information according to the data identifier, the acquisition point identifier and the time stamp.
Specifically, the time delay acquisition module generates time stamp information according to the data identifier, the acquisition point identifier and the time stamp, specifically packs the data identifier, the acquisition point identifier and the time stamp together into time stamp information, and sends the time stamp information to the time delay measurement component.
S206, reading a time delay index configuration file, wherein the time delay index configuration file comprises a time delay index statistical rule.
Specifically, the delay measurement component reads a delay index configuration file, where the delay index configuration file includes a delay index statistical rule. The statistical rule of the delay index is pre-configured in a server, and can be pre-configured in the server where the delay measurement component is located. And the time delay index statistical rule is a statistical rule of the distributed system according to the timestamp information.
And S207, based on the time delay index statistical rule, counting the time delay of the distributed system according to the time stamp information.
Specifically, the delay measurement component counts the delay of the distributed system according to the timestamp information based on the delay index statistical rule. The delay index statistical rule includes a plurality of delay index calculation formulas, for example, a delay index obtained by subtracting the end point timestamp and the start point timestamp, and may also include percentile values such as an average value, a minimum value, a maximum value, 50%, 90%, 95%, and 99%.
And S208, outputting and counting a statistical result corresponding to the time delay of the distributed system according to a preset output rule.
Specifically, the preset output rule is to output the statistical result according to a preset output form, where the preset output form includes three forms of output, which are: 1. rolling and outputting the statistical result to a command line console; 2. outputting the statistical result to a file, additionally recording the statistical value of each time delay index of each statistical period in the file, and also recording each time delay index value of each data; 3. the time delay measurement component is embedded with an Http server, can receive Http access requests from a browser or other programs, and returns the current statistical result to the visitor in the form of a Json character string according to the Http access requests.
Fig. 7 is a schematic block diagram of a latency statistic apparatus according to an embodiment of the present application. As shown in fig. 7, the present application also provides a delay statistics apparatus corresponding to the above delay statistics method. The delay statistics apparatus includes a unit for executing the delay statistics method, and the apparatus may be configured in a server.
as shown in fig. 7, the delay statistics apparatus 400 includes: the device comprises a data screening unit 401, an identification adding unit 402, an identification obtaining unit 403, an information collecting unit 404, an information generating unit 405, a file reading unit 406, a time delay counting unit 407 and a result output unit 408.
And the data screening unit 401 is configured to screen out sample data input to the distributed system according to a preset screening rule.
An identifier adding unit 402, configured to set the sample data as target data, and add a data identifier in a message header of the target data.
An identifier obtaining unit 403, configured to obtain a data identifier of the target data input to the distributed system.
an information acquisition unit 404, configured to acquire a timestamp and an acquisition point identifier corresponding to a preset acquisition point of an application program when the target data is processed by the application program, where the application program is distributed in different nodes of the distributed system.
An information generating unit 405, configured to generate timestamp information according to the data identifier, the collection point identifier, and the timestamp.
A file reading unit 406, configured to read a delay indicator configuration file, where the delay indicator configuration file includes a delay indicator statistical rule.
And a time delay counting unit 407, configured to count, based on the time delay index counting rule, a time delay of the distributed system according to the timestamp information.
And a result output unit 408, configured to output a statistical result corresponding to the time delay of the distributed system according to a preset output rule.
it can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the delay statistics apparatus and the unit described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The above-described apparatus may be implemented in the form of a computer program which is executable on a computer device as shown in fig. 8.
referring to fig. 8, fig. 8 is a schematic block diagram of a computer device according to an embodiment of the present application. The computer device 700 may be a server.
referring to fig. 8, the computer device 700 includes a processor 720, a memory, which may include a non-volatile storage medium 730 and an internal memory 740, and a network interface 750, which are connected by a system bus 710.
The non-volatile storage medium 730 may store an operating system 731 and computer programs 732. The computer program 732, when executed, may cause the processor 720 to perform any of the latency statistics.
The processor 720 is used to provide computing and control capabilities, supporting the operation of the overall computer device 700.
The internal memory 740 provides an environment for the execution of a computer program 732 in the non-volatile storage medium 730, and when executed by the processor 720, the computer program 732 may cause the processor 720 to perform any of the latency statistics methods.
The network interface 750 is used for network communication such as sending assigned tasks and the like. Those skilled in the art will appreciate that the architecture shown in fig. 8 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing device 700 to which the disclosed aspects apply, as a particular computing device 700 may include more or less components than those shown, or may combine certain components, or have a different arrangement of components. Wherein the processor 720 is configured to execute the program code stored in the memory to perform the following steps:
Acquiring a data identifier of target data input to the distributed system; acquiring a timestamp and an acquisition point identifier corresponding to a preset acquisition point of an application program when the target data is processed by the application program, wherein the application program is distributed at different nodes of the distributed system; generating time stamp information according to the data identification, the acquisition point identification and the time stamp; reading a time delay index configuration file, wherein the time delay index configuration file comprises a time delay index statistical rule; and based on the time delay index statistical rule, the time delay of the distributed system is counted according to the timestamp information.
in one embodiment, the processor 720 is configured to execute the program code stored in the memory to perform the following steps before the obtaining of the data identifier of the target data input to the distributed system is performed:
Screening out sample data input to the distributed system according to a preset screening rule; setting the sample data as target data, and adding a data identifier in a message header of the target data.
in an embodiment, the processor 720 is configured to run a program code stored in a memory to realize the screening of the sample data input to the distributed system according to a preset screening rule, and specifically realize the following steps:
counting data input to the distributed system according to a preset counter; judging whether the counting number corresponding to the counting meets a preset condition or not; and if the counting number meets the preset condition, determining that the data corresponding to the counting number is the sample data input into the distributed system.
In an embodiment, the processor 720 is configured to run a program code stored in a memory to implement the statistical rule based on the delay indicator, and count the delay of the distributed system according to the timestamp information, and specifically implement the following steps:
Acquiring a time delay index calculation formula in the time delay index statistical rule; and calculating the time delay index corresponding to the timestamp information according to the time delay index calculation formula.
In an embodiment, the processor 720 is configured to run a program code stored in a memory to implement the following steps when generating the timestamp information according to the data identifier, the collection point identifier, and the timestamp:
And correspondingly storing the time stamp in a preset data table according to the data identifier and the acquisition point identifier to generate the time stamp information table.
In an embodiment, the processor 720 is configured to execute the program code stored in the memory to implement the statistical rule based on the latency indicator, and after the statistics of the latency of the distributed system according to the timestamp information, further implement the following steps:
And outputting and counting a statistical result corresponding to the time delay of the distributed system according to a preset output rule.
In an embodiment, when the processor 720 is configured to run the program code stored in the memory to implement the output of the statistical result corresponding to the time delay of the statistical distributed system according to the preset output rule, the following steps are specifically implemented:
And receiving an Http access request, and returning the statistical result in a Json character string form according to the Http access request.
It should be understood that, in the embodiment of the present Application, the Processor 720 may be a Central Processing Unit (CPU), and the Processor 720 may also be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, and the like. Wherein a general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Those skilled in the art will appreciate that the configuration of computer device 700 depicted in FIG. 8 is not intended to be limiting of computer device 700 and may include more or less components than those shown, or some components in combination, or a different arrangement of components.
It will be understood by those skilled in the art that all or part of the processes in the methods of the above embodiments may be implemented by hardware related to instructions of a computer program, and the computer program may be stored in a storage medium, which is a computer-readable storage medium. In the embodiment of the present invention, the computer program may be stored in a storage medium of a computer system and executed by at least one processor in the computer system to implement the flow steps of the embodiments including the methods as described above.
the computer readable storage medium may be a magnetic disk, an optical disk, a usb disk, a removable hard disk, a Read-Only Memory (ROM), a magnetic disk or an optical disk, etc. which can store program codes.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be embodied in electronic hardware, computer software, or combinations of both, and that the components and steps of the examples have been described in a functional general in the foregoing description for the purpose of illustrating clearly the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the several embodiments provided in the present application, it should be understood that the disclosed latency statistic apparatus and method can be implemented in other ways. For example, the latency statistics embodiments described above are merely illustrative. For example, the division of each unit is only one logic function division, and there may be another division manner in actual implementation. For example, various elements or components may be combined or may be integrated into another system, or some features may be omitted, or not implemented.
The steps in the method of the embodiment of the application can be sequentially adjusted, combined and deleted according to actual needs.
The units in the device of the embodiment of the application can be combined, divided and deleted according to actual needs.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
the integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially or partially implemented in the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a terminal, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application.
While the invention has been described with reference to specific embodiments, the scope of the invention is not limited thereto, and those skilled in the art can easily conceive various equivalent modifications or substitutions within the technical scope of the invention. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.