Flow proxy method and system, electronic equipment and storage medium

By configuring the identity for each version of the microservice and adding corresponding identity to proxy requests, the problem of resource waste and management difficulty in the microservice architecture is solved, and the coexistence and automatic traffic proxy of multiple versions of microservices in the same environment is realized.

CN119520603APending Publication Date: 2025-02-25SUNSHINE PROPERTY & CASUALTY INSURANCE CO
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411342582.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-25
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

In the microservice architecture, the existing technology requires the deployment of multiple complete microservice clusters to ensure service stability, resulting in increased resource waste and management difficulties.

Method used

By configuring an identity for each version of each microservice of the target system and adding a corresponding identity to the proxy request for the pending traffic, the target microservice of the target version corresponding to the proxy request is determined, thereby processing the pending traffic.

Benefits of technology

There is no need to deploy multiple complete microservice clusters, which saves resources and is easy to manage, and can realize the coexistence of multiple versions of microservices and automatic traffic proxying in the same environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119520603A_ABST
    Figure CN119520603A_ABST
Patent Text Reader

Abstract

The invention discloses a traffic proxy method and system, electronic equipment and a storage medium, and relates to the technical field of traffic proxy, and the method comprises the steps: configuring an identifier for each version of each micro service of a target system; adding an identifier for an agent request corresponding to the to-be-processed flow in the target system, and determining a target micro-service of a target version corresponding to the agent request through identifier comparison; and processing the to-be-processed traffic through the target micro-service of the target version. When any micro-service has a new version, the corresponding identifier is added to participate in subsequent processing of the to-be-processed flow, multiple sets of complete micro-service clusters do not need to be deployed, resources are saved, and management is convenient.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] In the process of software iteration, before the new version is officially launched, it is often necessary to conduct a grayscale release to ensure service stability. This requires at least two production environments to meet the needs. However, in the microservice architecture design, a system is divided into multiple microservices, and multiple microservices need to be started at the same time to operate the service normally. In this case, at least two complete microservice clusters need to be deployed. This deployment method is not only a waste of resources, but also difficult to manage. Summary of the invention

[0003] The technical problem to be solved by the present invention is to address the deficiencies of the prior art and specifically provide a traffic proxy method, system, electronic device and storage medium, which are as follows:

[0004] 1) In the first aspect, the present invention provides a traffic proxy method, and the specific technical solution is as follows:

[0005] Configure an identifier for each version of each microservice of the target system;

[0006] Add an identifier to the proxy request corresponding to the pending traffic in the target system, and determine the target microservice of the target version corresponding to the proxy request by comparing the identifiers;

[0007] Handle pending traffic through the target version of the target microservice.

[0008] The beneficial effects of a traffic proxy method provided by the present invention are as follows:

[0009] When any microservice has a new version, it can participate in the processing of subsequent pending traffic by adding the corresponding identifier. There is no need to deploy multiple complete microservice clusters, which saves resources and facilitates management.

[0010] Based on the above solution, a traffic proxy method of the present invention can also be improved as follows.

[0011] Furthermore, it also includes: writing all configured identifiers into the microservice registration center of the target system.

[0012] Furthermore, the identifier configured for any version of any microservice is: the version number of the version of the microservice.

[0013] Furthermore, it also includes: using bytecode enhancement technology to obtain proxy requests.

[0014] 2) In the second aspect, the present invention also provides a traffic proxy system, and the specific technical solution is as follows:

[0015] It includes an identification configuration module, an identification addition determination module and a traffic proxy module;

[0016] The identity configuration module is used to: configure an identity for each version of each microservice of the target system;

[0017] The identification adding and determining module is used to: add identification to the proxy request corresponding to the pending traffic in the target system, and determine the target microservice of the target version corresponding to the proxy request by comparing the identification;

[0018] The traffic proxy module is used to process pending traffic through the target microservice of the target version.

[0019] Based on the above solution, a traffic proxy system of the present invention can also be improved as follows.

[0020] Furthermore, it also includes an identification writing module, which is used to write all configured identifications into the microservice registration center of the target system.

[0021] Furthermore, the identifier configured for any version of any microservice is: the version number of the version of the microservice.

[0022] Furthermore, it also includes a proxy request acquisition module, which is used to: use bytecode enhancement technology to acquire proxy requests.

[0023] 3) In a third aspect, the present invention further provides an electronic device, comprising a processor, the processor being coupled to a memory, the memory storing at least one computer program, and the at least one computer program being loaded and executed by the processor so that the electronic device implements any of the above-mentioned traffic proxy methods.

[0024] 4) In a fourth aspect, the present invention further provides a computer-readable storage medium, in which at least one computer program is stored, and the at least one computer program is loaded and executed by a processor so that the computer implements any of the above-mentioned traffic proxy methods.

[0025] It should be noted that the beneficial effects achieved by the technical solutions of the second to fourth aspects of the present invention and the corresponding possible implementation methods can be found in the above-mentioned technical effects of the first aspect and its corresponding possible implementation methods, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:

[0027] Figure 1 A flow chart of a traffic proxy method according to an embodiment of the present invention;

[0028] Figure 2 It is a schematic diagram of an application scenario of the present invention;

[0029] Figure 3 A schematic diagram of the structure of a traffic proxy system according to an embodiment of the present invention;

[0030] Figure 4 The figure is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0031] In order to make the objectives, technical solutions and advantages of the present invention more clear, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.

[0032] like Figure 1 As shown, a traffic proxy method according to an embodiment of the present invention includes the following steps:

[0033] S1. Configure an identifier for each version of each microservice of the target system;

[0034] For example, the target system has 10 microservices in total, each microservice has only one version, and an identifier is configured for each version of each microservice. When one of the microservices has a new version, an identifier is also configured for the new version of the microservice.

[0035] The identifier configured for any version of any microservice is: the version number of the version of the microservice, or a serial number set according to actual conditions. It can be set according to actual conditions. It should be noted that the identifiers configured for each version of each microservice are different.

[0036] Among them, the target system is an insurance business system, and it can also be other systems with multiple microservices, which can be set according to actual conditions.

[0037] S2. Add an identifier to the proxy request corresponding to the pending traffic in the target system, and determine the target microservice of the target version corresponding to the proxy request by comparing the identifiers. The specific implementation method is as follows:

[0038] 1) The first implementation method: the identifier added to the proxy request corresponding to the pending traffic in the target system is one of all the identifiers configured in S1. Then, through identifier comparison, the microservice with the same version as the identifier added to the proxy request corresponding to the pending traffic is determined as the target microservice of the target version corresponding to the proxy request.

[0039] 2) A one-to-one correspondence between all identifiers added to the proxy request and all identifiers configured in S1 is pre-set. Then, through identifier comparison, the microservice of the version corresponding to the identifier that has a corresponding relationship with the identifier added to the proxy request corresponding to the traffic to be processed is determined as the target microservice of the target version corresponding to the proxy request.

[0040] S3. Process the pending traffic through the target microservice of the target version.

[0041] Optionally, in the above technical solution, it also includes: writing all configured identifiers into a microservice registration center of the target system.

[0042] Optionally, the above technical solution also includes: utilizing bytecode enhancement technology to obtain a proxy request.

[0043] In another embodiment, comprising:

[0044] S10. In the configuration file of the target system, an identifier is configured for each version of each microservice of the target system, and each configured identifier is written as a field into the microservice registration center of the target system.

[0045] S11. The proxy request corresponding to the to-be-processed traffic in the target system is an http request. Using the nginx proxy or browser plug-in, a routing version identifier (i.e., the identifier added in S2) is added to the http request header (also called the http request header).

[0046] S12. The identifier added to the http request corresponding to the pending traffic in the target system is one of all the identifiers configured in S1, and a routing logic code is written. The routing logic code implements the process of "determining the microservice of the same version as the identifier added to the http request corresponding to the pending traffic as the target microservice of the target version corresponding to the http request, and processing the pending traffic through the target microservice of the target version".

[0047] Among them, bytecode enhancement technology is used to obtain http requests. When the framework of the target system is the spring MVC framework, Javassist bytecode enhancement technology can be used to intercept traffic routing at the bottom of spring MVC to obtain http requests. Java Agent probe method is used to implement non-intrusive traffic proxy. When the framework of the target system is the springMVC framework, the routing logic code in S12 is added to the bottom of spring MVC to implement non-intrusive (non-intrusive) traffic proxy.

[0048] When the target system is an insurance business system, the counter environment and channel environment in the insurance business system are isolated from each other. The request version of the test environment page is specified as 1.0, and the request version through the channel is specified as 2.0. Since the services that are frequently upgraded are mainly the five microservices of underwriting (insurance, underwriting, revision, transfer, and policy), only two sets of environments are deployed for the five microservices of underwriting, and the remaining microservices can be shared. The counter and the channel enter through different nginx proxy ports, and the corresponding routing identifiers will be marked by default to achieve each going its own way without affecting each other. When developing self-test scenarios, you need to temporarily start a set of environments and ensure that only the traffic you access goes to your local area. This can be achieved by using the Google traffic plug-in to modify the header request header. Develop a local startup service and specify the identifier as a custom version number, such as underwriting 1.0 and underwriting 2.0, etc. The browser plug-in specifies its own version number. In this way, when accessing the test environment page, the proxy request will be proxied to the local service and will not affect the normal test request, such as Figure 2 shown.

[0049] The beneficial effects of the present invention are as follows:

[0050] 1) Multi-environment application scenarios: For scenarios where different businesses need to be isolated into multiple environments, precise isolation can be achieved. The microservice that needs to be isolated can be isolated. Compared with the traditional method, a separate microservice cluster needs to be built, which greatly saves hardware resources and avoids the additional cost of maintaining another environment. Using a multi-version routing solution, in theory, multiple sub-environments can be dynamically split under limited resource conditions. In the traditional method, each environment requires a large amount of hardware resources and operation and maintenance costs. It can be applied to scenarios such as business isolation and grayscale verification.

[0051] Through the present invention, only one additional microservice with changes needs to be deployed, and no additional deployment is required for microservices that have not changed. The traffic proxy component (a component used to implement the technical solution of the present invention) will automatically proxy the traffic to the correct version of the microservice, so that multiple versions of microservices can coexist in the same environment and can automatically perform traffic proxy.

[0052] 2) Test environment application scenario: In traditional test environments, both testers and business personnel perform test verification in a test environment. It is common that "when testers upgrade services, it affects business personnel's use", which creates a conflict between test frequency and environment stability. Using the multi-version routing solution in the present invention (the technical solution of the present invention), the technical effects of testers using an agile environment and business personnel using a stable environment can be achieved at the same time. The agile environment can be released at any time to achieve rapid testing, and business personnel can use a stable environment to complete functional verification, which can effectively ensure the stability of the test environment and greatly improve test efficiency.

[0053] 3) Development self-test application scenario: Under the mainstream microservice architecture and front-end and back-end separation development mode, since developers cannot start all microservices and front-end codes locally at the same time, they cannot complete the complete process test during development self-test and can only test through API interface mode. This method is not only time-consuming and laborious, but also has great restrictions and often fails to test in place. Using the multi-version routing method (technical solution of the present invention) in the present invention, the microservices modified by development can be registered to the microservice registration center of the test environment (also the microservice registration center of the target system), and the routing version identifier in the http request header can be modified by using the browser plug-in to route to the development local, which can greatly improve the coverage of development self-test and improve the efficiency of self-test.

[0054] In the above embodiments, although the steps are numbered S1, S2, etc., these are only specific embodiments given by the present invention. Those skilled in the art may adjust the execution order of S1, S2, etc. according to actual conditions, which is also within the protection scope of the present invention. It can be understood that in some embodiments, some or all of the above embodiments may be included.

[0055] like Figure 3 As shown, a traffic proxy system 200 according to an embodiment of the present invention includes an identification configuration module 201, an identification addition determination module 202, and a traffic proxy module 203;

[0056] The identification configuration module 201 is used to: configure an identification for each version of each microservice of the target system;

[0057] The identification adding and determining module 202 is used to: add an identification to the proxy request corresponding to the to-be-processed traffic in the target system, and determine the target microservice of the target version corresponding to the proxy request by comparing the identification;

[0058] The traffic proxy module 203 is used to process the traffic to be processed through the target microservice of the target version.

[0059] Optionally, the above technical solution further includes an identification writing module, which is used to write all configured identifications into a microservice registration center of the target system.

[0060] Optionally, in the above technical solution, the identifier configured for any version of any microservice is: the version number of the version of the microservice.

[0061] Optionally, the above technical solution further includes a proxy request acquisition module, which is used to: obtain the proxy request by utilizing bytecode enhancement technology.

[0062] It should be noted that the beneficial effects of a traffic proxy system 200 provided in the above embodiment are the same as the beneficial effects of the above traffic proxy method, which will not be described in detail here. In addition, when the system provided in the above embodiment realizes its functions, it only uses the division of the above functional modules as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the system can be divided into different functional modules according to actual conditions to complete all or part of the functions described above. In addition, the system and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be described in detail here.

[0063] like Figure 4 As shown, an electronic device 300 of an embodiment of the present invention includes a processor 320, the processor 320 is coupled to a memory 310, and the memory 310 stores at least one computer program 330, and the at least one computer program 330 is loaded and executed by the processor 320, so that the electronic device 300 implements any of the above-mentioned traffic proxy methods, specifically:

[0064] The electronic device 300 may have relatively large differences due to different configurations or performances, and may include one or more processors 320 (Central Processing Units, CPU) and one or more memories 310, wherein the one or more memories 310 store at least one computer program 330, and the at least one computer program 330 is loaded and executed by the one or more processors 320, so that the electronic device 300 implements any of the traffic proxy methods provided in the above embodiments. Of course, the electronic device 300 may also have components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output. The electronic device 300 may also include other components for realizing device functions, which will not be described in detail here. The electronic device may specifically be a computer, etc.

[0065] A computer-readable storage medium according to an embodiment of the present invention stores at least one computer program, and the at least one computer program is loaded and executed by a processor so that a computer implements any of the above-mentioned traffic proxy methods.

[0066] Optionally, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, and the like.

[0067] In an exemplary embodiment, a computer program product or a computer program is also provided, the computer program product or the computer program comprising computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device performs any of the above-mentioned traffic proxy methods.

[0068] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects and represent the definition of a specific order or sequence. The order of use of similar objects can be interchanged where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than the order shown or described.

[0069] Those skilled in the art know that the present invention can be implemented as a system, method or computer program product. Therefore, the present invention can be specifically implemented in the following forms, namely: it can be complete hardware, it can be complete software (including firmware, resident software, microcode, etc.), or it can be a combination of hardware and software, which is generally referred to as "circuit", "module" or "system" herein. In addition, in some embodiments, the present invention can also be implemented in the form of a computer program product in one or more computer-readable media, and the computer-readable medium contains computer-readable program code.

[0070] Any combination of one or more computer-readable media can be used. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.

[0071] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.

Claims

1. A traffic proxy method, characterized in that: include: Configure an identifier for each version of each microservice of the target system; Add an identifier to the proxy request corresponding to the to-be-processed traffic in the target system, and determine the target microservice of the target version corresponding to the proxy request by comparing the identifiers; The to-be-processed traffic is processed by the target microservice of the target version.

2. A traffic proxy method according to claim 1, characterized in that: Also includes: Write all configured identifiers to the microservice registry of the target system.

3. A traffic proxy method according to claim 1, characterized in that: The identifier configured for any version of any microservice is: the version number of the version of the microservice.

4. A traffic proxy method according to any one of claims 1 to 3, characterized in that: Also includes: The proxy request is obtained by utilizing bytecode enhancement technology.

5. A traffic proxy system, characterized in that: It includes an identification configuration module, an identification addition determination module and a traffic proxy module; The identification configuration module is used to: configure an identification for each version of each microservice of the target system; The identification adding and determining module is used to: add an identification to the proxy request corresponding to the to-be-processed traffic in the target system, and determine the target microservice of the target version corresponding to the proxy request by comparing the identifications; The traffic proxy module is used to process the to-be-processed traffic through the target microservice of the target version.

6. A traffic proxy system according to claim 5, characterized in that: It also includes an identification writing module, which is used to write all configured identifications into the microservice registration center of the target system.

7. A traffic proxy system according to claim 5, characterized in that: The identifier configured for any version of any microservice is: the version number of the version of the microservice.

8. A traffic proxy system according to any one of claims 5 to 7, characterized in that: It also includes a proxy request acquisition module, which is used to: use bytecode enhancement technology to acquire the proxy request.

9. An electronic device, characterized in that: The electronic device includes a processor, the processor is coupled to a memory, the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor so that the electronic device implements a traffic proxy method as described in any one of claims 1 to 4.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one computer program, and the at least one computer program is loaded and executed by a processor so that a computer implements a traffic proxy method as claimed in any one of claims 1 to 4.