A transaction recording method under distributed architecture
By setting user identification information and generating distributed tracking IDs under a distributed architecture, the problem of client transactions being unable to be associated with link tracking results is solved, transaction records are clear and fast, and data support analysis is provided.
Patent Information
- Application Number
- CN202211239635.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-11
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2042-10-11
AI Technical Summary
In a distributed architecture, client transactions cannot be associated with link tracking results, making it impossible to record transaction execution clearly and quickly.
By setting user identification information, such as token and cookie, when the client initiates a request, the proxy server determines whether data collection is required, generates a distributed tracking ID, and records the relationship between the user identification ID and the distributed tracking ID to the database to ensure transactions. Record integrity.
It realizes the correlation between user transactions and link tracking results, clearly records transaction execution, and provides data support for user operation success and performance analysis.
Smart Images

Figure CN115665098B
Abstract
Description
Technical Field
[0001] The invention discloses a method, which relates to the technical field of distributed data collection, and specifically to a transaction recording method under a distributed architecture. Background Art
[0002] In today's Internet, there are systems with a huge user base. In order to ensure that user requests can be responded to promptly and accurately, system service providers mostly use distributed architecture to deploy services to achieve high throughput, high concurrency, low latency and load balancing of requests. Although the distributed architecture solves the single point problem and performance capacity problems of the traditional monolithic architecture, it also brings other problems. For example, if a user wants to complete a certain operation, such as adding a new piece of data, the client will execute a transaction to add the new data. To execute a new transaction, the client usually needs to call one or more interfaces together to complete it. The system executes a large number of transactions every day, and the execution of these transactions cannot be clearly and quickly recorded. Summary of the invention
[0003] In view of the problems of the prior art, the present invention provides a transaction recording method under a distributed architecture, which can solve the problem that client transactions and link tracking results cannot be associated, and thus the entire transaction cannot be recorded.
[0004] The specific scheme proposed by the present invention is:
[0005] The present invention provides a transaction recording method under a distributed architecture, wherein a client initiates a request, and after receiving the request through a proxy server, it is determined whether data collection is required according to a preset rule.
[0006] If data collection is required, a call chain tracing context is generated. According to the user identification information in the request header, the corresponding user identification information is selected to generate the user identification ID. At the same time, a globally unique distributed tracing ID is generated for the request, and the relationship between the user identification ID and the distributed tracing ID is recorded in the database. The business code logic continues to be executed.
[0007] After receiving the request forwarded by the proxy server through the business execution server, it determines whether the distributed tracking ID is contained in it. If it is contained, the data corresponding to the request is recorded; otherwise, only the business code logic is executed.
[0008] Furthermore, in the transaction recording method under a distributed architecture, when a request is sent through a client, user identification information is set in the request header to generate a user identification ID to mark the user's identity.
[0009] Furthermore, in the transaction recording method under a distributed architecture, setting the user identification information in the request header includes:
[0010] The set user identification information is token information and cookie information.
[0011] Furthermore, in the transaction recording method under a distributed architecture, after receiving the request through the proxy server, judging whether data collection is required according to a preset rule includes:
[0012] Check the user identification information in the request header, and check whether there is a user identification ID corresponding to the user identification information in the cache. If it exists, use the existing identification ID. Otherwise, user token information and cookie information are preferred to generate user identification ID, followed by client IP and browser information.
[0013] If data collection is required, a distributed tracking ID is generated and the relationship between the user ID and the distributed tracking ID is recorded in the database. Otherwise, the business logic continues to be executed.
[0014] Furthermore, in the transaction recording method under a distributed architecture, after receiving a request sent by the proxy service, the business execution server determines whether a distributed tracking ID is included, including:
[0015] When the distributed tracing ID exists, the request execution status is recorded in the database; otherwise, only the business logic is executed.
[0016] The present invention also provides a transaction recording device under a distributed architecture, including an agent service module and a business execution service module.
[0017] After receiving the request initiated by the client through the proxy server, the proxy service module determines whether data collection is required according to the pre-set rules.
[0018] If data collection is required, a call chain tracing context is generated. According to the user identification information in the request header, the corresponding user identification information is selected to generate the user identification ID. At the same time, a globally unique distributed tracing ID is generated for the request, and the relationship between the user identification ID and the distributed tracing ID is recorded in the database. The business code logic continues to be executed.
[0019] After receiving the request forwarded by the proxy server through the business execution server, the business execution service module determines whether the request contains the distributed tracking ID. If so, it records the data corresponding to the request; otherwise, it only executes the business code logic.
[0020] Furthermore, in the transaction recording device under the distributed architecture, the request header received by the proxy service module is provided with user identification information for generating a user identification ID to mark the identity of the user.
[0021] Furthermore, the user identification information set in the request header in the transaction recording device under the distributed architecture includes token information and cookie information.
[0022] Furthermore, after receiving a request through the proxy server, the proxy service module in the transaction recording device under the distributed architecture determines whether data collection is required according to a preset rule, including:
[0023] Check the user identification information in the request header, and check whether there is a user identification ID corresponding to the user identification information in the cache. If it exists, use the existing identification ID. Otherwise, user token information and cookie information are preferred to generate user identification ID, followed by client IP and browser information.
[0024] If data collection is required, a distributed tracking ID is generated and the relationship between the user ID and the distributed tracking ID is recorded in the database. Otherwise, the business logic continues to be executed.
[0025] Furthermore, the business execution service module in the transaction recording device under a distributed architecture determines whether a distributed tracking ID is included after receiving a request sent by a proxy service through a business execution service end, including:
[0026] When the distributed tracing ID exists, the request execution status is recorded in the database; otherwise, only the business logic is executed.
[0027] The benefits of the present invention are:
[0028] The present invention provides a transaction recording method under a distributed architecture, which can associate transactions initiated by users with link tracking results, clearly and quickly record the execution status of transactions, and record the entire transaction to provide data support for subsequent analysis of user operation success and performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0030] Figure 1It is a schematic flow chart of the method of the present invention.
[0031] Figure 2 It is a schematic diagram of the application architecture of the method of the present invention. DETAILED DESCRIPTION
[0032] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention.
[0033] The present invention provides a transaction recording method under a distributed architecture, wherein a client initiates a request, and after receiving the request through a proxy server, it is determined whether data collection is required according to a preset rule.
[0034] If data collection is required, a call chain tracing context is generated. According to the user identification information in the request header, the corresponding user identification information is selected to generate the user identification ID. At the same time, a globally unique distributed tracing ID is generated for the request, and the relationship between the user identification ID and the distributed tracing ID is recorded in the database. The business code logic continues to be executed.
[0035] After receiving the request forwarded by the proxy server through the business execution server, it determines whether the distributed tracking ID is contained in it. If it is contained, the data corresponding to the request is recorded; otherwise, only the business code logic is executed.
[0036] The method of the present invention can associate the transaction initiated by the user with the link tracking result, thereby providing data support for the subsequent analysis of the success and performance of the user operation.
[0037] In the specific application, the technical scheme in the embodiment of the present application will be clearly and completely described in combination with the drawings in the embodiment. Figure 1 , Figure 1 FIG. 1 is a flow chart of an embodiment of a transaction recording method under a distributed architecture in an embodiment of the present invention. Figure 1 As shown, including:
[0038] Step S01: When a user performs an operation, such as adding a new piece of data, the client executes the new transaction and sends one or more requests to complete the new operation. When the client sends the request, it can set identification information such as user token and cookie in the request header;
[0039] Step S02: The proxy server receives the request sent by the client and decides whether to collect data and generate a call chain tracking context according to the pre-set rules. If necessary, execute step S03, otherwise execute step S04;
[0040] Step S03: The proxy server checks the request header according to the fields specified in the pre-set rules. If there is a value in the field in the request header, a unique user can be determined. If there is no value in the field, the client IP + browser information can also be used to determine the unique user. When setting rules for this field, the user token information is set first, followed by the cookie information, and then the client IP + browser information.
[0041] Through the obtained user identification information, check whether there is a corresponding user identification ID in the cache. If not, generate a new user identification ID. Otherwise, use the existing identification ID without regenerating it. At the same time, generate a tracking ID to track the context of this request, and record the relationship between the user identification ID and the tracking ID in the database;
[0042] Step S04: When the business execution service receives the request forwarded by the proxy service, it first checks whether the request header contains the tracking ID. If the field exists, it executes step S05, otherwise it executes step S06;
[0043] Step S05: Record the execution status of the request corresponding to the tracking ID into the database;
[0044] Step S06: Execute specific business logic. Figure 2 show.
[0045] The present invention also provides a transaction recording device under a distributed architecture, including an agent service module and a business execution service module.
[0046] After receiving the request initiated by the client through the proxy server, the proxy service module determines whether data collection is required according to the pre-set rules.
[0047] If data collection is required, a call chain tracing context is generated. According to the user identification information in the request header, the corresponding user identification information is selected to generate the user identification ID. At the same time, a globally unique distributed tracing ID is generated for the request, and the relationship between the user identification ID and the distributed tracing ID is recorded in the database. The business code logic continues to be executed.
[0048] After receiving the request forwarded by the proxy server through the business execution server, the business execution service module determines whether the request contains the distributed tracking ID. If so, it records the data corresponding to the request; otherwise, it only executes the business code logic.
[0049] The information interaction, execution process and other contents between the modules in the above-mentioned device are based on the same concept as the embodiment of the method of the present invention. For the specific contents, please refer to the description in the embodiment of the method of the present invention, and no further description is given here.
[0050] It should be noted that not all steps and modules in the above-mentioned processes and device structures are necessary, and some steps or modules can be ignored according to actual needs. The execution order of each step is not fixed and can be adjusted as needed. The system structure described in the above-mentioned embodiments can be a physical structure or a logical structure, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by multiple physical entities, or some components in multiple independent devices may be implemented together.
[0051] The above-described embodiments are only preferred embodiments for fully illustrating the present invention, and the protection scope of the present invention is not limited thereto. Equivalent substitutions or changes made by those skilled in the art based on the present invention are within the protection scope of the present invention. The protection scope of the present invention shall be subject to the claims.
Claims
1. A transaction recording method under a distributed architecture, characterized by Initiate a request through the client and set the user identification information in the request header, including: the user identification information set is token information and cookie information, The set user identification information is used to generate the user's identification ID and mark the user's identity. After receiving the request through the proxy server, it determines whether data collection is required according to the pre-set rules, including: checking the user identification information in the request header, checking whether there is a user identification ID corresponding to the user identification information in the cache, if so, using the existing identification ID, otherwise giving priority to user token information and cookie information to generate user identification ID, and then selecting client IP and browser information to generate user identification ID, If data collection is required, a call chain tracing context is generated. According to the user identification information in the request header, the corresponding user identification information is selected to generate the user identification ID. At the same time, a globally unique distributed tracing ID is generated for the request, and the relationship between the user identification ID and the distributed tracing ID is recorded in the database. The business code logic continues to be executed. After receiving the request forwarded by the proxy server through the business execution server, it determines whether it contains the distributed tracing ID. If it does, it records the data corresponding to the request. Otherwise, it only executes the business code logic. When the distributed tracing ID exists, it records the execution status of the request to the database. Otherwise, it only executes the business logic.
2. A transaction recording device under a distributed architecture, characterized in that Including agency service module and business execution service module, The proxy service module receives the request initiated by the client through the proxy service end. The request header received by the proxy service module is provided with user identification information. The user identification information includes token information and cookie information, which is used to generate the user identification ID and mark the user's identity. According to the preset rules, it is determined whether data collection is required, including: checking the user identification information in the request header, checking whether there is a user identification ID corresponding to the user identification information in the cache, if so, using the existing identification ID, otherwise giving priority to selecting the user token information and cookie information to generate the user identification ID, and then selecting the client IP and browser information to generate the user identification ID, If data collection is required, a call chain tracing context is generated. According to the user identification information in the request header, the corresponding user identification information is selected to generate the user identification ID. At the same time, a globally unique distributed tracing ID is generated for the request, and the relationship between the user identification ID and the distributed tracing ID is recorded in the database. The business code logic continues to be executed. After the business execution service module receives the request forwarded by the proxy server through the business execution server, it determines whether it contains the distributed tracing ID. If it does, it records the data corresponding to the request. Otherwise, it only executes the business code logic. When the distributed tracing ID exists, it records the execution status of the request to the database. Otherwise, it only executes the business logic.
