Acquisition method and system of response time of application program and electronic equipment
By monitoring the time stamps of network packets on the client and server, and directly calculating the response time, the problem of high resource occupancy in the existing technology is solved, and efficient response time collection is achieved.
Patent Information
- Application Number
- CN202311873725.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-29
- Publication Date
- 2025-07-01
AI Technical Summary
When obtaining the response time of the message transmission end, the prior art needs to parse the message protocol to distinguish between requests and responses, resulting in the problem of high resource occupancy.
By monitoring the application's network message timestamps on the client and server, determining the timestamp differences between request and response messages, directly calculating the response time without parsing the message protocol.
This greatly reduces the resource occupancy rate, improves the efficiency of response time collection, and solves the problem of high resource occupancy rate.
Smart Images

Figure CN120238464A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technologies, and in particular, to a method, a system, and an electronic device for collecting the response time of an application program. Background Art
[0002] Currently, when collecting the response time of a request message at a message transmission end, it is necessary to distinguish or determine a request (for example, Request) and a response (for example, Response) by parsing the message protocols sent and received by the message transmission end, and then calculate the response time of the request message at the message transmission end. Since it is necessary to parse the message protocol to distinguish the request and the response, the resource occupancy rate is relatively high during the process of parsing the message protocol. Therefore, there is a technical problem of high resource occupancy rate when obtaining the response time of the request message at the message transmission end.
[0003] In view of the above problems, no effective solution has been proposed yet. Summary of the Invention
[0004] Embodiments of the present application provide a method, a system, and an electronic device for collecting the response time of an application program, so as to at least solve the technical problem of high resource occupancy rate when obtaining the response time of a request message at a message transmission end.
[0005] According to one aspect of the embodiments of the present application, a method for collecting the response time of an application program is provided. The method may include: monitoring request messages generated on a client during the running of the application program, where the request messages include a plurality of first network packets; monitoring response messages obtained by the server in response to the request messages, where the response messages include a plurality of second network packets, and there is a one-to-one correspondence between the plurality of second network packets and the plurality of first network packets; determining a first timestamp of a first target network packet in the plurality of first network packets during transmission at the message transmission end, and a second timestamp of a second target network packet in the plurality of second network packets during transmission at the message transmission end, where the message transmission end includes the client and / or the server; and determining the response time of the request message collected by the message transmission end based on the first timestamp of the first target network packet and the second timestamp of the second target network packet.
[0006] According to another aspect of the embodiments of the present application, there is also provided a method for collecting the response time of an application program. The method may include: in response to a message monitoring instruction acting on the operation interface, monitoring the request messages generated on the client during the running of the application program, and monitoring the response messages obtained by the server in response to the request messages. Among them, the request messages include multiple first network packets, the response messages include multiple second network packets, and there is a one-to-one correspondence between the multiple second network packets and the multiple first network packets; on the operation interface, display the first timestamp of the first target network packet among the multiple first network packets transmitted at the message transmission end, and the second timestamp of the second target network packet among the multiple second network packets transmitted at the message transmission end, where the message transmission end includes the client and / or the server; on the operation interface, display the response time collected by the message transmission end for the request message, where the response time is determined based on the first timestamp of the first target network packet and the second timestamp of the second target network packet.
[0007] According to another aspect of the embodiments of the present application, there is also provided a method for collecting the response time of an application program. The method may include: by calling a first interface to monitor the request messages generated on the client during the running of the application program, and monitoring the response messages obtained by the server in response to the request messages. Among them, the first interface includes a first parameter, and the parameter value of the first parameter is the request message and the response message. The request messages include multiple first network packets, the response messages include multiple second network packets, and there is a one-to-one correspondence between the multiple second network packets and the multiple first network packets; determine the first timestamp of the first target network packet among the multiple first network packets transmitted at the message transmission end, and the second timestamp of the second target network packet among the multiple second network packets transmitted at the message transmission end, where the message transmission end includes the client and / or the server; based on the first timestamp of the first target network packet and the second timestamp of the second target network packet, determine the response time collected by the message transmission end for the request message; output the response time by calling a second interface, where the second interface includes a second parameter, and the parameter value of the second parameter is the response time.
[0008] According to one aspect of the embodiments of the present application, a device for collecting the response time of an application program is provided. The device may include: a first monitoring unit, configured to monitor request messages generated on a client during the running of the application program, where the request messages include a plurality of first network packets; a second monitoring unit, configured to monitor response messages obtained by the server in response to the request messages, where the response messages include a plurality of second network packets, and there is a one-to-one correspondence between the plurality of second network packets and the plurality of first network packets; a first determining unit, configured to determine a first timestamp of a first target network packet among the plurality of first network packets during transmission at a message transmission end, and a second timestamp of a second target network packet among the plurality of second network packets during transmission at the message transmission end, where the message transmission end includes the client and / or the server; a second determining unit, configured to determine the response time of the request message collected by the message transmission end based on the first timestamp of the first target network packet and the second timestamp of the second target network packet.
[0009] According to another aspect of the embodiments of the present application, a device for collecting the response time of an application program is further provided. The device may include: a third monitoring unit, configured to respond to a message monitoring instruction on an operation interface, monitor request messages generated on a client during the running of the application program, and monitor response messages obtained by the server in response to the request messages, where the request messages include a plurality of first network packets, the response messages include a plurality of second network packets, and there is a one-to-one correspondence between the plurality of second network packets and the plurality of first network packets; a first display unit, configured to display, on the operation interface, a first timestamp of a first target network packet among the plurality of first network packets during transmission at a message transmission end, and a second timestamp of a second target network packet among the plurality of second network packets during transmission at the message transmission end, where the message transmission end includes the client and / or the server; a second display unit, configured to display, on the operation interface, the response time of the request message collected by the message transmission end, where the response time is determined based on the first timestamp of the first target network packet and the second timestamp of the second target network packet.
[0010] According to one aspect of the embodiments of the present application, there is provided an apparatus for collecting the response time of an application program. The apparatus may include: a first calling unit, configured to monitor, by calling a first interface, a request message generated on a client during the running of the application program, and a response message obtained by the server in response to the request message, where the first interface includes a first parameter, and the parameter value of the first parameter is the request message and the response message, the request message includes a plurality of first network packets, the response message includes a plurality of second network packets, and there is a one-to-one correspondence between the plurality of second network packets and the plurality of first network packets; a third determining unit, configured to determine a first timestamp at which a first target network packet in the plurality of first network packets is transmitted at a message transmission end, and a second timestamp at which a second target network packet in the plurality of second network packets is transmitted at the message transmission end, where the message transmission end includes the client and / or the server; a fourth determining unit, configured to determine the response time of the request message collected by the message transmission end based on the first timestamp of the first target network packet and the second timestamp of the second target network packet; a second calling unit, configured to output the response time by calling a second interface, where the second interface includes a second parameter, and the parameter value of the second parameter is the response time.
[0011] According to another aspect of the embodiments of the present application, there is also provided a system for collecting the response time of an application program. The system may include: a client and a server, where the client is configured to determine a first timestamp at which a first target network packet in a request message is sent on the client, and a second timestamp at which a second target network packet in a response message is received on the client, where the request message is generated on the client during the running of the application program, the response message is obtained by the server in response to the request message, the request message includes a plurality of first network packets, the response message includes a plurality of second network packets, and there is a one-to-one correspondence between the plurality of second network packets and the plurality of first network packets; determine the response time of the request message collected by the client based on the first timestamp of the first target network packet on the client and the second timestamp of the second target network packet on the client; the server is configured to determine a first timestamp at which the first target network packet is received on the server, and a second timestamp at which the second target network packet is sent on the server; determine the response time of the request message collected by the server based on the first timestamp of the first target network packet on the server and the second timestamp of the second target network packet on the server.
[0012] According to another aspect of the embodiments of the present application, there is also provided an electronic device, including a memory and a processor, the memory is configured to store computer-executable instructions, and the processor is configured to execute the computer-executable instructions, and the computer-executable instructions are executed by the processor to perform the steps of the method for collecting the response time of an application program.
[0013] According to another aspect of the embodiments of the present application, there is also provided a computer-readable storage medium. The computer-readable storage medium includes a stored program, wherein when the program processor runs, it controls the device where the computer storage medium is located to execute the steps of the method for collecting the response time of the application program.
[0014] In the embodiments of the present application, during the running of the application program, the request messages generated on the client are monitored. The request messages include a plurality of first network packets. The response messages obtained by the server in response to the request messages are monitored. The response messages include a plurality of second network packets, and there is a one-to-one correspondence between the plurality of second network packets and the plurality of first network packets. The first timestamp of the first target network packet in the plurality of first network packets during transmission at the message transmission end is determined, and the second timestamp of the second target network packet in the plurality of second network packets during transmission at the message transmission end is determined. The message transmission end includes the client and / or the server. Based on the first timestamp of the first target network packet and the second timestamp of the second target network packet, the response time of the request message collected by the message transmission end is determined. That is to say, in the embodiments of the present application, by monitoring the request messages generated by the client during the running of the application program and the response messages obtained by the server in response to the request messages, the request messages include a plurality of first network packets, and the response messages include a plurality of second network packets corresponding to the plurality of first network packets. Through the first timestamp of the first target network packet in the plurality of first network packets during transmission at the message transmission end and the second timestamp of the second target network packet in the plurality of second network packets during transmission at the message transmission end, the response time of the request message collected by the message transmission end can be determined. There is no need to distinguish the request message and the response message by parsing the packet protocol, which greatly reduces the resource occupancy rate when obtaining the response time of the message transmission end to the request message, improves the efficiency of determining the response time of the request message collected by the message transmission end, and solves the technical problem of high resource occupancy rate when obtaining the response time of the message transmission end to the request message.
[0015] It is easy to note that the above general description and the following detailed description are only for exemplifying and explaining the present application, and do not constitute a limitation to the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present application, and constitute a part of the present application. The schematic embodiments of the present application and their descriptions are used to explain the present application, and do not constitute an improper limitation to the present application. In the drawings:
[0017] Figure 1 is a hardware structure block diagram of a computer terminal (or mobile device) for implementing the method for collecting the response time of an application program according to the embodiments of the present application;
[0018] Figure 2 is a structural block diagram of a computing environment according to an embodiment of the present application;
[0019] Figure 3 is a structural block diagram of a service mesh according to an embodiment of the present application;
[0020] Figure 4 is a flowchart of a method for collecting the response time of an application according to an embodiment of the present application;
[0021] Figure 5 is a flowchart of another method for collecting the response time of an application according to an embodiment of the present application;
[0022] Figure 6 is a flowchart of another method for collecting the response time of an application according to an embodiment of the present application;
[0023] Figure 7 is a schematic diagram of a system for collecting the response time of an application according to an embodiment of the present application;
[0024] Figure 8 is a schematic diagram of an interaction process between a client and a server according to an embodiment of the present application;
[0025] Figure 9 is a flowchart of a method for obtaining the reception time or transmission time of a network packet according to an embodiment of the present application;
[0026] Figure 10 is a flowchart of a method for aggregating the response time of an application according to an embodiment of the present application;
[0027] Figure 11 is a schematic diagram of a device for collecting the response time of an application according to an embodiment of the present application;
[0028] Figure 12 is a schematic diagram of another device for collecting the response time of an application according to an embodiment of the present application;
[0029] Figure 13 is a schematic diagram of another device for collecting the response time of an application according to an embodiment of the present application;
[0030] Figure 14 is a structural block diagram of a computer terminal according to an embodiment of the present application. Detailed implementation
[0031] To enable those skilled in the art to better understand the solution of this application, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in this application without creative efforts shall fall within the scope of protection of this application.
[0032] It should be noted that the terms "first", "second", etc. in the specification, claims and the above-mentioned drawings of this application are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of this application described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or are inherent to these processes, methods, products or devices.
[0033] First, some nouns or terms that appear during the description of the embodiments of this application are applicable to the following explanations:
[0034] Berkeley Packet Filter (abbreviated as eBPF), a virtual machine running in the Linux kernel, used to provide flexibility and high performance in aspects such as packet processing and system tracing;
[0035] Response time (abbreviated as RT), used to indicate in the fields of computer science and performance analysis, the time elapsed from initiating a request or task to receiving a result or completing the task, which is one of the indicators for measuring the response performance of a system, application program or service;
[0036] Request / Response, in network communication, used to describe the interaction process between the client and the server. Among them, Request is used to indicate the message sent by the client to the server, used to request the server to perform a certain operation or obtain a certain resource, and Response is used to indicate the reply message of the server to the request message sent by the client;
[0037] Zero intrusion, used to indicate that dynamic observation can be achieved without modifying the code of the application program.
[0038] Embodiment 1
[0039] According to an embodiment of the present application, a method for collecting the response time of an application program is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0040] The method embodiment provided by the first embodiment of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 It is a hardware structure block diagram of a computer terminal (or mobile device) for implementing a method for collecting the response time of an application program according to an embodiment of the present application. As Figure 1 shown, the computer terminal 10 (or mobile device) may include one or more (shown as 102a, 102b,..., 102n in the figure) processors 102 (the processor 102 may include, but is not limited to, a processing device such as a microcontroller unit (MCU) or a field-programmable gate array (FPGA)), a memory 104 for storing data, and a transmission module 106 for communication functions. In addition, it may further include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply, and / or a camera. Those of ordinary skill in the art can understand that Figure 1 the structure shown is only schematic and does not limit the structure of the above electronic device. For example, the computer terminal 10 may further include more or fewer components than Figure 1 shown, or have a different configuration from Figure 1 shown.
[0041] It should be noted that the above one or more processors 102 and / or other data processing circuits can generally be referred to as "data processing circuits" in this article. The data processing circuit can be embodied in whole or in part as software, hardware, firmware, or any arbitrary combination thereof. In addition, the data processing circuit can be a single independent processing module, or be incorporated in whole or in part into any one of the other elements in the computer terminal 10 (or mobile device). As involved in the embodiments of the present application, the data processing circuit is a processor control (such as the selection of a variable resistance terminal path connected to an interface).
[0042] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the method for collecting the response time of the application program in the embodiments of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implements the method for collecting the response time of the above application program. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely provided with respect to the processor 102, and these remote memories can be connected to the computer terminal 10 through a network. Examples of the above network include but are not limited to the Internet, enterprise intranet, local area network, mobile communication network, and combinations thereof.
[0043] The transmission device 106 is used to receive or send data via a network. Specific examples of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one instance, the transmission device 106 includes a network adapter (Network Interface Controller, abbreviated as NIC), which can be connected to other network devices through a base station and thus can communicate with the Internet. In one instance, the transmission device 106 can be a radio frequency (Radio Frequency, abbreviated as RF) module, which is used to communicate with the Internet wirelessly.
[0044] The display can be, for example, a touch-screen liquid crystal display (Liquid Crystal Display, abbreviated as LCD), and the liquid crystal display enables a user to interact with the user interface of the computer terminal 10 (or mobile device).
[0045] Figure 1 The shown hardware structure block diagram can be used not only as an exemplary block diagram of the above computer terminal 10 (or mobile device), but also as an exemplary block diagram of the above server. In an alternative embodiment, Figure 2 is shown in a block diagram using the above Figure 1 shown computer terminal 10 (or mobile device) as a computing node in the computing environment 201 in one embodiment. Figure 2 is a structure block diagram of a computing environment according to an embodiment of the present application, such as Figure 2As shown, the computing environment 201 includes multiple computing nodes (such as servers, shown as 210-1, 210-2, … in the figure) running on a distributed network. Each computing node contains local processing and memory resources, and end users 202 can remotely run applications or store data in the computing environment 201. The applications can be provided as multiple services 220-1, 220-2, 220-3, and 220-4 in the computing environment 201, representing services "A", "D", "E", and "H" respectively.
[0046] End users 202 can provide and access services through a web browser or other software applications on the client side. In some embodiments, the provision and / or requests of end users 202 can be provided to the ingress gateway 230. The ingress gateway 230 can include a corresponding proxy to handle the provision and / or requests for services (one or more services provided in the computing environment 201).
[0047] Services are provided or deployed according to various virtualization technologies supported by the computing environment 201. In some embodiments, services can be provided based on virtual machine (VM)-based virtualization, container-based virtualization, and / or similar means. VM-based virtualization can simulate a real computer by initializing a virtual machine and execute programs and applications without directly accessing any actual hardware resources. While virtualizing the machine with a virtual machine, according to container-based virtualization, containers can be launched to virtualize the entire operating system (OS) so that multiple workloads can run on a single operating system instance.
[0048] In one embodiment of container-based virtualization, several containers of a service can be assembled into a Pod (e.g., Kubernetes Pod). For example, as Figure 2 shown, service 220-2 can be equipped with one or more Pods 240-1, 240-2, …, 240-N (collectively referred to as Pods). A Pod can include a proxy 245 and one or more containers 242-1, 242-2, …, 242-M (collectively referred to as containers). One or more containers in the Pod handle requests related to one or more corresponding functions of the service, and the proxy 245 generally controls network functions related to the service, such as routing, load balancing, etc. Other services can also be equipped with Pods similar to the Pod.
[0049] During operation, executing user requests from end users 202 may require invoking one or more services in the computing environment 201, and executing one or more functions of a service may require invoking one or more functions of another service. As Figure 2As shown, service "A" 220-1 receives a user request from end user 202 from ingress gateway 230. Service "A" 220-1 may invoke service "D" 220-2, and service "D" 220-2 may request service "E" 220-3 to perform one or more functions.
[0050] The computing environment described above may be a cloud computing environment where the allocation of resources is managed by a cloud service provider, allowing for the development of functions without considering the implementation, adjustment, or expansion of servers. This computing environment allows developers to execute code in response to events without building or maintaining complex infrastructure. Services can be split into a set of functions that can be automatically scaled independently, rather than scaling a single hardware device to handle potential loads.
[0051] In another alternative embodiment, Figure 3 A block diagram shows an embodiment of using the computer terminal 10 (or mobile device) described above Figure 1 as a service mesh. Figure 3 is a structural block diagram of a service mesh according to an embodiment of the present application. As Figure 3 shown, the service mesh 300 is mainly used to facilitate secure and reliable communication between multiple microservices. A microservice refers to decomposing an application into multiple smaller services or instances and running them on different clusters / machines.
[0052] As Figure 3 shown, the microservices may include application service instance A and application service instance B. Application service instance A and application service instance B form the functional application layer of service mesh 300. In one implementation, application service instance A runs in the form of a container / process 308 on a machine / workload container group 314 (Pod), and application service instance B runs in the form of a container / process 310 on a machine / workload container group 316 (Pod).
[0053] In one implementation, application service instance A may be a monitoring service. For example, it monitors the request messages generated on the client during the operation of the application program and the response messages obtained by the server in response to the request messages. Application service instance B may be a response time determination service. For example, it determines the first timestamp of the first target network packet among multiple first network packets in the request message transmitted at the message transmission end, and the second timestamp of the second target network packet among multiple second network packets in the response message transmitted at the message transmission end, and determines the response time of the request message collected by the message transmission end based on the first timestamp and the second timestamp.
[0054] As Figure 3As shown, application service instance A and mesh proxy (sidecar) 303 coexist in machine workload container group 614, and application service instance B and mesh proxy 305 coexist in machine workload container 314. Mesh proxy 303 and mesh proxy 305 form the data plane of service mesh 300. Among them, mesh proxy 303 and mesh proxy 305 run in the form of container / process 304 and container / process 306 respectively, can receive requests 312 for commodity query services, and there can be two-way communication between mesh proxy 303 and application service instance A, and between mesh proxy 305 and application service instance B. In addition, there can also be two-way communication between mesh proxy 303 and mesh proxy 305.
[0055] In one implementation, the traffic of application service instance A is routed to the appropriate destination through mesh proxy 303, and the network traffic of application service instance B is routed to the appropriate destination through mesh proxy 305. It should be noted that the network traffic mentioned here includes but is not limited to forms such as Hyper Text Transfer Protocol (abbreviated as HTTP), Representational State Transfer (abbreviated as REST), high-performance, general open-source framework (google Remote Procedure Call, abbreviated as gRPC), open-source in-memory data structure storage system (Redis), etc.
[0056] In one implementation, the function of the extended data plane can be achieved by writing custom filters (Filters) for the proxy (Envoy) in service mesh 300. The service mesh proxy configuration can be to enable the service mesh to correctly proxy service traffic and achieve service interconnection and service governance. Mesh proxy 303 and mesh proxy 305 can be configured to perform at least one of the following functions: service discovery, health checking, routing, load balancing, authentication and authorization, and observability.
[0057] As Figure 3 shown, the service mesh 300 also includes a control plane. Among them, the control plane can be a group of services running in a dedicated namespace, and these services are hosted by the managed control plane component 301 in machine / workload container group (machine / Pod) 302. AsFigure 3 As shown, the managed control plane component 301 communicates bidirectionally with the grid agents 303 and 305. The managed control plane component 301 is configured to perform some control and management functions. For example, the managed control plane component 301 receives the telemetry data transmitted by the grid agents 303 and 305, and can further aggregate this telemetry data. For these services, the managed control plane component 301 can also provide a user-oriented application programming interface (API for short) to more easily manipulate network behavior and provide configuration data to the grid agents 303 and 305, etc.
[0058] In the above operating environment, the present application provides a method for collecting the response time of an application as shown in Figure 4 shown. Figure 4 It is a flowchart of a method for collecting the response time of an application according to an embodiment of the present application.
[0059] Step S401, monitor the request messages generated on the client during the running of the application.
[0060] In the technical solution provided in step S401 of the present application, the application can be deployed on the client. For example, the application can be software on the client to implement specific functions and services. The request message includes a plurality of first network packets. That is, a request message can be split into a plurality of first network packets, and the plurality of first network packets are the network packets in a request message.
[0061] In this embodiment, when the application runs on the client, it can generate a request message on the client and send the request message to the server to request the server to perform an operation or obtain a certain resource. Among them, the request message can include a plurality of first network packets, and the plurality of first network packets are sequentially transmitted to the server on the client. Among them, the first first network packet in the plurality of first network packets can be represented by reqeust(first). That is, reqeust(first) can be the first first network packet transmitted to the server in the current request message, and the last first network packet in the plurality of first network packets can be represented by reqeust(last). That is, reqeust(last) can be the last first network packet transmitted to the server in the current request message.
[0062] For example, since the eBPF technology can intrude into the client and / or server without modifying the code, and the eBPF technology can implement packet processing and data tracking, based on this, the eBPF program can be intruded into the client without any intrusion to monitor the network packets on the client. For example, monitor the timestamp of the client sending the first network packet and the timestamp of the client receiving the second network packet sent by the server.
[0063] Optionally, by monitoring the request messages generated on the client, the sending time of each first network packet in the request message on the client and the time when the server receives each first network packet can be obtained.
[0064] Step S402: Monitor the response message obtained by the server in response to the request message.
[0065] In the technical solution provided in step S402 of the present application, since the request message is used to request the server to perform an operation or obtain a certain resource, that is, after the server responds to the request message, it can perform corresponding operations according to the content of the request message and generate a response message to return to the client. The response message obtained by the server in response to the request message can be monitored. Among them, the response message includes multiple second network packets, and there is a one-to-one correspondence between the multiple second network packets and the multiple first network packets.
[0066] In this embodiment, after the server responds to multiple first network packets in the request message, it can generate second network packets corresponding to each first network packet and return them to the client. Among them, the multiple second network packets are sequentially transmitted to the client on the server. Among them, the first second network packet in the multiple second network packets can be represented by response(first), that is, response(first) can be the first second network packet transmitted to the client in the response message, and the last second network packet in the multiple second network packets can be represented by response(last), that is, response(last) can be the last second network packet transmitted to the client in the response message. Among them, the first second network packet corresponds to the first first network packet of the client, and the last second network packet corresponds to the last first network packet of the client, that is, there is a one-to-one correspondence between the multiple second network packets and the multiple first network packets.
[0067] Optionally, referring to the introduction of step S401 above, the eBPF program can be intruded into the server without any intrusion to monitor the network packets on the server. For example, monitor the timestamp of the server sending the second network packet and the timestamp of the server receiving the first network packet sent by the client.
[0068] Optionally, by monitoring the response message obtained by the server in response to the request message, the transmission time of each second network packet in the response message at the server and the time when the client receives each second network packet can be obtained.
[0069] Step S403: Determine the first timestamp of the first target network packet among the multiple first network packets during transmission at the message transmission end, and the second timestamp of the second target network packet among the multiple second network packets during transmission at the message transmission end.
[0070] In the technical solution provided in step S403 of the present application above, the message transmission end includes the client and / or the server. The first target network packet can be the first network packet among the multiple first network packets in the request message, and the second target network packet can be the last network packet among the multiple second network packets in the response message. Based on this, when the message transmission end is the client, the first timestamp can be used to indicate the transmission time of the first target network packet among the multiple first network packets on the client, and the second timestamp can be used to indicate the reception time of the second target network packet among the multiple second network packets on the client. When the message transmission end is the server, the first timestamp can be used to indicate the reception time of the first target network packet among the multiple first network packets on the server, and the second timestamp can be used to indicate the transmission time of the second target network packet among the multiple second network packets on the server. Among them, there is a one-to-one correspondence between the second network packets in the response message and the first network packets in the request message, that is, the first second network packet in the response message corresponds to the first first network packet in the request message, and the last second network packet in the response message corresponds to the last first network packet in the request message.
[0071] In this embodiment, as can be seen from the introduction of the foregoing step S401, by monitoring the request message generated on the client, the transmission time of each first network packet in the request message on the client and the reception time on the server can be determined. Based on this, when the message transmission end is the client, the transmission time of the first target network packet in the request message on the client and the reception time of the second target network packet in the response message on the client can be determined, and the transmission time of the first target network packet on the client is determined as the first timestamp, and the reception time of the second target network packet on the client is determined as the second timestamp.
[0072] Optionally, as can be seen from the introduction of the foregoing step S402, by monitoring the response message obtained by the server in response to the request message, the transmission time of each second network packet in the response message on the server and the reception time on the client can be determined. Based on this, when the message transmission end is the server, the reception time of the first target network packet in the request message on the server and the transmission time of the second target network packet in the response message on the server can be determined, and the reception time of the first target network packet on the server is determined as the first timestamp, and the transmission time of the second target network packet on the server is determined as the second timestamp.
[0073] Step S404: Determine the response time of the request message collected by the message transmission end based on the first timestamp of the first target network packet and the second timestamp of the second target network packet.
[0074] In the technical solution provided in step S404 of the present application, as can be seen from the introduction of the foregoing step 403, when the message transmission end is the client, the first timestamp can be used to indicate the transmission time of the first target network packet in the request message on the client, and the second timestamp can be used to indicate the reception time of the second target network packet in the response message on the client. When the message transmission end is the server, the first timestamp can be used to indicate the reception time of the first target network packet in the request message on the server, and the second timestamp can be used to indicate the transmission time of the second target network packet in the response message on the server. Based on this, the response time of the request message collected by the client and the response time of the request message collected by the server can be determined respectively according to the first timestamp of the first target network packet and the second timestamp of the second target network packet. Among them, the response time of the request message collected by the client can be used to indicate the time interval between the time when the first target network packet in the request message is sent by the client and the time when the second target network packet sent by the server is received by the client, and the response time of the request message collected by the server can be used to indicate the time interval between the time when the first target network packet in the request message is received by the server and the time when the second target network packet in the response message is sent by the server.
[0075] In this embodiment, since the first target network packet can be the first network packet among multiple first network packets in the request message, and the second target network packet can be the last network packet among multiple second network packets in the response message. Based on this, when the message transmission end is the client, the difference between the transmission time of the first target network packet in the request message on the client and the reception time of the second target network packet in the response message on the client can be used to determine the response time of the application on the client.
[0076] Optionally, when the message transmission end is a server, the difference between the reception time of the first target network packet in the request message at the server and the transmission time of the second target network packet in the response message at the server can be used to determine the response time of the application program at the client.
[0077] Based on steps S401 to S404 of the above embodiments, by monitoring the first timestamp of the first target network packet included in the request message generated by the client during the operation of the application program, the transmission time of the first target network packet sent on the client and the reception time of the first target network packet received on the server can be obtained. By monitoring the second timestamp of the second target network packet transmitted by the message transmission end in the response message of the server, the transmission time of the second target network packet sent on the server and the reception time received on the client can be obtained. That is, through the first timestamp of the first target network packet and the second timestamp of the second target network packet, the response time of the request message collected by the message transmission end can be determined, without the need to distinguish the request message and the response message by parsing the packet protocol, greatly reducing the resource occupancy rate when obtaining the response time of the message transmission end to the request message, improving the efficiency of determining the response time of the request message collected by the message transmission end, and solving the technical problem of high resource occupancy rate when obtaining the response time of the message transmission end to the request message.
[0078] The above method of this embodiment will be further introduced below.
[0079] As an optional implementation manner, when multiple first network packets are sequentially transmitted at the message transmission end and multiple second network packets are sequentially transmitted at the message transmission end, the method for collecting the response time of the application program further includes: determining the first target network packet that is first transmitted among the multiple first network packets, and the second target network packet that is last transmitted among the multiple second network packets.
[0080] In this embodiment, since the request message includes multiple first network packets, the multiple first network packets are transmitted sequentially at the message transmission end. The response message includes multiple second network packets, and the multiple second network packets are transmitted sequentially at the message transmission end. Moreover, the multiple first network packets in the request message are transmitted from the client to the server for requesting the server to perform a certain operation or obtain a certain resource. Based on this, the first first network packet transmitted from the client to the server in the request message can be determined, that is, the first network packet among the multiple first network packets that is first transmitted from the client to the server is determined, and this first first network packet is determined as the first target network packet. For convenience of description, this first target network packet can be denoted as request(first). In addition, the multiple second network packets in the response message are transmitted from the server to the client for replying to the client. Based on this, the last second network packet transmitted from the server to the client in the response message can be determined, that is, the second network packet among the multiple second network packets that is last transmitted from the server to the client is determined, and this last second network packet is determined as the second target network packet. For convenience of description, this target second network packet can be denoted as response(last).
[0081] Optionally, after determining the first target network packet, the transmission time of the first target network packet on the client and the reception time on the server can be determined, and the transmission time and the reception time are determined as the first timestamp of the first target network packet transmitted at the message transmission end. For convenience of description, this first timestamp can be denoted as T(request(first)).
[0082] Optionally, after determining the second target network packet, the transmission time of the second target network packet on the server and the reception time on the client can be determined, and the transmission time and the reception time are determined as the second timestamp of the second target network packet transmitted at the message transmission end. For convenience of description, this second timestamp can be denoted as T(response(last)).
[0083] As an alternative implementation, the message transmission end is the client. Step S403, determining the first timestamp of the first target network packet transmitted at the message transmission end among the multiple first network packets and the second timestamp of the second target network packet transmitted at the message transmission end among the multiple second network packets, includes: determining the first timestamp of the first target network packet transmitted on the client based on the message sending event triggered by the first target network packet on the client; determining the second timestamp of the second target network packet received on the client based on the message receiving event triggered by the second target network packet on the client.
[0084] In this embodiment, when the message transmission end is the client, the message sending event is used to indicate the packet sending event of the client, that is, the client sends a first network packet to the server to request the server to perform a certain operation or obtain a certain resource. The message receiving event is used to indicate the packet receiving time of the client, that is, the client receives a second network packet fed back by the server, where the second network packet corresponds to the first network packet, and the second network packet is a reply message to the first network packet.
[0085] Optionally, when the message transmission end is the client, according to the message sending event triggered on the client, the sending time of the first target network packet sent by the client can be determined, and this sending time is determined as the first timestamp when the first target network packet is sent on the client. According to the message receiving event triggered on the client, the second timestamp when the second target network packet is received on the client can be determined, and this second timestamp is also the time when the client receives the second target network packet.
[0086] As an alternative implementation, step S404, determining the response time of the request message collected by the message transmission end based on the first timestamp of the first target network packet and the second timestamp of the second target network packet, includes: obtaining a first time difference between the second timestamp of the second target network packet and the first timestamp of the first target network packet; based on the first time difference, determining the response time of the request message collected by the client.
[0087] In this embodiment, after determining the first timestamp when the first target network packet is sent on the client and the second timestamp when the second target network packet is received on the client, a first time difference between the second timestamp of the second target network packet and the first timestamp of the first target network packet can be obtained, and this first time difference is determined as the response time of the request message collected by the client.
[0088] For example, the first time difference between the second timestamp of the second target network packet and the first timestamp of the first target network packet can be determined by the following formula.
[0089] ClientRT = T(response(last)) - T(request(first))
[0090] Where ClientRT can be used to represent the first time difference, T(request(first)) can be used to represent the first timestamp, that is, the sending time when the first target network packet (reqeust(first)) is sent on the client, and T(response(last)) can be used to represent the second timestamp, that is, the receiving time when the second target network packet (response(last)) is received on the client.
[0091] As an alternative implementation, based on the first time difference, determining the response time of the request message collected by the client includes: in response to the number of connections corresponding to multiple request messages within a time period being less than or equal to the connection number threshold, determining the first time difference as the response time of the request message collected by the client.
[0092] In this embodiment, after determining the first time difference between the second timestamp of the second target network packet and the first timestamp of the first target network packet, it can be determined whether the number of connections corresponding to multiple request messages within the time period is less than or equal to the connection number threshold. If the number of connections corresponding to multiple request messages within the time period is less than or equal to the connection number threshold, it indicates that the number of connections on the operating system platform where the application program runs does not exceed the threshold. In this case, the first time difference can be directly determined as the response time of the request message collected by the client. That is, the interval time from when the client sends the first target network packet until it receives the second target network packet corresponding to the first target network packet.
[0093] As an alternative implementation, based on the first time difference, determining the response time of the request message collected by the client includes: in the kernel state of the operating system platform where the application program runs, aggregating multiple first time differences corresponding to multiple request messages within a time period to obtain the response time of the request message collected by the client.
[0094] In this embodiment, since the resource occupancy rate of the message transmission end is proportional to the number of request messages, when the application program initiates multiple request messages, it may cause the operating system platform where the application program runs to listen to multiple ports, and there may be a problem of excessive resource occupancy when collecting the response time of the request message by the client. Based on this, when the number of connections corresponding to multiple request messages within a time period is greater than the connection number threshold, in the kernel state of the operating system platform where the application program runs, aggregating multiple first time differences corresponding to multiple requests within the time period to obtain the response time of the application program.
[0095] For example, in the kernel mode of the operating system platform on which the application runs, an eBPF program can be used to aggregate multiple first time differences corresponding to multiple request messages within a time period. For example, accumulate multiple first time differences corresponding to multiple request messages within a time period. Then, based on the aggregated time difference, determine the response time of the request message collected by the client, so as to reduce the resource occupancy rate of collecting the response time of the request message collected by the client. Among them, the method for determining multiple first time differences can refer to the method for determining the first time difference introduced above, which will not be elaborated here. It should be noted that when calculating multiple first time differences corresponding to multiple request messages, when the next request starts, it means that the previous request message has ended. In this case, the response time of the previous request message can be calculated. According to this method, after each request message ends in turn, the response time of each request message can be calculated, and then multiple first time differences corresponding to each request message can be obtained.
[0096] As an alternative implementation, in the kernel mode of the operating system platform on which the application runs, aggregating multiple first time differences corresponding to multiple request messages within a time period to obtain the response time of the request message collected by the client includes: in response to the number of connections corresponding to multiple request messages within a time period being greater than the connection number threshold, in the kernel mode, obtain the number of multiple first time differences within the time period; based on the number of multiple first time differences, determine the first average time difference of the first time differences within the time period; and determine the first average time difference as the response time of the request message collected by the client.
[0097] In this embodiment, after aggregating multiple first time differences, if the number of connections corresponding to multiple request messages within a time period is greater than the connection number threshold, it means that there are too many connections on the operating system platform where the application runs. In this case, in the kernel mode, obtain the number of multiple first time differences within the time period, and based on the number of multiple first time differences, determine the first average time difference of the multiple first time differences within the time period, and determine the first average time difference as the response time of the request message collected by the client.
[0098] For example, the number of multiple first time differences within a time period can be denoted as RT[Client(count)]. Based on this, the average value of multiple first time differences within the time period can be calculated according to the aggregation processing result of multiple first time differences and the number of multiple first time differences, and this average value can be determined as the first average time difference. For example, the first average time difference can be determined by the following formula.
[0099] RT1 = RT[Client(Total)] / RT[Client(count)]
[0100] Among them, RT1 can be used to represent the first average time difference, RT[Client(Total)] can be used to represent the aggregation processing result of multiple first time differences, and RT[Client(count)] can be used to represent the number of multiple first time differences.
[0101] Among them, RT[Client(Total)] = Client(RT1) + Client(RT2) + …… + Client(RTi), where Client(RTi) is used to represent the i-th time difference.
[0102] The above steps introduce the acquisition process of the response time of the application program on the client when the message transmission end is the client. Next, the acquisition process of the response time of the application program on the server is introduced.
[0103] As an optional implementation manner, when the message transmission end is the server, in step S403, determining the first timestamp at which the first target network packet in the multiple first network packets is transmitted at the message transmission end, and the second timestamp at which the second target network packet in the multiple second network packets is transmitted at the message transmission end includes: determining the first timestamp at which the first target network packet is received by the server based on the message reception event triggered by the first target network packet on the server; determining the second timestamp at which the second target network packet is sent by the server based on the message sending event triggered by the second target network packet on the server.
[0104] In this embodiment, when the message transmission end is the server, the message reception event is used to indicate the packet reception time of the server, that is, the server receives the first network packet sent by the client. The message sending time is used to indicate the packet sending time of the server, that is, the server sends the second network packet to the client, where the second network packet corresponds to the first network packet and the second network packet is a reply message to the first network packet.
[0105] Optionally, when the message transmission end is the server, according to the message reception event triggered on the server, the time when the server receives the first target network packet can be determined, and this time is determined as the first timestamp at which the first target network packet is received on the server. After the message sending event triggered on the server, the time when the server sends the second target network packet can be determined, and this time is determined as the second timestamp at which the second target network packet is sent by the server.
[0106] As an alternative implementation, in step S404, based on the first timestamp of the first target network packet and the second timestamp of the second target network packet, determining the response time of the request message collected by the message transmission end includes: obtaining a second time difference between the second timestamp of the second target network packet and the first timestamp of the first target network packet; based on the second time difference, determining the response time of the request message collected by the server.
[0107] In this embodiment, after determining the first timestamp when the first target network packet is received by the server and the second timestamp when the second target network packet is sent by the server, a second time difference between the second timestamp of the second target network packet and the first timestamp of the first target network packet can be obtained, and this second time difference is determined as the response time of the application program on the server.
[0108] For example, the second time difference between the second timestamp of the second target network packet and the first timestamp of the first target network packet can be determined by the following formula.
[0109] ServerRT = (response(last)) - T(request(first))
[0110] Wherein, ServerRT can be used to represent the second time difference, T(response(last)) can be used to represent the second timestamp, that is, the transmission time when the second target network packet (response(last)) is sent at the server side, and T(request(first)) can be used to represent the first timestamp, that is, the reception time when the first target network packet (reqeust(first)) is received at the server side.
[0111] As an alternative implementation, based on the second time difference, determining the response time of the request message collected by the server includes: in response to the number of connections corresponding to multiple request messages within a time period being less than or equal to the connection number threshold, determining the second time difference as the response time of the request message collected by the server.
[0112] In this embodiment, after determining the second time difference between the second timestamp of the second target network packet and the first timestamp of the first target network packet, it is possible to determine whether the number of connections corresponding to multiple request messages within a time period is less than or equal to the connection number threshold. If the number of connections corresponding to multiple request messages within the time period is less than or equal to the connection number threshold, it indicates that the number of connections on the operating system platform where the application is running does not exceed the threshold. In this case, the second time difference can be directly determined as the response time collected by the server for the request message. That is, the interval time from when the server receives the first target network packet until it generates the second target network packet corresponding to the first target network packet and sends the second target network packet to the client.
[0113] As an alternative implementation, based on the second time difference, determining the response time collected by the server for the request message includes: in the kernel mode of the operating system platform where the application is running, aggregating multiple second time differences corresponding to multiple request messages within a time period to obtain the response time collected by the server for the request message.
[0114] In this embodiment, when there are multiple request messages, the server can sequentially generate corresponding response messages according to the multiple request messages. Among them, each response message corresponding to each request message contains multiple second network packets, and the multiple second network packets correspond to the multiple first network packets in the corresponding request message. Since when there are multiple request messages, the operating system platform where the application is running needs to monitor multiple ports, there may be a problem that the collection of the response time of the application occupies too many resources. Based on this, when the number of connections corresponding to multiple request messages within a time period is greater than the connection number threshold, in the kernel mode of the operating system platform where the application is running, multiple second time differences corresponding to multiple request messages within a time period can be aggregated to obtain the response time collected by the server for the request message.
[0115] For example, in the kernel mode of the operating system platform where the application is running, an eBPF program can be used to aggregate multiple second time differences within a time period. Among them, the eBPF program is an extended mechanism in the kernel mode that allows custom code logic to be executed in the kernel to achieve more efficient data aggregation and processing. By using the eBPF program in the kernel mode, data aggregation can be directly performed in the kernel mode, avoiding frequent user-mode and kernel-mode switches, and further reducing the resource occupancy rate. That is, eBPF can perform efficient data processing in the kernel mode.
[0116] For example, an eBPF program is used to accumulate multiple second time differences within a time period. After that, based on the aggregated time differences, the response time of the request message collected by the server can be determined, which can reduce the resource occupancy rate for collecting the response time of the request message collected by the server. Among them, the method for determining multiple second time differences can refer to the method for determining the second time difference introduced above, which will not be elaborated here.
[0117] As an optional implementation manner, in the kernel state of the operating system platform where the application program runs, aggregate processing is performed on multiple second time differences corresponding to multiple request messages within a time period to obtain the response time of the request message collected by the server, including: in response to the number of connections corresponding to multiple request messages within a time period being greater than the connection number threshold, in the kernel state, obtain the number of multiple second time differences within the time period; based on the number of multiple second time differences, determine the second average time difference of the second time differences within the time period; and determine the second average time difference as the response time of the request message collected by the server.
[0118] In this embodiment, after aggregating multiple second time differences, if the number of connections corresponding to multiple request messages within a time period is greater than the connection number threshold, it indicates that there are too many connections on the operating system platform where the application program runs. In this case, in the kernel state, the number of multiple second time differences within the time period can be obtained, and based on the number of multiple second time differences, the second average time difference of the multiple second time differences within the time period can be determined, and the second average time difference is determined as the response time of the request message collected by the server.
[0119] For example, the number of multiple second time differences within a time period can be denoted as RT[server(count)]. Based on this, the average value of multiple second time differences within the time period can be calculated according to the aggregation processing result of multiple second time differences and the number of multiple second time differences, and this average value is determined as the second average time difference. For example, the second average time difference can be determined by the following formula.
[0120] RT2 = RT[Server(total)] / RT[Server(count)]
[0121] Among them, RT2 can be used to represent the second average time difference, RT[Server(total)] can be used to represent the aggregation processing result of multiple second time differences, and RT[Server(count)] can be used to represent the number of multiple second time differences.
[0122] Among them, RT(Server(total)) = Server(RT1) + Server(RT2) + …… + Server(RTi), where Server(RTi) is used to represent the i-th time difference.
[0123] As an alternative implementation, determining the first target network packet to be transmitted first among multiple first network packets and the second target network packet to be transmitted last among multiple second network packets includes: determining the first target network packet to be transmitted first among multiple first network packets and the second target network packet to be transmitted last among multiple second network packets when the next request message of the request message starts to be transmitted or the client is closed.
[0124] In this embodiment, when determining the first target network packet to be transmitted first among multiple first network packets and the second target network packet to be transmitted last among multiple second network packets, and calculating the response time of the request message collected by the message transmission end according to the first timestamp of the first target network packet and the second timestamp of the second target network packet, it is necessary to first determine whether the transmission of the request message is completed. When it is determined that the transmission of the request message is completed, the response time of the request message collected by the message transmission end is determined according to the first target network packet to be transmitted first among multiple first network packets in the request message and the second target network packet to be transmitted last among multiple second network packets.
[0125] For example, when determining whether the transmission of the request message is completed, if there is still a request message after the request message, then when the next request message of the request message starts to be transmitted, it can be determined that the request message has been transmitted. In this case, the response time of the request message collected by the message transmission end can be calculated according to the first timestamp of the first target network packet (i.e., the first network packet in the request message) recorded by the message transmission end and the second timestamp of the second target network packet (i.e., the last network packet in the response message) recorded by the message transmission end corresponding to the request message. Among them, the method for calculating the response time of the request message collected by the message transmission end can refer to the method for calculating the response time of the request message collected by the client or the server according to the first timestamp of the first target network packet and the second timestamp of the second target network packet introduced above, which will not be elaborated here.
[0126] Optionally, when determining whether the transmission of a request message has ended, if it is responded that the client has closed, it can be determined that the transmission of the request message has ended. In this case, it can also be determined the first target network packet that is first transmitted among multiple first network packets, and the second target network packet that is last transmitted among multiple second network packets, and calculate the response time of the request message collected by the message transmitter according to the first timestamp of the first target network packet and the second timestamp of the second target network packet.
[0127] As an optional implementation manner, the method for collecting the response time of an application further includes: in response to the response time of the application at the message transmitter being greater than the response time threshold, outputting corresponding prompt information, where the prompt information is used to at least identify the application.
[0128] In this embodiment, when the message transmitter is the client, it can be determined whether the response time of the application at the client is greater than the response time threshold. If it is greater, corresponding prompt information is output to identify the application and further determine the application with a higher response time.
[0129] Optionally, when the message transmitter is the server, it can be determined whether the response time of the application at the server is greater than the response time threshold. If it is greater, corresponding prompt information is output to identify the application.
[0130] It should be noted that the above method for determining the response time of the message transmitter is only an exemplary example. The embodiments of the present invention can be applied to any response time obtained by the above method, and will not be exemplified one by one here.
[0131] In the above steps, by monitoring the first timestamp of the first target network packet included in the request message of the client during the running of the application at the message transmitter and the second timestamp of the second target network packet in the response message at the message transmitter, the response time of the application at the client and the response time of the client at the server can be respectively determined. There is no need to distinguish the request message and the response message by parsing the packet protocol, which greatly reduces the resource occupancy rate for obtaining the response time of the message transmitter to the request message, improves the efficiency of determining the response time of the request message collected by the message transmitter, and solves the technical problem of high resource occupancy rate for obtaining the response time of the message transmitter to the request message.
[0132] In the above running environment, the present application also provides a method for collecting the response time of an application as shown in Figure 5 from the human-computer interaction side. Figure 5 is a flowchart of another method for collecting the response time of an application according to an embodiment of the present application. As shown in Figure 5 below, the method may include the following steps.
[0133] Step S501: In response to a message monitoring instruction on the operation interface, monitor the request messages generated on the client during the operation of the application program, and monitor the response messages obtained by the server in response to the request messages.
[0134] In the technical solution provided in step S501 of the present application, the operation interface includes a message monitoring control. When responding to the user's selection operation on the message monitoring control, that is, in response to the message monitoring instruction on the operation interface, monitor the request messages generated on the client during the operation of the application program, and monitor the response messages obtained by the server in response to the request messages. Among them, the request messages include multiple first network packets, and the response messages include multiple second network packets. There is a one-to-one correspondence between the multiple second network packets and the multiple first network packets. Among them, the method of monitoring the request messages generated on the client and the response messages obtained by the server in response to the request messages can refer to the descriptions in the foregoing steps S401 and S402, and will not be elaborated here.
[0135] Step S502: On the operation interface, display the first timestamp of the first target network packet among the multiple first network packets during transmission at the message transmission end, and the second timestamp of the second target network packet among the multiple second network packets during transmission at the message transmission end.
[0136] In the technical solution provided in step S502 of the present application, when the message transmission end is the client, the first timestamp can be used to indicate the sending time of the first target network packet among the multiple first network packets in the request message at the client, and the second timestamp can be used to indicate the receiving time of the second target network packet among the multiple second network packets in the response message at the client. Among them, the first target network packet can be the first network packet among the multiple first network packets in the request message, and the second target network packet can be the last network packet among the multiple second network packets in the response message. When the message transmission end is the server, the first timestamp can be used to indicate the receiving time of the first target network packet among the multiple first network packets at the server, and the second timestamp can be used to indicate the sending time of the second target network packet among the multiple second network packets at the server. Based on this, after determining the first timestamp of the first target network packet during transmission at the message transmission end and the second timestamp of the second target network packet in the response message during transmission at the message transmission end, they can be displayed on the display interface.
[0137] Step S503: On the operation interface, display the response time collected by the message transmission end for the request message.
[0138] In the technical solution provided in step S503 of the present application above, when the message transmission end is the client, the difference between the sending time of the first target network packet in the request message at the client and the receiving time of the second target network packet in the response message at the client can be used to determine the response time of the request message collected by the client. After determining the response time of the message transmission end, it can be displayed on the operation interface.
[0139] Optionally, when the message transmission end is the server, the difference between the receiving time of the first target network packet in the request message at the server and the sending time of the second target network packet in the response message at the server end can be used to determine the response time of the request message collected by the server. After determining the response time of the message transmission end, it can be displayed on the operation interface.
[0140] In the above steps S501 to S503, by monitoring the first timestamp of the transmission of the first target network packet included in the request message of the client and the second timestamp of the transmission of the second target network packet in the response message at the message transmission end during the running process of the application program, the response time of the request message collected by the client and the response time of the request message collected by the server can be determined respectively, without the need to distinguish the request message and the response message by parsing the packet protocol, greatly reducing the resource occupancy rate for obtaining the response time of the message transmission end to the request message, improving the efficiency of determining the response time of the request message collected by the message transmission end, and solving the technical problem of high resource occupancy rate for obtaining the response time of the message transmission end to the request message.
[0141] In the above operating environment, the present application also provides a method for collecting the response time of the application program as shown in Figure 6 from the perspective of human-computer interaction. Figure 6 is a flowchart of another method for collecting the response time of an application program according to an embodiment of the present application. As shown in Figure 6 The method may include the following steps.
[0142] Step S601, monitor the request message generated on the client during the running process of the application program by calling the first interface, and monitor the response message obtained by the server in response to the request message.
[0143] In this embodiment, the first interface can be an interface for data interaction between the server and the client. During the operation of the application, after generating request information on the client, the request message can be sent to the server through the first interface. After receiving the request message, the server can generate a corresponding response message based on the request message. Based on this, it is possible to monitor the request message generated on the client during the operation of the application and the response message obtained by monitoring the server's response to the request message by calling the first interface.
[0144] Step S602: Determine the first timestamp at which the first target network packet in the multiple first network packets is transmitted at the message transmission end, and the second timestamp at which the second target network packet in the multiple second network packets is transmitted at the message transmission end.
[0145] In this embodiment, since the message transmission end includes the client and / or the server, based on this, when the message transmission end is the client, the first timestamp can be used to indicate the sending time of the first target network packet in the multiple first network packets in the request message at the client, and the second timestamp can be used to indicate the receiving time of the second target network packet in the multiple second network packets in the response message at the client. When the message transmission end is the server, the first timestamp can be used to indicate the receiving time of the first target network packet in the request message at the server, and the second timestamp can be used to indicate the sending time of the second target network packet in the response message at the server. Among them, the first second network packet in the response message corresponds to the first first network packet in the request message, and the last second network packet in the response message corresponds to the last first network packet in the request message. Among them, the method for determining the first timestamp and the second timestamp can refer to the introduction in the foregoing step S403, which will not be elaborated here.
[0146] Step S603: Determine the response time of the request message collected by the message transmission end based on the first timestamp of the first target network packet and the second timestamp of the second target network packet.
[0147] In this embodiment, when the message transmission end is the client, the first timestamp can be used to indicate the sending time of the first target network packet in the request message at the client, and the second timestamp can be used to indicate the receiving time of the second target network packet in the response message at the client. When the message transmission end is the server, the first timestamp can be used to indicate the receiving time of the first target network packet in the request message at the server, and the second timestamp can be used to indicate the sending time of the second target network packet in the response message at the server. Based on this, the response time of the request message collected at the client and the response time of the request message collected at the server can be determined respectively according to the first timestamp of the first network packet and the second timestamp of the second network packet. Among them, the method for calculating the response time of the request message collected at the message transmission end can refer to the introduction in the foregoing step S404, which will not be elaborated here.
[0148] Step S604, output the response time by calling the second interface.
[0149] In this embodiment, the second interface can be an interface for data interaction between the server and the client. After determining the response time, the response time of the application program at the client can be output by calling the second interface, or the response time of the application program in the server can be output by calling the client.
[0150] Based on the above steps S601 to S604 of the embodiment, by monitoring the first timestamp of the first target network packet transmitted by the message transmission end in the request message of the client and the second timestamp of the second target network packet transmitted by the message transmission end in the response message during the running of the application program, the response time of the request message collected at the client and the response time of the request message collected at the server side can be determined respectively, without the need to distinguish the request message and the response message by parsing the packet protocol, greatly reducing the resource occupancy rate for obtaining the response time of the message transmission end to the request message, improving the efficiency of determining the response time of the request message collected at the message transmission end, and solving the technical problem of high resource occupancy rate when obtaining the response time of the message transmission end to the request message.
[0151] The embodiment of the present invention also provides a collection system for the response time of an application program. It should be noted that the collection system for the response time of the application program in this embodiment can be used to execute the collection method for the response time of the application program in the embodiment of the present invention.
[0152] Figure 7 is a schematic diagram of a collection system for the response time of an application program according to an embodiment of the present application. As Figure 7 shown, the collection system 700 for the response time of the application program includes: a client 701 and a server 702.
[0153] The client 701 is configured to determine a first timestamp at which a first target network packet in a request message is sent on the client, and a second timestamp at which a second target network packet in a response message is received on the client. The request message is generated on the client during the operation of an application, and the response message is obtained by the server in response to the request message. The request message includes multiple first network packets, and the response message includes multiple second network packets. There is a one-to-one correspondence between the multiple second network packets and the multiple first network packets. Based on the first timestamp of the first target network packet on the client and the second timestamp of the second target network packet on the client, determine the response time of the request message collected by the client.
[0154] In this embodiment, the client generates a request message and sends the request message to the server to request the server to perform a certain operation or obtain a certain resource. The request message may include multiple first network packets, and the multiple first network packets are sequentially transmitted to the server on the client. The first target network packet is used to indicate the first of the multiple first network packets transmitted from the client to the server. The client is configured to determine the first timestamp at which the first target network packet in the request message is sent on the client, and the second timestamp at which the second target network packet received from the server is received. The first target network packet corresponds to the second target network packet. Based on the first timestamp of the first target network packet on the client and the second timestamp of the second target network packet on the client, determine the response time of the request message collected by the client. The method for determining the response time of the request message collected by the client may refer to the description of step S404 above and will not be elaborated here.
[0155] The server 702 is configured to determine a first timestamp at which the first target network packet is received on the server, and a second timestamp at which the second target network packet is sent on the server. Based on the first timestamp of the first target network packet on the server and the second timestamp of the second target network packet on the server, determine the response time of the request message collected by the server.
[0156] In this embodiment, the server is configured to receive a request message sent by a client and generate a response message based on the request message. Among them, there is a one-to-one correspondence between multiple first network packets included in the request message and multiple second network packets included in the response message. The server is configured to determine the reception time of the first target network packet on the server, which is the first timestamp, and determine the transmission time of the second target network packet on the server, which is the second timestamp. Then, based on the first timestamp of the first target network packet on the server and the second timestamp of the second target network packet on the server, the response time of the request message collected by the server is determined. Among them, the method for determining the response time of the request message collected by the server can refer to the introduction in the foregoing step S404, which will not be elaborated here.
[0157] The technical solutions of the embodiments of the present application will be further introduced by way of examples in combination with the preferred embodiments below.
[0158] When obtaining the response time of the request message collected by message transmission, it is necessary to distinguish or judge requests and responses by parsing the message protocols sent and received by the application program, and then calculate the response time of the request message collected by the message transmission end. Since it is necessary to parse the message protocol to distinguish requests and responses, the resource occupancy rate is relatively high during the process of parsing the message protocol. Therefore, there is a technical problem of high resource occupancy rate in obtaining the response time of the message transmission end to the request message.
[0159] Currently, collection tools for observable data are usually used to distinguish request messages and response messages. For example, the Pixie tool or the ilogtail tool is used to distinguish request messages and response messages to calculate the response time of the application program. However, both of these methods have the technical problem of high resource occupancy rate in obtaining the response time of the message transmission end to the request message.
[0160] However, the embodiments of the present application provide a method for collecting the response time of an application, which obtains the response time of the application in a non-invasive manner through eBPF. For example, an eBPF program can be loaded into the client or the server, and the eBPF program can be integrated with the application. Then, the application is started, and the time when the client sends the first network packet is dynamically and continuously observed through the eBPF program of the client, as well as the time when the second network packet sent by the server is received. The time when the server sends the second network packet corresponding to the first network packet and the time when the server receives the first network packet are dynamically and continuously observed through the eBPF program of the server. Then, based on the time difference between the time when the client sends the first network packet and the time when the second network packet sent by the server is received, which is monitored by the eBPF program, the response time of the request message collected by the client is determined. Based on the time difference between the time when the server sends the second network packet corresponding to the first network packet and the time when the server receives the first network packet, which is monitored by the eBPF program, the response time of the request message collected by the server is determined. By collecting the RT of the application in a non-invasive manner through eBPF with extremely low resource occupancy, it is easy to find which applications have a high RT, which provides great convenience for problem positioning.
[0161] Figure 8 is a schematic diagram of an interaction process between a client and a server according to an embodiment of the present application. As Figure 8 shown, network packets can be transmitted between the client 801 and the server 802. During the operation of the application, the client 801 generates a request message, and the request message is split into multiple first network packets, as Figure 8 shown, the multiple first network packets can be the a-th network packet, the b-th network packet,..., the k-th network packet. Among them, the a-th network packet can be the first network packet of the current request message, and the k-th network packet can be the last network packet of the current request message. The multiple first network packets are sequentially transmitted to the server 802.
[0162] After each first network packet is received by the server 802, a second network packet corresponding to the first network packet can be generated and the generated second network packet is fed back to the client 801. Among them, as Figure 8 shown, the multiple second network packets generated by the server 802 can be the a'-th network packet, the b'-th network packet,..., the k'-th network packet. Among them, the a-th network packet corresponds to the a'-th network packet, and the k-th network packet corresponds to the k'-th network packet. The a-th network packet here corresponds to the first target network packet mentioned above, and the k'-th network packet corresponds to the second target network packet mentioned above.
[0163] In this embodiment, the response time of the request message collected on the client side can be calculated by the following formula:
[0164] ClientRT = T(response(last)) - T(request(first))
[0165] Wherein, ClientRT can be used to represent the response time of the request message collected on the client side, T(request(first)) can be used to represent the timestamp when the client sends the first first network packet, and T(response(last)) can be used to represent the timestamp when the client receives the last second network packet sent by the server. Among them, T(request(first)) and T(response(last)) are the network packet timestamps recorded on the client side.
[0166] In this embodiment, the response time of the request message collected on the server side can be calculated by the following formula:
[0167] ServerRT = T(response(last)) - T(request(first))
[0168] Wherein, ServerRT can be used to represent the response time of the request message collected on the server side, T(response(last)) can be used to represent the timestamp when the server sends the last second network packet, and T(request(first)) can be used to represent the timestamp when the server receives the first first network packet sent by the client. Among them, T(response(last)) and T(request(first)) are the network packet timestamps recorded on the server side.
[0169] In this embodiment, T(Packet) can be used to represent the time when a network packet is received or sent. Figure 9 It is a flowchart of a method for obtaining the reception time or transmission time of a network packet according to an embodiment of the present application. The method may include the following steps:
[0170] Step S901, initialize parameters.
[0171] In this embodiment, the eBPF program can be used to intrude into the client or the server, and then initialize the parameters to track the packet reception and transmission events of the client and the server.
[0172] Step S9202, trigger a packet transmission event.
[0173] In this embodiment, the client can be triggered to send a first network packet, and the server can be triggered to send a second network packet. The time when the client sends the first network packet is recorded, and the time when the server sends the second network packet is recorded.
[0174] Step S903: Trigger a packet reception event.
[0175] In this embodiment, the server can be triggered to receive the first network packet sent by the client, and the client can be triggered to receive the second network packet sent by the server. The time when the server receives the first network packet sent by the client is recorded, and the time when the client receives the second network packet sent by the server is recorded.
[0176] Step S904: Calculate the response time.
[0177] In this embodiment, when a first network packet and a second network packet are completed, the response time for sending the first network packet and receiving the second network packet can be calculated, where the first network packet and the second network packet correspond to each other.
[0178] Through the above steps S901 to S904, the response times of the client and the server can be obtained in a non-intrusive manner without parsing the network protocol to distinguish request information and response information, greatly reducing the resource occupancy rate.
[0179] Optionally, when there are too many request messages, since the resource occupancy rate is proportional to the number of requests, it may cause the problem that the response time of the collection application occupies too many resources. Based on this, the response time can be aggregated in the eBPF program in the kernel state to avoid frequent system calls and reduce the interference of the collection application to the original application. Figure 10 It is a flowchart of a method for aggregating the response time of an application program according to an embodiment of the present application. As Figure 10 shown, the method includes the following steps:
[0180] Step S1001: Initialize parameters.
[0181] In this embodiment, an eBPF program can be created and the eBPF program can be intruded into the client or the server.
[0182] Step S1002: Collect the response time within the collection period.
[0183] In this embodiment, the response time of multiple request messages at the message transmission end within the collection period can be collected.
[0184] Step S1003: Aggregate and process multiple response times.
[0185] In this embodiment, after collecting multiple response times, the multiple response times can be aggregated, for example, by adding up the multiple response times.
[0186] Step S1004: Determine the average response time within the cycle time based on the aggregation result and the number of multiple response times.
[0187] In this embodiment, the average response time within the cycle time can be determined by using the ratio of the aggregation result to the number of multiple response times.
[0188] In the above steps S1001 to S1004, by using the eBPF technology in the kernel state, the response time aggregation of the server port is performed, further reducing the resource occupancy rate.
[0189] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. And the collection, use, and processing of relevant data need to comply with the relevant laws, regulations, and standards of relevant countries and regions, and corresponding operation entrances are provided for users to choose to authorize or refuse.
[0190] It should be noted that for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that this application is not limited by the described action sequence, because according to this application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0191] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on such an understanding, the technical solution of this application, in essence, or the part that makes a contribution to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disc), and includes several instructions for causing a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods of the various embodiments of this application.
[0192] Embodiment 2
[0193] According to an embodiment of the present application, there is also provided an apparatus for collecting the response time of an application program for implementing the method for collecting the response time of the application program described above. Figure 11Schematic diagram of a device for collecting response time of an application according to an embodiment of the present application. As Figure 11 shown, the device 1100 for collecting response time of the application includes: a first monitoring unit 1101, a second monitoring unit 1102, a first determination unit 1103, and a second determination unit 1104.
[0194] The first monitoring unit 1101 is configured to monitor request messages generated on the client during the running of the application, where the request messages include a plurality of first network packets.
[0195] The second monitoring unit 1102 is configured to monitor response messages obtained by the server in response to the request messages, where the response messages include a plurality of second network packets, and there is a one-to-one correspondence between the plurality of second network packets and the plurality of first network packets.
[0196] The first determination unit 1103 is configured to determine a first timestamp of a first target network packet transmitted at the message transmission end among the plurality of first network packets, and a second timestamp of a second target network packet transmitted at the message transmission end among the plurality of second network packets, where the message transmission end includes the client and / or the server.
[0197] The second determination unit 1104 is configured to determine the response time of the request message collected by the message transmission end based on the first timestamp of the first target network packet and the second timestamp of the second target network packet.
[0198] It should be noted here that the above first monitoring unit 1101, second monitoring unit 1102, first determination unit 1103, and second determination unit 1104 correspond to steps S401 to S404 in Embodiment 1. The instances and application scenarios implemented by the four modules and the corresponding steps are the same, but are not limited to the content disclosed in the above Embodiment 1. It should be noted that the above modules or units can be hardware components or software components stored in a memory (for example, memory 104) and processed by one or more processors (for example, processors 102a, 102b,..., 102n), and the above modules can also be part of the device and can run in the computer terminal 10 provided in Embodiment 1.
[0199] It should be noted that the preferred implementation schemes involved in the above embodiments of the present application are the same as the schemes, application scenarios, and implementation processes provided in Embodiment 1, but are not limited to the schemes provided in Embodiment 1.
[0200] According to an embodiment of the present application, there is also provided a device for collecting response time of an application for implementing the above method for collecting response time of an application, Figure 12 Schematic diagram of another device for collecting response time of an application according to an embodiment of the present application. AsFigure 12 As shown in Figure 12 , the acquisition device 1200 for the response time of the application program includes: a third monitoring unit 1201, a first display unit 1202, and a second display unit 1203.
[0201] The third monitoring unit 1201 is configured to respond to a message monitoring instruction acting on the operation interface, monitor the request messages generated on the client during the running of the application program, and monitor the response messages obtained by the server in response to the request messages. Among them, the request messages include multiple first network packets, the response messages include multiple second network packets, and there is a one-to-one correspondence between the multiple second network packets and the multiple first network packets.
[0202] The first display unit 1202 is configured to display, on the operation interface, the first timestamp of the first target network packet transmitted at the message transmission end among the multiple first network packets, and the second timestamp of the second target network packet transmitted at the message transmission end among the multiple second network packets, where the message transmission end includes the client and / or the server.
[0203] The second display unit 1203 is configured to display, on the operation interface, the response time collected by the message transmission end for the request message, where the response time is determined based on the first timestamp of the first target network packet and the second timestamp of the second target network packet.
[0204] It should be noted here that the above-mentioned third monitoring unit 1201, first display unit 1202, and second display unit 1203 correspond to steps S501 to S503 in Embodiment 1. The instances and application scenarios implemented by the three modules and the corresponding steps are the same, but are not limited to the content disclosed in the above-mentioned Embodiment 1. It should be noted that the above-mentioned modules or units can be hardware components or software components stored in a memory (for example, memory 104) and processed by one or more processors (for example, processors 102a, 102b,..., 102n). The above-mentioned modules can also be part of the device and can run in the computer terminal 10 provided in Embodiment 1.
[0205] It should be noted that the preferred implementation schemes involved in the above embodiments of the present application are the same as the schemes, application scenarios, and implementation processes provided in Embodiment 1, but are not limited to the schemes provided in Embodiment 1.
[0206] According to an embodiment of the present application, there is also provided an acquisition device for the response time of an application program for implementing the above-mentioned acquisition method for the response time of an application program. Figure 13 It is a schematic diagram of another acquisition device for the response time of an application program according to an embodiment of the present application. As Figure 13As shown in the figure, the acquisition device 1300 for the response time of the application program includes: a first call unit 1301, a third determination unit 1302, a fourth determination unit 1303, and a second call unit 1304.
[0207] The first call unit 1301 is configured to monitor, by calling a first interface, the request message generated on the client during the running of the application program, and the response message obtained by monitoring the server's response to the request message. The first interface includes a first parameter, and the parameter value of the first parameter is the request message and the response message. The request message includes multiple first network packets, and the response message includes multiple second network packets. There is a one-to-one correspondence between the multiple second network packets and the multiple first network packets.
[0208] The third determination unit 1302 is configured to determine the first timestamp of the first target network packet transmitted at the message transmission end among the multiple first network packets, and the second timestamp of the second target network packet transmitted at the message transmission end among the multiple second network packets, where the message transmission end includes the client and / or the server.
[0209] The fourth determination unit 1303 is configured to determine the response time of the request message collected by the message transmission end based on the first timestamp of the first target network packet and the second timestamp of the second target network packet.
[0210] The second call unit 1304 is configured to output the response time by calling a second interface. The second interface includes a second parameter, and the parameter value of the second parameter is the response time.
[0211] It should be noted here that the above first call unit 1301, third determination unit 1302, fourth determination unit 1303, and second call unit 1304 correspond to steps S601 to S604 in Embodiment 1. The instances and application scenarios implemented by the four modules and the corresponding steps are the same, but are not limited to the content disclosed in the above Embodiment 1. It should be noted that the above modules or units can be hardware components or software components stored in a memory (for example, memory 104) and processed by one or more processors (for example, processors 102a, 102b,..., 102n). The above modules can also be part of the device and can run in the computer terminal 10 provided in Embodiment 1.
[0212] It should be noted that the preferred implementation schemes involved in the above embodiments of the present application are the same as the schemes, application scenarios, and implementation processes provided in Embodiment 1, but are not limited to the schemes provided in Embodiment 1.
[0213] Embodiment 3
[0214] Embodiments of the present application can provide a computer terminal, which can be any computer terminal device in a group of computer terminals. Optionally, in this embodiment, the above computer terminal can also be replaced with a terminal device such as a mobile terminal.
[0215] Optionally, in this embodiment, the above computer terminal can be located in at least one of multiple network devices in a computer network.
[0216] In this embodiment, the above computer terminal can execute the program code of the following steps in the method for collecting the response time of an application program: monitoring the request messages generated on the client during the running of the application program, where the request messages include multiple first network packets; monitoring the response messages obtained by the server in response to the request messages, where the response messages include multiple second network packets, and there is a one-to-one correspondence between the multiple second network packets and the multiple first network packets; determining the first timestamp of the first network packet in the request message transmitted at the message transmission end, and the second timestamp of the second network packet in the response message transmitted at the message transmission end, where the message transmission end includes the client and / or the server; and determining the response time of the request message collected by the message transmission end based on the first timestamp of the first network packet and the second timestamp of the second network packet.
[0217] Optionally, Figure 14 is a structural block diagram of a computer terminal according to an embodiment of the present application. As Figure 14 shown, the computer terminal C may include: one or more (only one is shown in the figure) processors 1402, a memory 1404, a storage controller, and a peripheral interface, where the peripheral interface is connected to a radio frequency module, an audio module, and a display.
[0218] Among them, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the method and device for collecting the response time of the application program in the embodiments of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, implements the above method for collecting the response time of the application program. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some instances, the memory may further include a memory remotely set relative to the processor, and these remote memories can be connected to the computer terminal C through a network. Examples of the above network include but are not limited to the Internet, an enterprise internal network, a local area network, a mobile communication network, and combinations thereof.
[0219] The processor can call the information and application programs stored in the memory through a transmission device to execute the following steps: Monitor the request messages generated on the client during the running of the application program, where the request messages include multiple first network packets; Monitor the response messages obtained by the server in response to the request messages, where the response messages include multiple second network packets, and there is a one-to-one correspondence between the multiple second network packets and the multiple first network packets; Determine the first timestamp of the first target network packet transmitted at the message transmission end among the multiple first network packets, and the second timestamp of the second target network packet transmitted at the message transmission end among the multiple second network packets, where the message transmission end includes the client and / or the server; Based on the first timestamp of the first target network packet and the second timestamp of the second target network packet, determine the response time of the request message collected by the message transmission end.
[0220] Optionally, the above-mentioned processor can also execute the program code of the following steps: Determine the first target network packet that is first transmitted among the multiple first network packets, and the second target network packet that is last transmitted among the multiple second network packets.
[0221] Optionally, the above-mentioned processor can also execute the program code of the following steps: Based on the message sending event triggered by the first target network packet on the client, determine the first timestamp when the first target network packet is sent on the client; Based on the message receiving event triggered by the second target network packet on the client, determine the second timestamp when the second target network packet is received on the client.
[0222] Optionally, the above-mentioned processor can also execute the program code of the following steps: Obtain the first time difference between the first timestamp of the first target network packet and the second timestamp of the second target network packet; Based on the first time difference, determine the response time of the request message collected by the client.
[0223] Optionally, the above-mentioned processor can also execute the program code of the following steps: In response to the number of connections corresponding to multiple request messages within a time period being less than or equal to the connection number threshold, determine the first time difference as the response time of the request message collected by the client.
[0224] Optionally, the above-mentioned processor can also execute the program code of the following steps: In the kernel state of the operating system platform where the application program runs, perform an aggregation process on the multiple first time differences corresponding to multiple request messages within a time period to obtain the response time of the request message collected by the client.
[0225] Optionally, the above-mentioned processor may also execute the program code of the following steps: in response to the number of connections corresponding to multiple request messages within a time period being greater than the connection number threshold, in the kernel state, obtain the number of multiple first time differences within the time period; based on the number of multiple first time differences, determine the first average time difference of the first time differences within the time period; and determine the first average time difference as the response time collected by the client for the request message.
[0226] Optionally, the above-mentioned processor may also execute the program code of the following steps: based on the message reception event triggered by the first target network packet on the server, determine the first timestamp at which the first target network packet is received on the server; based on the message transmission event triggered by the second target network packet on the server, determine the second timestamp at which the second target network packet is sent on the server.
[0227] Optionally, the above-mentioned processor may also execute the program code of the following steps: obtain the second time difference between the second timestamp of the second target network packet and the first timestamp of the first target network packet; based on the second time difference, determine the response time collected by the server for the request message.
[0228] Optionally, the above-mentioned processor may also execute the program code of the following steps: in response to the number of connections corresponding to multiple request messages within a time period being less than or equal to the connection number threshold, determine the second time difference as the response time collected by the server for the request message.
[0229] Optionally, the above-mentioned processor may also execute the program code of the following steps: in the kernel state of the operating system platform on which the application program runs, perform an aggregation process on multiple second time differences corresponding to multiple request messages within a time period to obtain the response time collected by the server for the request message.
[0230] Optionally, the above-mentioned processor may also execute the program code of the following steps: in response to the number of connections corresponding to multiple request messages within a time period being greater than the connection number threshold, in the kernel state, obtain the number of multiple second time differences within the time period; based on the number of multiple second time differences, determine the second average time difference of the second time differences within the time period; and determine the second average time difference as the response time collected by the server for the request message.
[0231] Optionally, the above-mentioned processor may also execute the program code of the following steps: when the next request message of the request message starts to be transmitted, or when the client is closed, determine the first target network packet that is first transmitted among multiple first network packets, and the second target network packet that is last transmitted among multiple second network packets.
[0232] Optionally, the above processor may also execute the program code of the following steps: in response to the response time of the application at the message transmission end being greater than the response time threshold, output a corresponding prompt message, where the prompt message is used to at least identify the application.
[0233] By adopting the embodiment of the present application, a scheme for collecting the response time of an application is provided. By monitoring the first timestamp of the first target network packet included in the request message of the client during the operation of the application at the message transmission end, and the second timestamp of the second target network packet in the response message of the server at the message transmission end, the response time of the application at the message transmission end can be determined. There is no need to distinguish the request message and the response message by parsing the packet protocol, which greatly reduces the resource occupancy rate for obtaining the response time collected by the message transmission end for the request message, improves the efficiency of determining the response time collected by the message transmission end for the request message, and solves the technical problem of high resource occupancy rate for obtaining the response time of the message transmission end to the request message.
[0234] Those of ordinary skill in the art can understand that Figure 14 The structure shown is only schematic. The computer terminal can also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a handheld computer, and a mobile Internet device (abbreviated as MID), a portable intelligent terminal device (abbreviated as PAD), and other terminal devices. Figure 14 It does not limit the structure of the above electronic device. For example, the computer terminal C may also include more or fewer components (such as a network interface, a display device, etc.) than those shown in Figure 14 or have a different configuration from that shown in Figure 14 shown.
[0235] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the relevant hardware of the terminal device through a program, and the program can be stored in a computer-readable storage medium. The storage medium may include: a flash drive, a read-only memory (abbreviated as ROM), a random access memory (abbreviated as RAM), a magnetic disk, or an optical disc, etc.
[0236] Embodiment 4
[0237] The embodiment of the present application also provides a storage medium. Optionally, in this embodiment, the above storage medium can be used to save the program code executed by the method for collecting the response time of the application provided in the first embodiment above.
[0238] Optionally, in this embodiment, the above storage medium may be located in any one of the computer terminals in the computer terminal group in the computer network, or in any one of the mobile terminals in the mobile terminal group.
[0239] Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps: monitoring request messages generated on the client during the running of the application program, where the request messages include a plurality of first network packets; monitoring response messages obtained by the server in response to the request messages, where the response messages include a plurality of second network packets, and there is a one-to-one correspondence between the plurality of second network packets and the plurality of first network packets; determining a first timestamp at which a first target network packet in the plurality of first network packets is transmitted at the message transmission end, and a second timestamp at which a second target network packet in the plurality of second network packets is transmitted at the message transmission end, where the message transmission end includes the client and / or the server; and determining the response time of the request message collected by the message transmission end based on the first timestamp of the first target network packet and the second timestamp of the second target network packet.
[0240] The serial numbers of the embodiments of the present application above are only for description and do not represent the superiority or inferiority of the embodiments.
[0241] In the above embodiments of the present application, the descriptions of the respective embodiments have their own emphases. For parts not detailed in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
[0242] In several embodiments provided by the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, and the indirect coupling or communication connection of the units or modules may be in an electrical or other form.
[0243] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0244] In addition, each functional unit in various embodiments of the present application may be integrated into one processing unit, may exist physically alone for each unit, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of a software functional unit.
[0245] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, may be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present application. The foregoing storage medium includes: various media such as USB flash drives, read-only memories (ROMs), random access memories (RAMs), mobile hard disks, magnetic disks, or optical discs that can store program codes.
[0246] The above are only the preferred embodiments of the present application. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present application, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present application.
Claims
1. A method for collecting the response time of an application program, characterized in that, Including: Monitoring request messages generated on the client during the running of the monitoring application, where the request messages include multiple first network packets; Monitoring response messages obtained by the server in response to the request messages, where the response messages include multiple second network packets, and there is a one-to-one correspondence between the multiple second network packets and the multiple first network packets; Determining a first timestamp at which a first target network packet among the multiple first network packets is transmitted at the message transmission end, and a second timestamp at which a second target network packet among the multiple second network packets is transmitted at the message transmission end, where the message transmission end includes the client and / or the server; Based on the first timestamp of the first target network packet and the second timestamp of the second target network packet, determining the response time of the request message collected by the message transmission end.
2. The method according to claim 1, characterized in that The multiple first network packets are sequentially transmitted at the message transmission end, and the multiple second network packets are sequentially transmitted at the message transmission end, where the method further includes: Determining the first target network packet that is first transmitted among the multiple first network packets, and the second target network packet that is last transmitted among the multiple second network packets.
3. The method according to claim 2, wherein The message transmission end is the client, and determining the first timestamp at which a first target network packet among the multiple first network packets is transmitted at the message transmission end, and the second timestamp at which a second target network packet among the multiple second network packets is transmitted at the message transmission end includes: Based on a message sending event triggered by the first target network packet on the client, determining the first timestamp at which the first target network packet is sent on the client; Based on a message receiving event triggered by the second target network packet on the client, determining the second timestamp at which the second target network packet is received on the client.
4. The method according to claim 3, wherein Based on the first timestamp of the first target network packet and the second timestamp of the second target network packet, determining the response time of the request message collected by the message transmission end includes: Obtaining a first time difference between the second timestamp of the second target network packet and the first timestamp of the first target network packet; Based on the first time difference, determining the response time of the request message collected by the client.
5. The method according to claim 4, wherein Based on the first time difference, determining the response time of the request message collected by the client includes: In response to the number of connections corresponding to multiple request messages within a time period being less than or equal to a connection number threshold, determining the first time difference as the response time of the request message collected by the client.
6. The method according to claim 4, wherein Based on the first time difference, determining the response time of the request message collected by the client includes: In the kernel state of the operating system platform on which the application runs, aggregating multiple first time differences corresponding to multiple request messages within a time period to obtain the response time of the request message collected by the client.
7. The method according to claim 6, wherein In the kernel state of the operating system platform on which the application runs, aggregating multiple first time differences corresponding to multiple request messages within a time period to obtain the response time collected by the client for the request message, including: In response to the number of connections corresponding to multiple request messages within the time period being greater than a connection number threshold, in the kernel state, obtaining the number of multiple first time differences within the time period; Based on the number of multiple first time differences, determining a first average time difference of the first time differences within the time period; Determining the first average time difference as the response time collected by the client for the request message.
8. The method according to claim 2, wherein The message transmission end is the server. Among them, determining the first timestamp at which the first target network packet in the multiple first network packets is transmitted at the message transmission end, and the second timestamp at which the second target network packet in the multiple second network packets is transmitted at the message transmission end, including: Based on the message reception event triggered by the first target network packet on the server, determining the first timestamp at which the first target network packet is received on the server; Based on the message sending event triggered by the second target network packet on the server, determining the second timestamp at which the second target network packet is sent on the server.
9. The method according to claim 8, wherein Based on the first timestamp of the first target network packet and the second timestamp of the second target network packet, determining the response time collected by the message transmission end for the request message, including: Obtaining a second time difference between the second timestamp of the second target network packet and the first timestamp of the first target network packet; Based on the second time difference, determining the response time collected by the server for the request message.
10. The method according to claim 9, characterized in that, Based on the second time difference, determining the response time collected by the server for the request message, including: In response to the number of connections corresponding to multiple request messages within the time period being less than or equal to the connection number threshold, determining the second time difference as the response time collected by the server for the request message.
11. The method according to claim 9, wherein Based on the second time difference, determining the response time collected by the server for the request message, including: In the kernel state of the operating system platform on which the application runs, aggregating multiple second time differences corresponding to multiple request messages within a time period to obtain the response time collected by the server for the request message.
12. The method according to claim 11, wherein In the kernel state of the operating system platform on which the application runs, aggregating multiple second time differences corresponding to multiple request messages within a time period to obtain the response time collected by the server for the request message, including: In response to the number of connections corresponding to multiple request messages within the time period being greater than a connection number threshold, in the kernel state, obtaining the number of multiple second time differences within the time period; Based on the number of multiple second time differences, determining a second average time difference of the second time differences within the time period; Determine the second average time difference as the response time of the request message collected by the server.
13. The method according to claim 2, wherein Determining a first target network packet that is first transmitted among the plurality of first network packets, and a second target network packet that is last transmitted among the plurality of second network packets, includes: When the next request message of the request message starts to be transmitted, or when the client is closed, determining a first target network packet that is first transmitted among the plurality of first network packets, and a second target network packet that is last transmitted among the plurality of second network packets.
14. The method according to any one of claims 1 to 12, characterized in that, The method further includes: In response to the response time of the application program at the message transmission end being greater than the response time threshold, output a corresponding prompt message, where the prompt message is used to at least identify the application program.
15. A method for collecting the response time of an application program, characterized in that, Including: In response to a message monitoring instruction acting on the operation interface, monitoring a request message generated by an application program during operation on the client, and monitoring a response message obtained by the server in response to the request message. The request message includes a plurality of first network packets, the response message includes a plurality of second network packets, and there is a one-to-one correspondence between the plurality of second network packets and the plurality of first network packets; On the operation interface, display a first timestamp of the first target network packet among the plurality of first network packets transmitted at the message transmission end, and a second timestamp of the second target network packet among the plurality of second network packets transmitted at the message transmission end, where the message transmission end includes the client and / or the server; On the operation interface, display the response time of the request message collected by the message transmission end, where the response time is determined based on the first timestamp of the first target network packet and the second timestamp of the second target network packet.
16. A method for collecting the response time of an application program, characterized in that, Including: By invoking a first interface to monitor a request message generated by an application program during operation on the client, and monitoring a response message obtained by the server in response to the request message. The first interface includes a first parameter, and the parameter value of the first parameter is the request message and the response message. The request message includes a plurality of first network packets, the response message includes a plurality of second network packets, and there is a one-to-one correspondence between the plurality of second network packets and the plurality of first network packets; Determine a first timestamp of the first target network packet among the plurality of first network packets transmitted at the message transmission end, and a second timestamp of the second target network packet among the plurality of second network packets transmitted at the message transmission end, where the message transmission end includes the client and / or the server; Based on the first timestamp of the first target network packet and the second timestamp of the second target network packet, determine the response time of the request message collected by the message transmission end; Output the response time by invoking a second interface, where the second interface includes a second parameter, and the parameter value of the second parameter is the response time.
17. A collection system for the response time of an application program, characterized in that, Including: A client and a server, where The client is used to determine the first timestamp when the first target network packet in the request message is sent on the client, and the second timestamp when the second target network packet in the response message is received on the client. Wherein, the request message is generated on the client during the operation of the application program, the response message is obtained by the server in response to the request message, the request message includes a plurality of first network packets, the response message includes a plurality of second network packets, and there is a one-to-one correspondence between the plurality of second network packets and the plurality of first network packets; based on the first timestamp of the first target network packet on the client and the second timestamp of the second target network packet on the client, determine the response time of the request message collected by the client. The server is used to determine the first timestamp when the first target network packet is received on the server, and the second timestamp when the second target network packet is sent on the server; based on the first timestamp of the first target network packet on the server and the second timestamp of the second target network packet on the server, determine the response time of the request message collected by the server.
18. An electronic device, characterized in that, It includes: A memory storing an executable program; A processor for running the program, wherein when the program runs, it executes the method according to any one of claims 1 to 16.