Method and system for optimizing data transmission
By building a distributed link tracking engine in the microservice architecture, counting the number of repeated interfaces and adding request information to the request header, the problem of waste of resources and low data transmission efficiency caused by external requests under the microservice architecture is solved, and the problem of waste of resources and low data transmission efficiency is realized. Efficient data transmission.
Patent Information
- Application Number
- CN202410988304.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2024-11-22
AI Technical Summary
Under the microservice architecture, external requests lead to multiple internal calls to obtain user information interfaces, resulting in waste of resources and low data transmission efficiency.
Build a distributed link tracking engine under the microservice architecture system to count the number of repeated interfaces. When the threshold exceeds the threshold, obtain request information through the top-level node or the lowest-level common superior node, and add it to the request header to pass through to avoid repeated calls .
Reduces the waste of invalid resources, improves data transmission efficiency, and directly obtains the information of duplicate interfaces through the request header, reducing the burden on top-level nodes.
Smart Images

Figure CN119003202A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and system for optimizing data transmission. Background Art
[0002] In order to achieve high concurrency and high throughput performance requirements, the current system usually adopts a microservice architecture on the server side. However, under the microservice architecture, it is necessary to divide the fields of various businesses. For example, the account system is the bottom-level basic component, which is relied on by multiple business components in the upper layer, and the top layer is integrated by the client to generate the final product. The account system is relied on by multiple business components as the bottom-level component, and multiple business components are independent of each other, and there may be a sequence of calls before and after. Then, when some functions, such as the interface for obtaining user information, are called by multiple business components, when multiple business components have a sequence before and after, each business component will need to call the interface for obtaining user information. Here, when an external request arrives, the internal business component will generate multiple calls to the interface for obtaining user information. After a request arrives internally, it will be expanded into multiple data reading requests. When external requests gradually increase, internal requests will increase infinitely, causing waste of resources. Summary of the invention
[0003] The technical problem to be solved by the present invention is: the present invention provides a method and system for optimizing data transmission, thereby improving the efficiency of data transmission and reducing the waste of resources.
[0004] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0005] In a first aspect, the present invention provides a method for optimizing data transmission, comprising:
[0006] Build a distributed link tracking engine under the microservice architecture system;
[0007] All internal link information of each type of external request is obtained through the distributed link tracking engine, and the number of repetitions of each interface in all the internal link information is counted. When the number of repetitions exceeds a first threshold, the request information of the interface is preferentially obtained once through the top-level node in the internal link information, and the request information is added to the request header of the top-level node, and the request information is transmitted to the interface through the request header.
[0008] The beneficial effect of the present invention is that for an interface whose number of repetitions in an external request exceeds a first threshold, the request information of the interface is preferentially obtained once through the top-level node, and it is added to the request header of the top-level node. The request information is transmitted to the interface through the request header. That is, it is only necessary to obtain the request for the repeated interface once, and there is no need to repeatedly call the interface. Information can be directly obtained from the request header, thereby reducing the waste of invalid resources and improving the efficiency of data transmission.
[0009] Optionally, when the number of repetitions exceeds a first threshold, preferentially obtaining the request information of the interface once through the top-level node in the internal link information, and adding the request information to the request header includes:
[0010] When the interface whose repetition times exceeds the first threshold is an intermediate layer interface, all common superior nodes of the intermediate layer interface are obtained from all the internal link information, and the common superior node with the lowest level is selected from all the common superior nodes to obtain request information of the intermediate layer interface once, and the request information is added to the request header of the common superior node with the lowest level.
[0011] According to the above description, for the middle-layer interface whose repetition times exceed the first threshold, the request information of the middle-layer interface is obtained once through the lowest-level common superior node, rather than through the top-level node. While reducing the burden on the top-level node, the request information is added to the request header of the lowest-level common superior node, and the request header is used for transparent transmission to improve data transmission efficiency.
[0012] Optionally, the adding the request information to the request header of the top-level node and transparently transmitting the request information to the external request having the interface through the request header comprises:
[0013] Adding the request information to the request header of the top-level node, and marking the added identifier corresponding to the unique identifier of the interface in the request header;
[0014] When an external request of the interface is received again, it is first checked whether there is an added identifier corresponding to the unique identifier of the interface in the request header. If so, the request information is directly transmitted to the interface through the request header.
[0015] According to the above description, when an external request to the interface is received again with the number of repetitions exceeding the first threshold, it is prioritized to query whether the request information of the interface exists in the request header. If so, it is directly obtained from the request header without calling the interface again to obtain information, thereby reducing resource waste. At the same time, whether the request information of the interface exists in the request header is judged by the added identifier corresponding to the unique identifier of the interface to ensure the accuracy of the judgment.
[0016] Optionally, the distributed link tracking engine is pinpoint or skywalking.
[0017] According to the above description, the distributed link tracking engine has diversity.
[0018] Optionally, the first threshold is 2.
[0019] In a second aspect, the present invention provides a system for optimizing data transmission, comprising:
[0020] Tracking module, used to build a distributed link tracking engine under the microservice architecture system;
[0021] A transmission module is used to obtain all internal link information of each type of external request through the distributed link tracking engine, count the number of repetitions of each interface in all the internal link information, and when the number of repetitions exceeds a first threshold, preferentially obtain the request information of the interface once through the top-level node in the internal link information, add the request information to the request header of the top-level node, and transparently transmit the request information to the interface through the request header.
[0022] The beneficial effect of the present invention is that for an interface whose number of repetitions in an external request exceeds a first threshold, the request information of the interface is preferentially obtained once through the top-level node, and it is added to the request header of the top-level node. The request information is transmitted to the interface through the request header. That is, it is only necessary to obtain the request for the repeated interface once, and there is no need to repeatedly call the interface. Information can be directly obtained from the request header, thereby reducing the waste of invalid resources and improving the efficiency of data transmission.
[0023] Optionally, the transmission module is specifically:
[0024] When the interface whose repetition times exceeds the first threshold is an intermediate layer interface, all common superior nodes of the intermediate layer interface are obtained from all the internal link information, and the common superior node with the lowest level is selected from all the common superior nodes to obtain request information of the intermediate layer interface once, and the request information is added to the request header of the common superior node with the lowest level.
[0025] Optionally, the transmission module is specifically:
[0026] Adding the request information to the request header of the top-level node, and marking the added identifier corresponding to the unique identifier of the interface in the request header;
[0027] When an external request of the interface is received again, it is first checked whether there is an added identifier corresponding to the unique identifier of the interface in the request header. If so, the request information is directly transmitted to the interface through the request header.
[0028] According to the above description, when an external request to the interface is received again with the number of repetitions exceeding the first threshold, it is prioritized to query whether the request information of the interface exists in the request header. If so, it is directly obtained from the request header without calling the interface again to obtain information, thereby reducing resource waste. At the same time, whether the request information of the interface exists in the request header is judged by the added identifier corresponding to the unique identifier of the interface to ensure the accuracy of the judgment.
[0029] Optionally, the distributed link tracking engine is pinpoint or skywalking.
[0030] According to the above description, the distributed link tracking engine has diversity.
[0031] Optionally, the first threshold is 2. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 A flowchart of a method for optimizing data transmission provided by an embodiment of the present invention;
[0033] Figure 2 A schematic diagram of the overall flow of a method for optimizing data transmission provided by an embodiment of the present invention;
[0034] Figure 3 A schematic diagram of the structure of a system for optimizing data transmission provided by an embodiment of the present invention.
[0035] [Description of Reference Numerals]
[0036] 1. A system for optimizing data transmission;
[0037] 2. Tracking module;
[0038] 3. Transmission module. DETAILED DESCRIPTION
[0039] In order to better understand the above technical solution, exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to enable a clearer and more thorough understanding of the present invention and to fully convey the scope of the present invention to those skilled in the art.
[0040] Embodiment 1
[0041] Please refer to Figure 1 to Figure 2 The present invention provides a method for optimizing data transmission, comprising the steps of:
[0042] S1. Build a distributed link tracking engine under the microservice architecture system;
[0043] In this embodiment, the distributed link tracking engine is pinpoint or skywalking.
[0044] S2. Obtain all internal link information of each type of external request through the distributed link tracking engine, count the number of repetitions of each interface in all the internal link information, and when the number of repetitions exceeds a first threshold, preferentially obtain the request information of the interface once through the top-level node in the internal link information, add the request information to the request header of the top-level node, and transmit the request information to the interface through the request header.
[0045] In this embodiment, if Figure 2 As shown, the distributed link tracking engine built through step S1 obtains all internal link information of each type of external request, and each type of external request may contain multiple different internal links, wherein the internal link information includes the passed nodes and interfaces, thereby counting the number of repetitions of each interface in all internal link information of each type of external request. When the number of repetitions exceeds the first threshold, the top-level node preferentially obtains the request information of the interface once, and then adds the request information to the request header of the top-level node, and transmits the request information to the interface through the request header. At this time, the first threshold is 2, and the first threshold can be adjusted according to actual conditions.
[0046] In a specific embodiment, the external request of type 1 includes three pieces of internal link information, namely:
[0047] Internal link 1: client→gateway→A→B→UC obtains the account interface;
[0048] Internal link 2: client→gateway→A→C→UC to obtain the account interface;
[0049] Internal link 3: client→gateway→A→D→UC to obtain the account interface;
[0050] Among them, A, B, C and D all represent nodes. It can be seen that the number of repetitions of UC obtaining the account interface is 3. If the number of repetitions exceeds the first threshold, the top-level node A will preferentially obtain the request information of UC obtaining the account interface once, and add the request information to the request header of the top-level node A.
[0051] At this time, when the number of repetitions exceeds the first threshold in step S2, the request information of the interface is preferentially obtained once through the top-level node in the internal link information, and the request information is added to the request header, including:
[0052] S21. When the interface whose number of repetitions exceeds the first threshold is an intermediate layer interface, all common superior nodes of the intermediate layer interface are obtained from all the internal link information, and the common superior node with the lowest level is selected from all the common superior nodes to obtain request information of the intermediate layer interface once, and the request information is added to the request header of the common superior node with the lowest level.
[0053] In this embodiment, if Figure 2 As shown, for the interface whose repetition times exceed the first threshold, it will be further determined whether it is an intermediate layer interface. If it is an intermediate layer interface, all common superior nodes of the intermediate layer interface are obtained, and the common superior node with the lowest level is selected to obtain the request information of the intermediate layer interface, and the request information is added to the request header of the common superior node. That is, for the bottom-level interface whose repetition times exceed the first threshold, the request information is obtained through the top-level node. For the intermediate layer interface whose repetition times exceed the first threshold, it is preferred to obtain the request information through the common superior node with the lowest level. Of course, you can also choose to obtain the request information through the top-level node.
[0054] At this time, the adding of the request information to the request header of the top-level node in step S2, and transparently transmitting the request information to the external request having the interface through the request header includes:
[0055] S22, adding the request information to the request header of the top-level node, and marking the added identifier corresponding to the unique identifier of the interface in the request header;
[0056] S23. When an external request of the interface is received again, it is preferred to query whether there is an added identifier corresponding to the unique identifier of the interface in the request header. If so, the request information is directly transmitted to the interface through the request header.
[0057] In this embodiment, if Figure 2 As shown, after the request information is added to the request header of the top-level node, the added identifier corresponding to the unique identifier of the interface will also be marked in the request header. When an external request of the interface is received again in the future, it will be preferentially queried whether there is an added identifier corresponding to the unique identifier of the interface in the request header. If it exists, it will be directly obtained from the request header, that is, the request information will be directly transmitted to the interface through the request header.
[0058] Embodiment 2
[0059] Please refer to Figure 3 The present invention provides a system 1 for optimizing data transmission, including: a tracking module 2 and a transmission module 3.
[0060] Among them, the tracking module 2 is used to build a distributed link tracking engine under the microservice architecture system;
[0061] Transmission module 3 is used to obtain all internal link information of each type of external request through the distributed link tracking engine, count the number of repetitions of each interface in all the internal link information, and when the number of repetitions exceeds a first threshold, preferentially obtain the request information of the interface once through the top-level node in the internal link information, add the request information to the request header of the top-level node, and transmit the request information to the interface through the request header.
[0062] Specifically, the transmission module 2 is specifically:
[0063] When the interface whose repetition times exceeds the first threshold is an intermediate layer interface, all common superior nodes of the intermediate layer interface are obtained from all the internal link information, and the common superior node with the lowest level is selected from all the common superior nodes to obtain request information of the intermediate layer interface once, and the request information is added to the request header of the common superior node with the lowest level.
[0064] Specifically, the transmission module 2 is specifically:
[0065] Adding the request information to the request header of the top-level node, and marking the added identifier corresponding to the unique identifier of the interface in the request header;
[0066] When an external request of the interface is received again, it is first checked whether there is an added identifier corresponding to the unique identifier of the interface in the request header. If so, the request information is directly transmitted to the interface through the request header.
[0067] Specifically, the distributed link tracking engine is pinpoint or skywalking.
[0068] Specifically, the first threshold is 2.
[0069] Since the system / device described in the above embodiments of the present invention is a system / device used to implement the method of the above embodiments of the present invention, a person skilled in the art can understand the specific structure and deformation of the system / device based on the method described in the above embodiments of the present invention, and thus will not be described in detail here. All systems / devices used in the method of the above embodiments of the present invention belong to the scope of protection of the present invention.
[0070] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0071] The present invention is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present invention. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions.
[0072] It should be noted that in the claims, any reference numerals placed between brackets shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claims. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention may be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In the claims enumerating several means, several of these means may be embodied by the same hardware. The use of the words first, second, third, etc., is for convenience of expression only and does not indicate any order. These words may be understood as part of the component name.
[0073] In addition, it should be noted that, in the description of this specification, the description of the terms "one embodiment", "some embodiments", "embodiment", "example", "specific example" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.
[0074] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments after knowing the basic creative concept. Therefore, the claims should be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present invention.
[0075] Obviously, those skilled in the art can make various modifications and variations to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention should also include these modifications and variations.
Claims
1. A method for optimizing data transmission, characterized in that: include: Build a distributed link tracking engine under the microservice architecture system; All internal link information of each type of external request is obtained through the distributed link tracking engine, and the number of repetitions of each interface in all the internal link information is counted. When the number of repetitions exceeds a first threshold, the request information of the interface is preferentially obtained once through the top-level node in the internal link information, and the request information is added to the request header of the top-level node, and the request information is transmitted to the interface through the request header.
2. A method for optimizing data transmission according to claim 1, characterized in that: When the number of repetitions exceeds a first threshold, preferentially obtaining the request information of the interface once through the top-level node in the internal link information, and adding the request information to the request header comprises: When the interface whose repetition times exceeds the first threshold is an intermediate layer interface, all common superior nodes of the intermediate layer interface are obtained from all the internal link information, and the common superior node with the lowest level is selected from all the common superior nodes to obtain request information of the intermediate layer interface once, and the request information is added to the request header of the common superior node with the lowest level.
3. A method for optimizing data transmission according to claim 1, characterized in that: The adding the request information to the request header of the top-level node and transparently transmitting the request information to the external request having the interface through the request header comprises: Adding the request information to the request header of the top-level node, and marking the added identifier corresponding to the unique identifier of the interface in the request header; When an external request of the interface is received again, it is first checked whether there is an added identifier corresponding to the unique identifier of the interface in the request header. If so, the request information is directly transmitted to the interface through the request header.
4. A method for optimizing data transmission according to claim 1, characterized in that: The distributed link tracking engine is pinpoint or skywalking.
5. A method for optimizing data transmission according to claim 1, characterized in that: The first threshold is 2.
6. A system for optimizing data transmission, characterized in that: include: Tracking module, used to build a distributed link tracking engine under the microservice architecture system; A transmission module is used to obtain all internal link information of each type of external request through the distributed link tracking engine, count the number of repetitions of each interface in all the internal link information, and when the number of repetitions exceeds a first threshold, preferentially obtain the request information of the interface once through the top-level node in the internal link information, add the request information to the request header of the top-level node, and transparently transmit the request information to the interface through the request header.
7. A system for optimizing data transmission as claimed in claim 6, characterized in that: The transmission module is specifically: When the interface whose repetition times exceeds the first threshold is an intermediate layer interface, all common superior nodes of the intermediate layer interface are obtained from all the internal link information, and the common superior node with the lowest level is selected from all the common superior nodes to obtain request information of the intermediate layer interface once, and the request information is added to the request header of the common superior node with the lowest level.
8. A system for optimizing data transmission as claimed in claim 6, characterized in that: The transmission module is specifically: Adding the request information to the request header of the top-level node, and marking the added identifier corresponding to the unique identifier of the interface in the request header; When an external request of the interface is received again, it is first checked whether there is an added identifier corresponding to the unique identifier of the interface in the request header. If so, the request information is directly transmitted to the interface through the request header.
9. A system for optimizing data transmission as claimed in claim 6, characterized in that: The distributed link tracking engine is pinpoint or skywalking.
10. A system for optimizing data transmission as claimed in claim 6, characterized in that: The first threshold is 2.
