Traffic playback method and device, storage medium, electronic equipment and program product
By obtaining and locally cacheing the traffic tree from the distributed cache during traffic playback, the problems of high error rate and low efficiency caused by sorting by call time in the prior art are solved, and higher playback accuracy and efficiency are achieved.
Patent Information
- Application Number
- CN202411954616.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-12-27
AI Technical Summary
In the prior art, traffic playback is performed by sorting service nodes by calling time, resulting in high error rate and low matching of wrong traffic.
By receiving the call request generated during the traffic playback process, the corresponding traffic tree is obtained from the distributed cache based on the identification information in the request, and cached it to the local cache for traffic playback. During playback, the called service node is removed to avoid duplicate matches and network transmission consumption.
It improves the accuracy of traffic playback, reduces the error rate, avoids traffic consumption conflicts, and improves playback efficiency.
Smart Images

Figure CN119728511A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the distributed field, and specifically, to a traffic playback method, device, storage medium, electronic device and program product. Background Art
[0002] In the related art, during the playback of recorded traffic, the recorded traffic is generally simply sorted in time at the backend of the recording platform, and then the application container calls the backend API (Application Programming Interface) during playback, and the backend matches the resource name and returns the recorded traffic. However, when the same resource is called multiple times, in different branches, asynchronously, and other scenarios, it is easy to match the wrong traffic, and the efficiency is low. In the related art, the traceId+spanId mechanism is used at the backend of the recording and playback platform to perform preliminary traffic level positioning, combine time sorting, match resource names, and return recorded traffic. However, obtaining recorded traffic through the backend API of the recording and playback platform: there are repeated traffic search operations, and the network transmission consumption is low and efficient, which can easily cause playback timeouts. If the same traffic case is played back at the same time, there will be a traffic consumption conflict problem.
[0003] Currently, no effective solution has been proposed to the problem that the error rate of traffic replay is high when the service nodes are sorted by the calling time in the related technology to replay the traffic. Summary of the invention
[0004] The main purpose of the present application is to provide a traffic playback method, device, storage medium, electronic device and program product to solve the problem in the related art that traffic playback is performed by sorting service nodes according to call time, resulting in a high error rate in traffic playback.
[0005] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a traffic playback method is provided. The method includes: receiving a first call request generated during the traffic playback process, based on the identification information carried in the first call request, obtaining the traffic tree associated with the identification information from the distributed cache, and obtaining the first traffic tree, wherein the distributed cache caches: M traffic trees, the traffic tree is used to record the traffic generated by the transaction processing process during each transaction, and the traffic obtained by recording the traffic generated by the transaction processing process, each service node in the traffic tree records: transaction identification, node identification of the service node, parent node identification of the service node, and the parent node identification of each service node includes: node identification associated with the parent node of the service node, and the first call request includes: a call request for calling a service generated during the traffic playback process; caching the first traffic tree to a local cache, wherein the cache location of the local cache is different from that of the distributed cache; performing traffic playback based on the local cache and the first traffic tree, and removing the called service node from the local cache during the traffic playback process.
[0006] Furthermore, each of the service nodes also includes: a resource identifier, performing traffic replay based on the local cache and the first traffic tree, and removing the called service node from the local cache during the traffic replay process, including: performing traffic replay based on the local cache and the first traffic tree, determining the resource identifier associated with the service node called at the current moment during the traffic replay process to obtain a first resource identifier; determining the service node containing the first resource identifier in the first traffic tree to obtain a first service node; calling the first service node, and after calling the first service node, removing the first service node from the first traffic tree of the local cache.
[0007] Furthermore, each of the service nodes also includes: a simulation identifier, wherein the simulation identifier is used to indicate whether calling the service node requires simulated return information. When the simulation identifier in any service node in the first traffic tree indicates that calling the service node requires simulated return information, the service node is a leaf node of the first traffic tree. When the simulation identifier of any service node in the first traffic tree indicates that calling the service node does not require simulated return information, the service node has a child service node, and the child service node refers to a service node actively called by the service node. In the process of calling the first service node, it also includes: when the simulation identifier of the first service node indicates that calling the first service node requires simulated return information, returning simulated information; when the simulation identifier of the first service node indicates that calling the first service node does not require simulated return information, splicing the node identifier in the identification information and the node identifier of the first service node to obtain a spliced node identifier, and generating a second call request based on the spliced node identifier, wherein the second call request is used to request a call to the child service node of the first service node.
[0008] Furthermore, the spliced node identifier at least includes: a preset separator, which is used to separate the node identifier in the identification information and the node identifier of the first service node. After removing the first service node from the first traffic tree in the local cache, it also includes: responding to the second call request, segmenting the spliced node identifier based on the preset separator to obtain a segmentation result; extracting the node identifier of the first service node from the segmentation result; based on the node identifier of the first service node and the transaction identifier in the identification information, obtaining the first service node and all child service nodes of the first service node from the distributed cache to obtain a second traffic tree, and caching the second traffic tree to the local cache; performing traffic playback based on the local cache and the second traffic tree, and removing the called service node from the local cache during the traffic playback process.
[0009] Furthermore, each of the service nodes also includes: input and output parameters recorded during the traffic recording process, and during the traffic playback process based on the local cache and the first traffic tree, it also includes: during the traffic playback process, collecting the input and output parameters generated during the service call process through a pre-established pile point to obtain playback data, wherein the pile point includes: a plug-in for collecting the input and output parameters generated during the service call process; comparing the playback data with the input and output parameters recorded by the service node in the first traffic tree to obtain a comparison result, wherein the comparison result is used to analyze whether there are any abnormalities in the transactions associated with the first traffic tree.
[0010] Furthermore, based on the identification information carried in the first call request, a traffic tree associated with the identification information is obtained from the distributed cache to obtain a first traffic tree, including: reading the transaction identifier in the identification information, the first transaction identifier; determining the traffic tree containing the first transaction identifier in the distributed cache to obtain an initial traffic tree; reading the node identifier in the identification information to obtain a first node identifier; in the initial traffic tree, intercepting the service node associated with the first node identifier and all child service nodes of the service node to obtain the first traffic tree.
[0011] Furthermore, before obtaining the first traffic tree from the distributed cache based on the identification information carried in the first call request, it also includes: reading the traffic obtained by recording the traffic generated by the transaction processing process from the traffic recording and playback platform to obtain the target traffic; assembling the target traffic into a traffic tree, and uploading the traffic tree to the distributed cache with the transaction identification associated with the traffic tree as the key of the key-value pair and the traffic tree as the value of the key-value pair.
[0012] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a traffic playback device is provided. The device includes: a processing unit, which is used to receive a first call request generated during the traffic playback process, and based on the identification information carried in the first call request, obtain the traffic tree associated with the identification information from the distributed cache to obtain a first traffic tree, wherein the distributed cache caches: M traffic trees, the traffic tree is used to record the traffic generated by the transaction processing process during each transaction, and the traffic obtained by recording the traffic generated during the transaction processing process, each service node in the traffic tree records: transaction identification, node identification of the service node, parent node identification of the service node, and the parent node identification of each service node includes: node identification associated with the parent node of the service node, and the first call request includes: a call request for calling a service generated during the traffic playback process; a cache unit, which is used to cache the first traffic tree to a local cache, wherein the cache location of the local cache is different from that of the distributed cache; a playback unit, which is used to perform traffic playback based on the local cache and the first traffic tree, and remove the called service node from the local cache during the traffic playback process.
[0013] Furthermore, each of the service nodes also includes: a resource identifier, and the playback unit includes: a first determination subunit, used to perform traffic replay based on the local cache and the first traffic tree, and determine the resource identifier associated with the service node called at the current moment during the traffic playback process to obtain a first resource identifier; a second determination subunit, used to determine the service node containing the first resource identifier in the first traffic tree to obtain the first service node; a first processing subunit, used to call the first service node, and after calling the first service node, remove the first service node from the first traffic tree of the local cache.
[0014] Furthermore, each of the service nodes also includes: a simulation identifier, wherein the simulation identifier is used to indicate whether calling the service node requires simulated return information. When the simulation identifier in any service node in the first traffic tree indicates that calling the service node requires simulated return information, the service node is a leaf node of the first traffic tree. When the simulation identifier of any service node in the first traffic tree indicates that calling the service node does not require simulated return information, the service node has a child service node, and the child service node refers to a service node actively called by the service node. The first processing sub-unit also includes: a return module, which is used to return simulated information during the process of calling the first service node when the simulation identifier of the first service node indicates that calling the first service node requires simulated return information; a processing module, which is used to splice the node identifier in the identification information and the node identifier of the first service node when the simulation identifier of the first service node indicates that calling the first service node does not require simulated return information, to obtain a spliced node identifier, and generate a second call request based on the spliced node identifier, wherein the second call request is used to request a call to the child service node of the first service node.
[0015] Furthermore, the spliced node identifier at least includes: a preset separator, which is used to separate the node identifier in the identification information and the node identifier of the first service node, and the playback unit also includes: a segmentation subunit, which is used to respond to the second call request after removing the first service node from the first traffic tree in the local cache, and to segment the spliced node identifier based on the preset separator to obtain a segmentation result; an extraction subunit, which is used to extract the node identifier of the first service node from the segmentation result; a second processing subunit, which is used to obtain the first service node and all sub-service nodes of the first service node from the distributed cache based on the node identifier of the first service node and the transaction identifier in the identification information, to obtain a second traffic tree, and cache the second traffic tree to the local cache; a third processing subunit, which is used to perform traffic replay based on the local cache and the second traffic tree, and remove the called service node from the local cache during the traffic replay process.
[0016] Furthermore, each of the service nodes also includes: input and output parameters recorded during the traffic recording process, and the playback unit also includes: a collection subunit, which is used to collect the input and output parameters generated in the service call process through a pre-established pile point during the traffic playback process based on the local cache and the first traffic tree, and obtain playback data, wherein the pile point includes: a plug-in for collecting the input and output parameters generated in the service call process; a comparison subunit, which is used to compare the playback data with the input and output parameters recorded by the service node in the first traffic tree to obtain a comparison result, wherein the comparison result is used to analyze whether there are any abnormalities in the transactions associated with the first traffic tree.
[0017] Furthermore, the processing unit includes: a first reading subunit, used to read the transaction identifier in the identification information, the first transaction identifier; a determination subunit, used to determine the traffic tree containing the first transaction identifier in the distributed cache to obtain an initial traffic tree; a second reading subunit, used to read the node identifier in the identification information to obtain a first node identifier; an interception subunit, used to intercept the service node associated with the first node identifier and all sub-service nodes of the service node in the initial traffic tree to obtain the first traffic tree.
[0018] Furthermore, the traffic playback device also includes: a reading unit, used to obtain the traffic tree associated with the identification information from the distributed cache based on the identification information carried in the first call request, and before obtaining the first traffic tree, read the traffic obtained by recording the traffic generated by the transaction processing process from the traffic recording and playback platform to obtain the target traffic; an uploading unit, used to assemble the target traffic into a traffic tree, and upload the traffic tree to the distributed cache with the transaction identification associated with the traffic tree as the key of the key-value pair and the traffic tree as the value of the key-value pair.
[0019] According to another aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the traffic playback method.
[0020] According to another aspect of the present application, an electronic device is provided, comprising: a memory storing an executable program; and a processor for running the program, wherein the traffic playback method is executed when the program is running.
[0021] According to another aspect of the present application, a computer program product is provided, comprising computer instructions, which implement the steps of the traffic playback method when executed by a processor.
[0022] In an embodiment of the present application, a first call request generated during a traffic playback process is received, and based on the identification information carried in the first call request, a traffic tree associated with the identification information is obtained from a distributed cache to obtain a first traffic tree, wherein the distributed cache caches: M traffic trees, the traffic tree is used to record the traffic generated during each transaction processing process, and the traffic obtained by recording the traffic generated during the transaction processing process, each service node in the traffic tree records: a transaction identifier, a node identifier of the service node, and a parent node identifier of the service node, and the parent node identifier of each service node includes: a node identifier associated with a parent node that calls the service node, and the first call request includes: a call request for calling a service generated during the traffic playback process; the first traffic tree is cached in a local cache, wherein the local cache and the distributed cache have different cache locations; traffic is replayed based on the local cache and the first traffic tree, and the called service nodes are removed from the local cache during the traffic playback process, thereby solving the technical problem in the related art of replaying traffic by sorting service nodes by call time, and having a high error rate in traffic playback.
[0023] In the present invention, the corresponding traffic tree is obtained from the distributed cache according to the identification information of the call request, and the traffic tree is cached in the local cache for traffic playback, thereby avoiding the traffic playback method of sorting the service nodes by the call time in the related technology. When the same service node is called multiple times, in different branches, asynchronously, etc., it is easy to match the wrong traffic, thereby achieving the technical effect of improving the accuracy of traffic playback. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0025] Figure 1 A hardware structure block diagram of a computer terminal for implementing a traffic playback method is shown;
[0026] Figure 2 is a flow chart of a traffic playback method provided according to an embodiment of the present application;
[0027] Figure 3 is a structural diagram of a traffic playback system provided according to an embodiment of the present application;
[0028] Figure 4 It is a service call link diagram provided according to an embodiment of the present application;
[0029] Figure 5 A service call link diagram including stubs provided according to an embodiment of the present application;
[0030] Figure 6 is a schematic diagram of a traffic playback device provided according to an embodiment of the present application;
[0031] Figure 7 It is a structural block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0032] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0033] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0034] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following explanations:
[0035] mock: simulation, that is, simulating the information returned by the interface, replacing the information it needs to return with the existing information. For example, for some unstable, difficult to construct, and unfinished object interfaces, the test can be completed by returning pre-set mock data.
[0036] traceId: transaction identifier. In a transaction, the traceIds of all service nodes are consistent and unique, which means that a transaction data can be located through traceId.
[0037] spanId, service node identifier. In a transaction, each service node that is called will generate a spanId, which is equivalent to the unique identifier of each service node in this transaction.
[0038] parentSpanId: The spanId of the parent node of the current service node, so that the call tree diagram of this transaction can be constructed through traceId+spanId+parentSpanId. Note that the parentSpanId of the first node is empty because it has no parent node.
[0039] Traffic: Traffic in traffic recording and playback mainly refers to the input and output messages and other additional information generated by calls between service nodes.
[0040] Traffic recording and playback: Traffic recording is to save the input and output messages and additional information of each service node to a database when a normal transaction occurs. When replaying, the same transaction is initiated, but some tags are used to declare that this transaction is a playback transaction. When encountering some service nodes that need to be mocked, the recorded traffic output will be returned without actual service node calls.
[0041] It should be noted that the collected information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in this application are information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data are in compliance with relevant laws, regulations and standards, necessary confidentiality measures are taken, and public order and good customs are not violated, and corresponding operation entrances are provided for users to choose to authorize or refuse. For example, an interface is set up between this system and relevant users or institutions to provide users with corresponding operation entrances for users to choose to agree or refuse the results of automated decision-making; if the user chooses to refuse, the expert decision-making process will be entered.
[0042] Example 1
[0043] According to an embodiment of the present application, a method embodiment of a traffic replay method is also 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 an order different from that shown here.
[0044] The method embodiment provided in Embodiment 1 of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computer terminal (or mobile device) for implementing a traffic playback method. Figure 1 As shown, the computer terminal 10 (or mobile device) may include one or more (102a, 102b, ..., 102n are used to illustrate) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also 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. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0045] It should be noted that the one or more processors 102 and / or other data processing circuits mentioned above may generally be referred to as "data processing circuits" herein. The data processing circuit may be embodied in whole or in part as software, hardware, firmware or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10 (or mobile device). As involved in the embodiments of the present application, the data processing circuit is used as a processor control (e.g., the selection of a variable resistor terminal path connected to an interface). The memory 104 may be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the flow playback method 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, implementing the above-mentioned flow playback method. 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 memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof. The transmission device 106 is used to receive or send data via a network. A specific example of the above-mentioned network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, RF) module, which is used to communicate with the Internet wirelessly. The display can be, for example, a touch screen liquid crystal display (LCD), which enables a user to interact with the user interface of the computer terminal 10 (or mobile device).
[0046] Under the above operating environment, this application provides Figure 2 Traffic playback method shown. Figure 2 It is a flow chart of the traffic playback method according to Example 1 of the present application.
[0047] Step S201, receiving the first call request generated during the traffic playback process, based on the identification information carried in the first call request, obtaining the traffic tree associated with the identification information from the distributed cache, and obtaining the first traffic tree, wherein the distributed cache caches: M traffic trees, the traffic tree is used to record the traffic generated during each transaction processing process, and the traffic obtained by recording the traffic generated during the transaction processing process, each service node in the traffic tree records: the transaction identifier, the node identifier of the service node, and the parent node identifier of the service node, the parent node identifier of each service node includes: the node identifier associated with the parent node of the service node, and the first call request includes: a call request for calling the service generated during the traffic playback process.
[0048] The above-mentioned first call request may include: a call request for calling a service generated during the traffic playback process, for example, a call request for the traffic recording and playback platform to call the first node (root service node) of the traffic tree of a transaction. The request context of the first call request may include the playback identifier, the playback result id, the recorded traceId (i.e., the transaction identifier), and spanIdLink (spanId (node identifier) of the first node). For example, a playback identifier is found in the context of the first call request, and it is determined that it is an external call itself, so traffic initialization is required; (whether it is an external call itself can be determined by the stub type or context, such as the dubbo (distributed service framework) framework plug-in, which can intercept the called request in the remote procedure call proxy abstract caller, or judge from the value of the address information of the remote peer (remote caller), and then the recorded traceId (transaction identifier) can be obtained from the context of the first call request, and then the cache tool class is called to read the traffic tree json corresponding to the traceId from the distributed cache, and then the traffic tree level is located according to the spanIdLink of the context of the first call request. The current level traffic tree is obtained to obtain the first traffic tree.
[0049] Step S202: Cache the first traffic tree into a local cache, wherein the cache locations of the local cache and the distributed cache are different.
[0050] In this embodiment, the first traffic tree can be cached in a container memory of the local cache to avoid traffic consumption conflicts caused by multiple playbacks of the same case and simultaneous calls of multiple services; at the same time, it can also reduce traffic level matching, traffic node matching and network transmission consumption.
[0051] Step S203: replay traffic based on the local cache and the first traffic tree, and remove the called service node from the local cache during the traffic replay process.
[0052] In this embodiment, traffic playback can be performed based on the local cache and the first traffic tree. After the current level traffic tree of the local cache is successfully matched, the traffic node can be removed from the local cache to avoid the problem of multiple matching when the same node is repeatedly called.
[0053] In this embodiment, through the above steps, the corresponding traffic tree is obtained from the distributed cache according to the identification information of the call request, and the traffic tree is cached in the local cache for traffic playback, avoiding the traffic playback in the related art by sorting the service nodes by the call time. When the same service node is called multiple times, in different branches, asynchronously, etc., it is easy to match the wrong traffic, thereby achieving the technical effect of improving the accuracy of traffic playback. And then solve the technical problem of high error rate of traffic playback in the related art by sorting the service nodes by the call time.
[0054] Figure 3 is a structural diagram of a traffic playback system provided according to an embodiment of the present application, such as Figure 3 As shown, it includes: 1. The user triggers traffic playback to the backend of the recording and playback platform; 2. The backend of the recording and playback platform uploads the recorded traffic to the distributed cache, reads the recorded traffic from the database of the recording and playback platform, assembles the recorded traffic into a traffic tree in json format, sorts it by the recording start timestamp, and then uploads it to the distributed cache, with the key being the traceId of the recorded traffic; 3. The backend of the recording and playback platform initiates a first-node playback call; 4. Application container 1 reads the recorded traffic from the distributed cache; 5. Container 1 calls container 2 service; 6. Application container 2 reads the recorded traffic from the distributed cache; 7 returns the playback first-node output.
[0055] Figure 4 is a service call link diagram provided according to an embodiment of the present application, such as Figure 4 As shown, the first node is service 1 of container 1; service 1 calls database operation 3 of container 1 and service 2 of container 2; service 2 of container 2 calls database operation 4 of container 2. Figure 5 is a service call link diagram including stubs provided according to an embodiment of the present application, such as Figure 5 As shown in the figure, the nodes enclosed by the rectangular box are deployed with the code of the container in the rectangular box. When service 1 calls service 2, it passes through two dubbo stubs. The mock actions all occur when calling other service nodes, such as Figure 5 The two database pile points and the dubbo pile point when service 1 calls service 2.
[0056] In this embodiment, Figure 5 Taking the traffic tree corresponding to the service call link shown in the figure as an example, the process of traffic playback is explained. Figure 5The traffic tree corresponding to the service call link shown is:
[0057]
[0058]
[0059]
[0060] The backend of the recording and playback platform initiates a service call (first call request) to the playback environment based on the information of the first node. At this time, the first call request context may include the playback identifier, playback result id, recorded traceId, and spanIdLink (spanId of the first node);
[0061] In the example of the traffic tree provided in this embodiment:
[0062] Recording traceId: 650828fdaaaaaaaaaaaaaaaaa54ed0037;
[0063] spanIdLink:6bfe5ccccccc0037.
[0064] Container 1 Service 1 receives the service call request and finds that the request context contains a playback identifier, indicating that mock processing is required; it obtains the recorded traffic from the distributed cache according to the recorded traceId; Container 1 Service 1 performs mock based on the obtained traffic and the actual sub-call that occurred during the playback, and finally returns the service call result; the processing logic of Container 2 Service 2 is basically the same as Service 1, except that the caller has changed from the recording and playback platform to Service 1. The following uses the example of the traffic tree above to explain in detail what operations have occurred in Container 1 Service 1 and Container 2 Service 2.
[0065] 1. Specific operations of container 1:
[0066] (1) Container 1 receives a call request from service 1. The request is captured by the dubbo framework plug-in, and the context shows that it has a playback flag, so it is determined that it is an external call to itself, so traffic initialization is required; (To determine whether it is an external call to itself, you can determine it by the stub type or context. For example, the dubbo framework plug-in can intercept the called request in com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker, or determine it from the value of RpcContext.attachments.remotePeer).
[0067] (2) Traffic initialization: First, obtain the recorded traceId from the context, and then call the cache tool class to read the traffic tree json corresponding to the traceId from the distributed cache;
[0068] (3) Locate the traffic tree level according to the context spanIdLink. At this time, spanIdlink = 6bfe5cccccccc0037, which corresponds to the spanId of the first node service 1, so the current level traffic tree 1 obtained is the subInvocations (sub-call) of the first node:
[0069]
[0070]
[0071] (4) Encapsulate the recorded traceId, spanIdLink, playback result id, and current hierarchical traffic tree into the mockContext object, and then call the public method MockContextHolder.set(mockContext) (a method for managing simulation data and configuration information related to service calls in the traffic playback system) to complete the local traffic cache. Among them, the MockContextHolder.set method first obtains the playback spanId of the current node, and sets it to the ConcurrentMap type Map object with the playback spanId as the key; it should be noted that the playback spanId is used as the key to solve the key value conflict that causes traffic caching and consumption anomalies in scenarios such as simultaneous playback of the same case and simultaneous calling of a container by the same case; the Map object can be declared as ConcurrentMap<String,MockContext> CURRENT_MOCK_CONTEXT (a concurrent mapping table used to store simulation context information of the current playback case in traffic playback or simulation test scenarios). The use of ConcurrentMap (in traffic playback technology, used to cache and manage simulation context information during playback) type is to solve problems such as deadlock and dirty read that may occur under multi-threading.
[0072] Optionally, each service node also includes: a resource identifier, performing traffic replay based on the local cache and the first traffic tree, and removing the called service node from the local cache during the traffic replay process, including: performing traffic replay based on the local cache and the first traffic tree, determining the resource identifier associated with the service node called at the current moment during the traffic replay process to obtain the first resource identifier; determining the service node containing the first resource identifier in the first traffic tree to obtain the first service node; calling the first service node, and after calling the first service node, removing the first service node from the first traffic tree in the local cache.
[0073] Take the recorded traceId (transaction identifier): 650828fdaaaaaaaaaaaaaaaaa54ed0037 and spanIdLink: 6bfe5ccccccc0037 of the first traffic tree as an example for explanation.
[0074] (1) Since service 1 does not need a mock, it starts to execute the logic of service 1 itself. Service 1 first calls database operation 3;
[0075] (2) The database plug-in stub intercepts the call to operation 3, calls the MockContextHolder.getByCurrSpanId() method (a method used to obtain mock data related to the current service call), obtains the current playback spanId, and gets the mockContext cached locally (simulated context. Since the newSpanId function of the database plug-in has not been called at this time, the current playback spanId is still the spanId used when the first node initializes the mockContext).
[0076] (3) Traverse the current level traffic tree 1 (corresponding to the first traffic tree) and find the first node whose recorded resource name (i.e., resource identifier) is consistent with the currently called resource name; the resource name here is database operation 3, so the recorded traffic node obtained (corresponding to the first service node) is:
[0077]
[0078] (4) Remove the successfully matched node (or the node that has been called during the traffic playback process, i.e., the first service node) database operation 3 from the current hierarchical traffic tree 1, thereby avoiding the problem of traffic reuse caused by calling database operation 3 next time, and reducing the number of repeated traffic matches; the current hierarchical traffic tree 1 becomes:
[0079]
[0080]
[0081] After calling the first service node, the first service node is removed from the first traffic tree in the local cache, so as to avoid the problem of repeated use of traffic caused by calling the first service node next time, and reduce the number of repeated traffic matches.
[0082] Optionally, in the traffic playback method provided in the embodiment of the present application, each service node also includes: a simulation identifier, the simulation identifier is used to indicate whether calling the service node requires simulated return information. When the simulation identifier in any service node in the first traffic tree indicates that calling the service node requires simulated return information, the service node is a leaf node of the first traffic tree. When the simulation identifier of any service node in the first traffic tree indicates that calling the service node does not require simulated return information, the service node has a child service node, and the child service node refers to a service node actively called by the service node. In the process of calling the first service node, it also includes: when the simulation identifier of the first service node indicates that calling the first service node requires simulated return information, returning simulated information; when the simulation identifier of the first service node indicates that calling the first service node does not require simulated return information, the node identifier in the identification information and the node identifier of the first service node are spliced to obtain a spliced node identifier, and a second call request is generated based on the spliced node identifier, wherein the second call request is used to request a call to the child service node of the first service node.
[0083] For example, the value of needMock (corresponding to the simulation identifier) in the traffic node (i.e., service node) of database operation 3 is true, indicating that a mock is needed; set the return of database operation 3 to the responseRecord value of the recorded traffic (corresponding to the simulated information), skip the actual execution of database operation 3, and directly return the mock value; before returning the mock value of database operation 3, the actual input parameters of this database operation 3, mock status and other information can be packaged as a queue message and pushed to the recording and playback platform for comparison processing; after service 1 obtains the return (Mock) of database operation 3, it continues to execute and calls up dubbo type container 2 service 2; the dubbo plug-in stub of container 1 intercepts the call of service 2. Get MockContext through the current playback spanId, traverse the current level traffic tree 1, and find the recorded traffic of service 2:
[0084]
[0085]
[0086] Remove the traffic node of service 2 from the current level traffic tree 1, and the current level traffic tree 1 becomes an empty array;
[0087] The value of needMock in the traffic node of service 2 is false, indicating that mock is not needed. The spanIdLink in the context is updated, and the recorded spanId of service 2 is spliced. At this time, spanIdLink changes from 6bfe5ccccccc0037, which is only the spanId of the first node, to 6bfe5ccccccc0037&&ed8bbbbbbbbb3f1c, which is the spanId of the first node plus the spanId of service 2 (corresponding to the spliced node identifier); (&& is used as a delimiter to facilitate subsequent cutting. It is not necessary to use &&, as long as it is easy to distinguish).
[0088] Initiate an actual call request for service 2 (corresponding to the second call request), and then set the return of service 2 to the return message obtained by replaying the actual call;
[0089] The actual input message, actual output message, mock status and other information of service 2 are packaged into a queue message and pushed to the recording and playback platform for comparison processing to analyze whether there are any abnormalities in the transaction;
[0090] After service 1 obtains the actual call return of service 2, all logical processing of service 1 is completed, and the MockContextHolder.remove() method is called (a method used to clean up the mock data context related to the current service call), and the locally cached traffic mockContext (simulation context) is removed from CURRENT_MOCK_CONTEXT (current simulation context) (i.e., the first traffic tree is removed from the local cache). Before calling the next layer of nodes, the recorded spanId of the current node is spliced to spanIdLink, that is, the node identifier in the identification information and the node identifier of the first service node are equivalent to caching the current playback traffic level, which can reduce the number of traffic matches and improve the efficiency of traffic playback.
[0091] Optionally, the spliced node identifier at least includes: a preset separator, the preset separator is used to separate the node identifier in the identification information and the node identifier of the first service node, and after removing the first service node from the first traffic tree in the local cache, it also includes: responding to the second call request, segmenting the spliced node identifier based on the preset separator to obtain a segmentation result; extracting the node identifier of the first service node from the segmentation result; based on the node identifier of the first service node and the transaction identifier in the identification information, obtaining the first service node and all sub-service nodes of the first service node from the distributed cache to obtain a second traffic tree, and caching the second traffic tree to the local cache; replaying the traffic based on the local cache and the second traffic tree, and removing the called service node from the local cache during the traffic playback process. The following is an example of the specific operation of container 2:
[0092] (1) Container 2 receives a call request from service 2. The request is captured by the dubbo framework plug-in. From the context of the second call request, it is found that there is a playback flag. It is determined that it is an external call to itself, so traffic initialization is required;
[0093] (2) Traffic initialization: First, obtain the recorded traceId from the context, and then call the cache tool class to read the traffic tree json corresponding to the traceId from the distributed cache;
[0094] (3) Locate the traffic tree level according to the context spanIdLink. At this time, the spanIdLink value is 6bfe5ccccccc0037&&ed8bbbbbbbbb3f1c. Cut the spanIdLink by && (corresponding to the preset delimiter), first get the subInvocations corresponding to the first spanId, that is, the subInvocations of service 1; then search for the subInvocations of the second spanId in the subInvocations of service 1, that is, the subInvocations of service 2; so the current level traffic tree 2 (corresponding to the second traffic tree) obtained is the subInvocations of service 2;
[0095]
[0096] (4) Encapsulate the recorded traceId, spanIdLink, playback result id, and current level traffic tree 2 into the MockContext object, and then call the public method MockContextHolder.set(mockContext) to complete the local traffic cache. Then, service 2 calls database operation 4. The database plug-in stub intercepts the call of operation 4, traverses the current level traffic tree 2, and finds the first node whose recorded resource name is consistent with the current call resource name; the resource name here is database operation 4, so the recorded traffic node obtained is:
[0097]
[0098]
[0099] (5) Remove the successfully matched node database operation 4 from the current level traffic tree 2;
[0100] (6) The value of needMock in the traffic node of database operation 4 is true, indicating that a mock is needed. Set the return value of database operation 4 to the responseRecord value of the recorded traffic, skip the actual execution of database operation 4, and directly return the mock value.
[0101] (7) Before returning the mock value of database operation 4, the actual input parameters of this database operation 4, the mock situation and other information are packaged into a queue message and pushed to the recording and playback platform for comparison processing;
[0102] (8) After service 2 obtains the return (mock) of database operation 4, it ends the logical processing, removes the locally cached mockContext, and returns the output message of service 2.
[0103] In this embodiment, the next layer of nodes calls and performs traffic playback based on splicing the recorded spanId of the current node to spanIdLink, thereby avoiding traffic matching errors and achieving the technical effect of reducing the error rate of traffic playback.
[0104] Optionally, each service node also includes: input and output parameters recorded during the traffic recording process, and during the traffic playback process based on the local cache and the first traffic tree, it also includes: during the traffic playback process, collecting the input and output parameters generated during the service call process through a pre-established pile point to obtain playback data, wherein the pile point includes: a plug-in for collecting the input and output parameters generated during the service call process; comparing the playback data with the input and output parameters recorded by the service node in the first traffic tree to obtain a comparison result, wherein the comparison result is used to analyze whether there are any abnormalities in the transactions associated with the first traffic tree.
[0105] like Figure 5 As shown, in this embodiment, a corresponding plug-in can be established according to the framework to be monitored. The plug-in can declare which methods need to be stubbed, and the stub method will record its input and output parameters and other information; for example, if you need to record the call of dubbo service, you can create a dubbo plug-in, and the stub point is declared as xx.dubbo.monitor.support.MonitorFilter (dubbo filter); the stub point is not unique, as long as the service call will pass through. For example, if a traffic monitoring station needs to be built on a highway, the monitoring station should be built at a location that vehicles must pass through on the highway, rather than on a ramp or non-highway urban road.
[0106] When service 1 calls service 2, it passes through two dubbo pile points. This is because the calls from service 1 to service 2 and service 2 to service 1 are all through the API of the dubbo framework, and both pass through the MonitorFilter pile point. Traffic initialization occurs when the service is called up, for example, the first dubbo pile point in front of service 1 and service 2 will do traffic initialization; Mock actions occur when other service nodes are called up, for example, the two database pile points and the dubbo pile point when service 1 calls service 2; in this embodiment, the playback data can be compared with the input and output parameters recorded in the traffic recording to obtain a comparison result. According to the difference between the playback data and the records in the traffic recording process, it is determined whether there is an abnormality in the transaction, for example, whether the transaction is wrong, so as to achieve the purpose of accurately verifying whether there is an abnormality in the transaction.
[0107] Optionally, in the traffic replay method provided in the embodiment of the present application, based on the identification information carried in the first call request, a traffic tree associated with the identification information is obtained from the distributed cache to obtain a first traffic tree, including: reading the transaction identifier in the identification information, the first transaction identifier; determining the traffic tree containing the first transaction identifier in the distributed cache to obtain an initial traffic tree; reading the node identifier in the identification information to obtain a first node identifier; in the initial traffic tree, intercepting the service node associated with the first node identifier and all child service nodes of the service node to obtain the first traffic tree.
[0108] In this embodiment, the recorded traceId (corresponding to the first transaction identifier) can be first obtained from the first call request context, and then the cache tool class is called to read the traffic tree json corresponding to the traceId from the distributed cache. The traffic tree level is located according to the context's spanIdLink (corresponding to the first node identifier). At this time, spanIdlink = 6bfe5ccccccc0037, corresponding to the spanId of the first node service 1, so the current level traffic tree 1 (corresponding to the first traffic tree) obtained is the subInvocations (sub-call) of the first node:
[0109]
[0110]
[0111] Encapsulate the recorded traceId, spanIdLink, playback result id, and current level traffic tree into the MockContext object, and then call the public method MockContextHolder.set(mockContext) to complete the local traffic cache. The MockContextHolder.set method first obtains the playback spanId of the current node, and sets it to the ConcurrentMap type Map object with the playback spanId as the key. The traffic level is located by traceId+spanId, and the traffic tree corresponding to the call request is obtained, achieving the technical effect of traffic positioning.
[0112] Optionally, in the traffic playback method provided in the embodiment of the present application, before obtaining the first traffic tree by obtaining the traffic tree associated with the identification information from the distributed cache based on the identification information carried in the first call request, it also includes: reading the traffic obtained by recording the traffic generated by the transaction processing process from the traffic recording and playback platform to obtain the target traffic; assembling the target traffic into a traffic tree, and uploading the traffic tree to the distributed cache with the transaction identification associated with the traffic tree as the key of the key-value pair and the traffic tree as the value of the key-value pair.
[0113] For example, Figure 3 As shown, users can select the traffic cases that need to be replayed on the recording and playback platform web page, triggering immediate playback or scheduled playback. After receiving the playback request, the recording and playback platform can first read the recorded traffic from the database of the recording and playback platform, and then assemble the recorded traffic into a traffic tree in json format, sort it by the recording start timestamp, and then upload it to the distributed cache. The key is the traceId (transaction identifier) of the recorded traffic, and the value is the traffic tree. The recorded traffic is cached in the distributed cache with the recorded traceId as the key, which is convenient for each container to read and improve the efficiency of traffic playback.
[0114] In this embodiment, through the traceId+spanIdLink mechanism, the recorded traceId is used as the key to cache the recorded traffic to the distributed cache, which can facilitate the reading of each container. The recorded traceId and spanIdLink are passed through the context to ensure that the recorded traffic obtained by each container and node through the recorded traceId during playback is consistent; before calling the next layer of nodes, the recorded spanId of the current node is spliced to the spanIdLink, which is equivalent to caching the current playback traffic level, which can reduce the number of traffic matches.
[0115] In this embodiment, local cache + playback parent node spanId is used as the key. When the node is called up (such as the recording and playback platform calls up service 1, service 1 calls up service 2), the local traffic cache is initialized. The traffic is cached locally, which can reduce network transmission consumption. The current level traffic tree of the local cache removes the traffic node after the match is successful, which can avoid the problem of multiple matches when the same node is repeatedly called. The spanId of the parent node (entry node, such as service 1 and service 2) during playback is used as the cache key to avoid traffic consumption conflicts (recording traceId as key, recording spanId as key). : Playing back the same case at the same time will conflict; Playing back traceID: Synchronous calls to multiple services in the same container will conflict); Using the spanId of the parent node during playback as the key for local caching, the child node (i.e., child service node) obtains the current spanId before calling newSpanId; Since newSpanId has not been called yet, the current spanId obtained by the child node is still the playback spanId of the parent node; Therefore, the local traffic cache obtained by the child node through the current spanId is the same as the local cache written by the parent node, thus realizing traffic sharing between parent and child nodes and between brother child nodes.
[0116] In this embodiment, the traffic level is located through traceId+spanId, combined with timestamp sorting and resource name matching, so that the correct traffic can be 100% matched during normal playback; the traffic is cached in the container memory through the current playback spanId, which can avoid traffic consumption conflicts caused by multiple playbacks of the same case and simultaneous calls of multiple services; at the same time, it can also reduce traffic level matching, traffic node matching and network transmission consumption, and the mock efficiency is significantly higher than the backend API method; spanIdLink is equivalent to caching the current playback traffic level, which can reduce the number of traffic matches; the parent node initializes the local traffic cache after calling newSpanId, and the child node obtains the local traffic cache before calling newSpanId, which solves the traffic sharing problem between parent and child nodes and brother nodes.
[0117] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0118] Example 2
[0119] The embodiment of the present application also provides a traffic playback device. It should be noted that the traffic playback device of the embodiment of the present application can be used to execute the traffic playback method provided in the embodiment of the present application. The traffic playback device provided in the embodiment of the present application is introduced below.
[0120] According to an embodiment of the present application, a device for implementing the above-mentioned traffic playback method is also provided. Figure 6 is a schematic diagram of a flow playback device provided according to an embodiment of the present application, such as Figure 6 As shown, the device includes: a processing unit 61, a cache unit 62 and a playback unit 63.
[0121] In the traffic playback device provided in the embodiment of the present application, the processing unit 61 is used to receive the first call request generated during the traffic playback process, and based on the identification information carried in the first call request, obtain the traffic tree associated with the identification information from the distributed cache to obtain the first traffic tree, wherein the distributed cache caches: M traffic trees, the traffic tree is used to record the traffic generated during each transaction processing process, and the traffic obtained by recording the traffic generated during the transaction processing process, each service node in the traffic tree records: transaction identification, node identification of the service node, parent node identification of the service node, and the parent node identification of each service node includes: node identification associated with the parent node of the service node, and the first call request includes: a call request for calling the service generated during the traffic playback process; the cache unit 62 is used to cache the first traffic tree to the local cache, wherein the cache location of the local cache is different from that of the distributed cache; the playback unit 63 is used to perform traffic playback based on the local cache and the first traffic tree, and remove the called service node from the local cache during the traffic playback process. Thus, the technical problem of high error rate of traffic playback in the related technology of sorting service nodes by call time for traffic playback is solved. In this embodiment, the corresponding traffic tree is obtained from the distributed cache according to the identification information of the call request, and the traffic tree is cached in the local cache for traffic playback, thereby avoiding the traffic playback method of sorting the service nodes by call time in the related technology. When the same service node is called multiple times, in different branches, asynchronously, etc., it is easy to match the wrong traffic, thereby achieving the technical effect of improving the accuracy of traffic playback.
[0122] Optionally, in the traffic replay device provided in the embodiment of the present application, each service node also includes: a resource identifier, and the replay unit includes: a first determination subunit, used to perform traffic replay based on the local cache and the first traffic tree, and determine the resource identifier associated with the service node called at the current moment during the traffic replay process to obtain the first resource identifier; a second determination subunit, used to determine the service node containing the first resource identifier in the first traffic tree to obtain the first service node; a first processing subunit, used to call the first service node, and after calling the first service node, remove the first service node from the first traffic tree in the local cache.
[0123] Optionally, in the traffic replay device provided in the embodiment of the present application, each service node also includes: a simulation identifier, the simulation identifier is used to indicate whether calling the service node requires simulated return information. When the simulation identifier in any service node in the first traffic tree indicates that calling the service node requires simulated return information, the service node is a leaf node of the first traffic tree. When the simulation identifier of any service node in the first traffic tree indicates that calling the service node does not require simulated return information, the service node has a child service node, and the child service node refers to a service node actively called by the service node. The first processing sub-unit also includes: a return module, which is used to return simulated information during the process of calling the first service node when the simulation identifier of the first service node indicates that calling the first service node requires simulated return information; a processing module, which is used to splice the node identifier in the identification information and the node identifier of the first service node when the simulation identifier of the first service node indicates that calling the first service node does not require simulated return information, to obtain the spliced node identifier, and generate a second call request based on the spliced node identifier, wherein the second call request is used to request a call to the child service node of the first service node.
[0124] Optionally, in the traffic replay device provided in the embodiment of the present application, the spliced node identifier at least includes: a preset separator, which is used to separate the node identifier in the identification information and the node identifier of the first service node, and the replay unit also includes: a segmentation subunit, which is used to remove the first service node from the first traffic tree in the local cache, and then respond to the second call request to segment the spliced node identifier based on the preset separator to obtain a segmentation result; an extraction subunit, which is used to extract the node identifier of the first service node from the segmentation result; a second processing subunit, which is used to obtain the first service node and all sub-service nodes of the first service node from the distributed cache based on the node identifier of the first service node and the transaction identifier in the identification information, to obtain a second traffic tree, and cache the second traffic tree to the local cache; a third processing subunit, which is used to perform traffic replay based on the local cache and the second traffic tree, and remove the called service node from the local cache during the traffic replay process.
[0125] Optionally, in the traffic playback device provided in the embodiment of the present application, each service node also includes: input and output parameters recorded during the traffic recording process, and the playback unit also includes: a collection subunit, which is used to collect the input and output parameters generated in the service call process through a pre-established pile point during the traffic playback process based on the local cache and the first traffic tree, and obtain playback data, wherein the pile point includes: a plug-in for collecting the input and output parameters generated in the service call process; a comparison subunit, which is used to compare the playback data with the input and output parameters recorded by the service node in the first traffic tree to obtain a comparison result, wherein the comparison result is used to analyze whether there are any abnormalities in the transactions associated with the first traffic tree.
[0126] Optionally, in the traffic replay device provided in the embodiment of the present application, the processing unit includes: a first reading sub-unit, used to read the transaction identifier in the identification information, the first transaction identifier; a determination sub-unit, used to determine the traffic tree containing the first transaction identifier in the distributed cache, and obtain an initial traffic tree; a second reading sub-unit, used to read the node identifier in the identification information, and obtain the first node identifier; an interception sub-unit, used to intercept the service node associated with the first node identifier and all child service nodes of the service node in the initial traffic tree, and obtain the first traffic tree.
[0127] Optionally, in the traffic replay device provided in the embodiment of the present application, the traffic replay device also includes: a reading unit, used to obtain a traffic tree associated with the identification information from the distributed cache based on the identification information carried in the first call request, and before obtaining the first traffic tree, read the traffic obtained by recording the traffic generated by the transaction processing process from the traffic recording and playback platform to obtain the target traffic; an uploading unit, used to assemble the target traffic into a traffic tree, and upload the traffic tree to the distributed cache with the transaction identification associated with the traffic tree as the key of the key-value pair and the traffic tree as the value of the key-value pair.
[0128] It should be noted that the above-mentioned processing unit 61, cache unit 62 and playback unit 63 correspond to steps S201 to S203 in Example 1, and the examples and application scenarios implemented by the two modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above-mentioned Example 1. It should be noted that the above-mentioned modules or units can be hardware components or software components stored in a memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n), and the above-mentioned modules can also be part of the device and can be run in the computer terminal 10 provided in Example 1.
[0129] Example 3
[0130] An embodiment of the present application may provide an electronic device, Figure 7is a structural block diagram of an electronic device according to an embodiment of the present application. Figure 7 As shown, the electronic device may include: one or more ( Figure 7 Only one is shown) processor 702, memory 704, storage controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display. Among them, the memory can be used to store software programs and modules, such as program instructions / modules corresponding to the method and device in the embodiment of the present application, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, realizing the above method. 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 memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network and a combination thereof. The processor can call the information and application programs stored in the memory through a transmission device to execute the traffic playback method provided in the first embodiment of the present invention.
[0131] By using the embodiment of the present application, a solution for traffic playback is provided. According to the identification information of the call request, the corresponding traffic tree is obtained from the distributed cache, and the traffic tree is cached in the local cache for traffic playback, which avoids the traffic playback in the related art by sorting the service nodes by the call time. When the same service node is called multiple times, in different branches, asynchronously, etc., it is easy to match the wrong traffic, thereby achieving the technical effect of improving the accuracy of traffic playback. This solves the technical problem of the high error rate of traffic playback in the related art by sorting the service nodes by the call time.
[0132] It can be understood by those skilled in the art that Figure 7 The structure shown is for illustration only, and the electronic device may also be a smart phone, a tablet computer, a PDA, a mobile Internet device (MID), a PAD or other terminal device. Figure 7 The structure of the electronic device is not limited. Figure 7 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 7 Different configurations shown.
[0133] A person 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 hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0134] Example 4
[0135] The embodiment of the present application also provides a storage medium. Optionally, in this embodiment, the above storage medium can be used to store the program code executed by the traffic playback method provided in the above embodiment 1. Optionally, in this embodiment, the above storage medium can 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.
[0136] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing the program steps of the traffic playback method.
[0137] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0138] In the above-mentioned embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. In the several embodiments provided in 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 schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. 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 mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0139] 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 they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, each functional unit in each embodiment of the present application may be integrated into a processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated units may be implemented in the form of hardware or in the form of software functional units.
[0140] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0141] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A traffic playback method, characterized in that: include: Receive a first call request generated during the traffic playback process, and based on the identification information carried in the first call request, obtain a traffic tree associated with the identification information from a distributed cache to obtain a first traffic tree, wherein the distributed cache caches: M traffic trees, the traffic tree is used to record the traffic generated during each transaction processing process, and the traffic obtained by recording the traffic generated during the transaction processing process, each service node in the traffic tree records: a transaction identifier, a node identifier of the service node, and a parent node identifier of the service node, and the parent node identifier of each service node includes: a node identifier associated with a parent node that calls the service node, and the first call request includes: a call request for calling a service generated during the traffic playback process; caching the first traffic tree into a local cache, wherein the local cache and the distributed cache have different cache locations; Traffic replay is performed based on the local cache and the first traffic tree, and the called service node is removed from the local cache during the traffic replay process.
2. The traffic playback method according to claim 1, characterized in that: Each of the service nodes also includes: a resource identifier, performing traffic playback based on the local cache and the first traffic tree, and removing the called service node from the local cache during the traffic playback process, including: Performing traffic replay based on the local cache and the first traffic tree, determining a resource identifier associated with the service node called at the current moment during the traffic replay process, and obtaining a first resource identifier; Determine a service node having the first resource identifier in the first traffic tree to obtain a first service node; The first service node is called, and after calling the first service node, the first service node is removed from the first traffic tree in the local cache.
3. The traffic playback method according to claim 2, characterized in that: Each of the service nodes also includes: a simulation identifier, the simulation identifier is used to indicate whether calling the service node requires simulation return information. When the simulation identifier in any service node in the first traffic tree indicates that calling the service node requires simulation return information, the service node is a leaf node of the first traffic tree. When the simulation identifier of any service node in the first traffic tree indicates that calling the service node does not require simulation return information, the service node has a child service node, and the child service node refers to a service node actively called by the service node. In the process of calling the first service node, it also includes: Returning simulated information when the simulation identifier of the first service node indicates that calling the first service node requires simulated return information; When the simulation identifier of the first service node indicates that calling the first service node does not require simulation return information, the node identifier in the identification information and the node identifier of the first service node are concatenated to obtain a concatenated node identifier, and a second call request is generated based on the concatenated node identifier, wherein the second call request is used to request a call to a sub-service node of the first service node.
4. The traffic playback method according to claim 3, characterized in that: The spliced node identifier at least includes: a preset separator, the preset separator is used to separate the node identifier in the identification information and the node identifier of the first service node, and after removing the first service node from the first traffic tree in the local cache, further includes: In response to the second calling request, segment the spliced node identifiers based on the preset separator to obtain a segmentation result; Extracting a node identifier of the first service node from the segmentation result; Based on the node identifier of the first service node and the transaction identifier in the identifier information, acquiring the first service node and all child service nodes of the first service node from the distributed cache to obtain a second traffic tree, and caching the second traffic tree to the local cache; Traffic replay is performed based on the local cache and the second traffic tree, and the called service node is removed from the local cache during the traffic replay process.
5. The traffic playback method according to claim 1, characterized in that: Each of the service nodes also includes: input and output parameters recorded during the traffic recording process, and during the traffic playback process based on the local cache and the first traffic tree, also includes: During the traffic playback process, the input and output parameters generated during the service call process are collected through the pre-established pile points to obtain the playback data, wherein the pile points include: a plug-in for collecting the input and output parameters generated during the service call process; The playback data is compared with the input and output parameters recorded by the service node in the first traffic tree to obtain a comparison result, wherein the comparison result is used to analyze whether there is an abnormality in the transaction associated with the first traffic tree.
6. The traffic playback method according to claim 1, characterized in that: Based on the identification information carried in the first call request, acquiring a traffic tree associated with the identification information from a distributed cache to obtain a first traffic tree includes: Reading a transaction identifier, a first transaction identifier, from the identification information; Determine a traffic tree containing the first transaction identifier in the distributed cache to obtain an initial traffic tree; Reading the node identifier in the identification information to obtain a first node identifier; In the initial traffic tree, the service node associated with the first node identifier and all child service nodes of the service node are intercepted to obtain the first traffic tree.
7. The traffic playback method according to claim 1, characterized in that: Before obtaining the first traffic tree based on the identification information carried in the first call request and obtaining the traffic tree associated with the identification information from the distributed cache, the method further includes: The traffic generated by the transaction processing process is recorded and read from the traffic recording and playback platform to obtain the target traffic; The target traffic is assembled into a traffic tree, and the transaction identifier associated with the traffic tree is used as the key of a key-value pair, and the traffic tree is used as the value of the key-value pair, and the traffic tree is uploaded to the distributed cache.
8. A flow playback device, characterized in that: include: A processing unit is used to receive a first call request generated during a traffic playback process, and based on the identification information carried in the first call request, obtain a traffic tree associated with the identification information from a distributed cache to obtain a first traffic tree, wherein the distributed cache caches: M traffic trees, the traffic tree is used to record the traffic generated during each transaction processing process, and the traffic obtained by recording the traffic generated during the transaction processing process, each service node in the traffic tree records: a transaction identifier, a node identifier of the service node, and a parent node identifier of the service node, and the parent node identifier of each service node includes: a node identifier associated with a parent node that calls the service node, and the first call request includes: a call request for calling a service generated during the traffic playback process; A cache unit, configured to cache the first traffic tree to a local cache, wherein the local cache and the distributed cache have different cache locations; A playback unit is used to perform traffic playback based on the local cache and the first traffic tree, and remove the called service node from the local cache during the traffic playback process.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the traffic playback method described in any one of claims 1 to 7.
10. An electronic device, characterized in that: include: A memory storing an executable program; A processor is used to run the program, wherein the program executes the traffic playback method described in any one of claims 1 to 7 when running.
11. A computer program product comprising computer instructions, characterized in that: When the computer instructions are executed by a processor, the steps of the traffic playback method described in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Service request processing method and device, electronic equipment and storage medium
CN114629883A
Non-intrusive strategy reconstruction method and device based on traffic recording and playback
CN115391223A
Replacement method for guaranteeing MEC service continuity
CN117336808A
Just-In-Time Distributed Video Cache
US20140025837A1
Method and system for expediting peer-to-peer content delivery with improved network utilization
US7818402B1