A multi-tenant method and system based on service and traffic coloring

By dyeing services and traffic, it solves the problems of resource waste and complexity under the microservice architecture, achieves isolation and fairness in multi-tenant environments, provides a more flexible and scalable architecture, and improves production efficiency.

CN115297158BActive Publication Date: 2024-10-18CHENGDU JIXIANG RUIYI TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210923884.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-02
Publication Date
2024-10-18
Estimated Expiration
2042-08-02

AI Technical Summary

Technical Problem

Under the microservice architecture, the traditional test environment deployment model requires multiple physical machines, and both the development and test environments require repeated deployment of basic applications, resulting in waste of resources and unnecessary complexity.

Method used

By dyeing services and traffic, using microservice gateways to dye requests after detecting them, and making routing selections based on the dyeing information, multi-tenant isolation and fairness are achieved, and the demand for resources is reduced.

Benefits of technology

It achieves isolation and fairness in a multi-tenant environment, provides a more flexible and scalable microservice architecture, improves production efficiency, and reduces resource consumption and deployment complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115297158B_ABST
    Figure CN115297158B_ABST
Patent Text Reader

Abstract

The present invention provides a multi-tenant method based on service and traffic coloring, which realizes multi-tenancy by coloring services and user traffic. After detecting the set parameters of the request, the gateway colors the traffic, and the traffic is routed through the coloring information during the subsequent transmission process. The present invention also provides a multi-tenant system based on service and traffic coloring. The beneficial effects of the present invention are as follows: multi-tenancy can be conveniently realized by coloring services and user traffic. After detecting the specific parameters of the request, the gateway colors the traffic, and the traffic is routed through the coloring information during the subsequent transmission process. Isolation and fairness can be guaranteed for data tenants in transmission, as well as routing opportunities based on tenants. The present method and system provide a more flexible and scalable microservice architecture, which can bring greater production efficiency, which will benefit engineers and platform users.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a multi-tenant method, and in particular to a multi-tenant method and system based on service and traffic coloring. Background Art

[0002] In the microservice architecture, a microservice cluster often requires multiple physical machines to support it. If the traditional test environment deployment mode is still used, developers and testers need to deploy a formal online service environment and a test service environment respectively to ensure that the test and online environments do not affect each other. This will bring two problems. One is that multiple physical machines are required to support the two systems, and the other is the repeated deployment of some basic applications that both systems depend on but do not affect each other. Summary of the invention

[0003] In order to solve the problems in the prior art, the present invention provides a multi-tenant method and system based on service and traffic coloring.

[0004] The present invention provides a multi-tenancy method based on service and traffic coloring, which realizes multi-tenancy by coloring services and user traffic. After detecting the set parameters of the request, the gateway colors the traffic, and in the subsequent transmission process of the traffic, the coloring information is used for routing selection.

[0005] As a further improvement of the present invention, the method comprises the following process:

[0006] S1. Server deployment;

[0007] S2. Configuration and data flow during the usage phase.

[0008] As a further improvement of the present invention, step S1 includes the following sub-steps:

[0009] S101. Deploy a remote dictionary service, namely Redis, and a microservice registration center, namely ETCD. The microservice registration center is used to store and schedule microservices, and realize mutual communication between microservices and the registration center, and between microservices.

[0010] S102. Deploy the dyeing configuration microservice. The dyeing configuration microservice is an independent microservice used by management personnel to add, delete or modify traffic dyeing rules.

[0011] S103. Deploy an instance of the upstream microservice;

[0012] S104, deploy an instance of downstream microservices;

[0013] S105. Deploy a microservice gateway and register the access interface a1 exposed to the outside by the upstream microservice with the microservice registration center.

[0014] As a further improvement of the present invention, the color of the coloring information mark used by the upstream microservice instance is different from the coloring information mark used by the downstream microservice instance.

[0015] As a further improvement of the present invention, the microservice gateway includes a gateway traffic dyeing module and a gateway service discovery module. The gateway traffic dyeing module is used to read the traffic dyeing rules and dye the traffic according to the dyeing flag in the request header; the gateway service discovery module is used for the communication between the microservice gateway and the microservice registration center and the selection of the downstream node list.

[0016] As a further improvement of the present invention, the upstream microservice and the downstream microservice both include a service coloring module and a logic processing module, wherein the service coloring module is used to read the coloring information in the configuration file when the microservice is started, and register it to the microservice registration center to complete the microservice coloring; the logic processing module is a specific business module, which implements specific business functions according to different systems.

[0017] As a further improvement of the present invention, step S2 includes the following sub-steps:

[0018] S201, configure the dyeing rules, call the configuration dyeing rule interface of the dyeing configuration microservice, set the HTTP request of a certain version number to a certain color, and the dyeing configuration microservice writes the data to the remote dictionary service after receiving the request;

[0019] S202, synchronize the coloring rules, wait for the set time T, assemble the HTTP request, add the header information of the same version number in the HTTP request, and send the request to the microservice gateway;

[0020] S203, traffic coloring. After receiving the HTTP request, the microservice gateway first retrieves the HTTP header information for matching the coloring rule in the gateway traffic coloring module, colors the traffic according to the coloring rule table, and writes the color information into the HTTP header information.

[0021] S204, perform route selection according to the coloring information. After coloring is completed, the traffic comes to the gateway service discovery module. The gateway service discovery module obtains a list of qualified interface nodes from the microservice list according to the color information in the HTTP header information and the uniform resource locator system. Finally, the request is forwarded to the access interface a1 of the upstream microservice.

[0022] After the S205 traffic arrives at the upstream microservice, the coloring information is obtained from the HTTP header information and stored in the request context. When the business processing needs to call the downstream microservice, the gateway service discovery module matches the coloring information in the context with the downstream node list, and finally sends the request to the downstream microservice;

[0023] S205. Finally, after the downstream microservice completes the business processing, it returns the result to the upstream microservice. The upstream microservice continues to process the business and assembles the response and returns it to the microservice gateway. The microservice gateway will reply to the front end accordingly to complete the entire request.

[0024] As a further improvement of the present invention, in step S202, the microservice gateway synchronizes the dyeing configuration once every set time T.

[0025] The present invention also provides a multi-tenant system based on service and traffic coloring, including a readable storage medium, in which execution instructions are stored. When the execution instructions are executed by a processor, they are used to implement the described method.

[0026] The present invention also provides a multi-tenant system based on service and traffic coloring, including:

[0027] The dyeing configuration microservice is an independent microservice used by administrators to add, delete or modify traffic dyeing rules. The dyeing configuration microservice includes a traffic dyeing rule configuration module and a microservice dyeing module.

[0028] The microservice gateway includes a gateway traffic dyeing module and a gateway service discovery module. The gateway traffic dyeing module is used to read traffic dyeing rules and dye traffic according to the dyeing flag in the request header; the gateway service discovery module is used for communication between the microservice gateway and the microservice registration center and selection of the downstream node list;

[0029] The microservice registration center is used to store and schedule microservices, and realize the mutual communication between microservices and the registration center, and between microservices;

[0030] Remote dictionary service, used to store dyeing rules of dyeing configuration microservice;

[0031] The upstream microservice includes an upstream service coloring module and an upstream logic processing module. The upstream service coloring module is used to read the coloring information in the configuration file when the upstream microservice is started, and register it to the microservice registration center to complete the microservice coloring; the upstream logic processing module is a specific business module, which implements specific business functions according to different systems;

[0032] The downstream microservice includes a downstream service coloring module and a downstream logic processing module. The downstream service coloring module is used to read the coloring information in the configuration file when the downstream microservice is started, and register it to the microservice registration center to complete the microservice coloring; the downstream logic processing module is a specific business module, which implements specific business functions according to different systems.

[0033] As a further improvement of the present invention, data is transferred internally through the context, and HTTP is used to transfer data between services.

[0034] The beneficial effects of the present invention are as follows: through the above scheme, multi-tenancy can be conveniently realized by coloring the service and user traffic. The gateway colors the traffic after detecting the specific parameters of the request, and the traffic is routed according to the coloring information during the subsequent transmission process. Isolation and fairness can be guaranteed for data tenants in transmission, as well as routing opportunities based on tenants. The method and system provide a more flexible and scalable microservice architecture, which can bring greater production efficiency, which will benefit engineers and platform users. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other solutions can be obtained based on these drawings without paying creative work.

[0036] Figure 1 This is an architecture diagram of a multi-tenant system based on service and traffic coloring in the present invention.

[0037] Figure 2 It is a flow chart of a multi-tenant method based on service and traffic coloring of the present invention. DETAILED DESCRIPTION

[0038] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.

[0039] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the scope of protection of the present invention. In addition, the terms "first", "second", etc. are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, features defined as "first", "second", etc. may explicitly or implicitly include one or more of the features. In the description of the present invention, unless otherwise specified, "multiple" means two or more.

[0040] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a direct connection, or an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood by specific circumstances.

[0041] The present invention will be further described below in conjunction with the accompanying drawings and specific implementation methods.

[0042] like Figure 1 As shown, a multi-tenant system based on service and traffic coloring includes a coloring configuration microservice, a microservice gateway, a microservice registration center, an upstream microservice, and a downstream microservice.

[0043] This embodiment is mainly written in lua and golang programming languages. Multi-tenancy can be easily achieved by coloring service and user traffic. The gateway colors the traffic after detecting specific parameters of the request, and the traffic is routed through the coloring information during the subsequent transmission process. For data tenants in transmission, isolation and fairness can be guaranteed, as well as tenant-based routing opportunities. This system provides a more flexible and scalable microservice architecture that can bring greater production efficiency, which will benefit engineers and platform users.

[0044] Pass data internally through context and use HTTP to pass data between services

[0045] Coloring configuration microservice. This module is an independent microservice used by managers to add / delete / modify coloring rules.

[0046] Microservice Gateway: It includes the gateway traffic dyeing module and the gateway service discovery module. The gateway traffic dyeing module is used to read the traffic dyeing rules and dye the traffic according to the dyeing flag in the request header. The gateway service discovery module is used for the communication between the microservice gateway and the microservice registration center and the selection of the downstream node list.

[0047] Microservice registration center: used to store and schedule microservices, and realize mutual communication between microservices and registration center, and between microservices.

[0048] Upstream and downstream microservices: include service coloring module and logic processing module. The service coloring module is used to read the coloring information in the configuration file when the microservice is started, and register it to the microservice registration center to complete the microservice coloring; the logic processing module is a specific business module, which implements specific business functions according to different systems.

[0049] like Figure 2 As shown, a multi-tenant method based on service and traffic coloring specifically includes the following processes:

[0050] Server deployment phase:

[0051] 1. Deploy Redis and microservice registration center (ETCD);

[0052] 2. Deploy dyeing microservice (traffic dyeing rule configuration module);

[0053] 3. Deploy instances A1 (with the coloring information marked as blue) and A2 (with the coloring information marked as default) of upstream microservice A (both A1 and A2 are instances of microservice A, and downstream microservice B needs to be called during business processing);

[0054] 4. Deploy instances B1 (with coloring information marked as red) and B2 (with coloring information marked as default) of downstream microservice B (both B1 and B2 are instances of microservice B);

[0055] 5. Deploy the microservice gateway and register the interface a1 exposed by microservice A with ETCD.

[0056] Redis (Remote Dictionary Server), also known as remote dictionary service, is an open source log-type, Key-Value database written in ANSI C language, supporting the network, memory-based and persistent, and providing APIs in multiple languages.

[0057] ETCD is an open source, highly available distributed key-value storage system developed in Go language, which can be used for configuration sharing and service registration and discovery.

[0058] Multi-tenancy technology (English: multi-tenancy technology) or multi-tenancy technology, is a software architecture technology that explores and implements how to share the same system or program components in a multi-user environment while still ensuring the isolation of data between users.

[0059] The specific configuration and data flow during the use phase are as follows:

[0060] 1. Call the dyeing rule configuration interface of the dyeing microservice, set the HTTP request with version number v1.1 to red, and the dyeing microservice writes the data to Redis after receiving the request;

[0061] 2. After waiting for 2 minutes (the gateway synchronizes the dye configuration every 2 minutes), assemble the HTTP request, add the head (header information, hereinafter the same) with version v1.1 in the HTTP request, and send the request to the microservice gateway to access the a1 interface;

[0062] 3. After receiving the request, the microservice gateway first takes out the HTTP head used to match the dyeing rule in the traffic dyeing module, and matches the dyeing rule in the dyeing rule table. Checking the gateway log, you can see that the gateway traffic dyeing module dyes the traffic red and writes this color information into the HTTP head;

[0063] 4. After coloring, the traffic comes to the gateway service discovery module. The module obtains the list of qualified interface nodes from the microservice list according to the color information and URL in the HTTP head (if there is no node list with the corresponding color, the node list with the default coloring information is selected). Since there is no red microservice A in the deployment environment, the node list of microservice A with the default color is selected. After the subsequent load balancing modules of the gateway, the request is finally forwarded to the a1 interface of A2. By checking the logs of A1 and A2, it can be seen that there is traffic flowing into the A2 microservice;

[0064] 5. After the traffic arrives at microservice A2, the coloring information is obtained from the HTTP head and stored in the request context. When the business processing needs to call microservice B, the microservice service discovery module matches the downstream node list according to the coloring information in the context (if there is no node list with the corresponding color, the node list with the coloring information of default is selected). Because the downstream microservice B deploys a service with the color red, the node list of microservice B with the color red is selected. After passing through the load balancing module, the request is sent to microservice B1. By checking the logs of B1 and B2, it can be seen that there is traffic flowing into the B1 microservice;

[0065] 6. Finally, microservice B1 returns the result to A2 after processing the business. A2 continues to process the business and assembles the response and returns it to the gateway. The gateway replies to the front end accordingly to complete the entire request. The link is "gateway->A2 (default)->B1 (red)".

[0066] URL, or uniform resource locator, is a method of specifying the location of information on the World Wide Web service program of the Internet. It was originally invented by Tim Berners-Lee as the address of the World Wide Web.

[0067] The present invention provides a multi-tenant method and system based on service and traffic coloring. The microservice architecture can provide good scalability and support stable deployment and modularization. Under the microservice architecture, different development teams publish and maintain different modules (microservices), and the business is completed by calling each other through modules (microservices). Therefore, it is necessary to ensure that the technology stack can not only safely publish new changes, but also reliably use the existing parts of the existing architecture. Using multi-tenants in a microservice architecture and allowing multiple systems to coexist is one of the most effective ways to utilize the stability and modularization of microservices. Through the multi-tenant approach, new changes can be better released while ensuring the stable operation of existing services. At the same time, the use of multi-tenants can also conveniently realize the invitation of users to conduct internal testing, provide more personalized services for special users (paying users), distinguish different companies with different traffic colors, etc., which will benefit engineers and platform users.

[0068] The above contents are further detailed descriptions of the present invention in combination with specific preferred embodiments, and it cannot be determined that the specific implementation of the present invention is limited to these descriptions. For ordinary technicians in the technical field to which the present invention belongs, several simple deductions or substitutions can be made without departing from the concept of the present invention, which should be regarded as falling within the protection scope of the present invention.

Claims

1. A multi-tenant method based on service and traffic coloring, characterized in that: Multi-tenancy is achieved by coloring service and user traffic. After detecting the set parameters of the request, the gateway colors the traffic, and the traffic is routed according to the coloring information during the subsequent transmission process. The method The process includes: S1. Server deployment; S2, configuration and data flow in the use phase; Step S1 includes the following sub-steps: S101. Deploy a remote dictionary service and a microservice registration center. The microservice registration center is used to store and schedule microservices, and realize mutual communication between microservices and the registration center, and between microservices. S102. Deploy the dyeing configuration microservice. The dyeing configuration microservice is an independent microservice used by management personnel to add, delete or modify traffic dyeing rules. S103. Deploy an instance of the upstream microservice; S104, deploy an instance of downstream microservices; S105, deploying a microservice gateway, and registering the access interface a1 exposed by the upstream microservice to the microservice registration center; Step S2 includes the following sub-steps: S201, configure the dyeing rules, call the configuration dyeing rule interface of the dyeing configuration microservice, set the HTTP request of a certain version number to a certain color, and the dyeing configuration microservice writes the data to the remote dictionary service after receiving the request; S202, synchronize the coloring rules, wait for the set time T, assemble the HTTP request, add the header information of the same version number in the HTTP request, and send the request to the microservice gateway; S203, traffic coloring. After receiving the HTTP request, the microservice gateway first retrieves the HTTP header information for matching the coloring rule in the gateway traffic coloring module, colors the traffic according to the coloring rule table, and writes the color information into the HTTP header information. S204, perform route selection according to the coloring information. After coloring is completed, the traffic comes to the gateway service discovery module. The gateway service discovery module obtains a list of qualified interface nodes from the microservice list according to the color information in the HTTP header information and the uniform resource locator system. Finally, the request is forwarded to the access interface a1 of the upstream microservice. After the S205 traffic arrives at the upstream microservice, the coloring information is obtained from the HTTP header information and stored in the request context. When the business processing needs to call the downstream microservice, the gateway service discovery module matches the coloring information in the context with the downstream node list, and finally sends the request to the downstream microservice; S205. After the downstream microservice completes the business processing, it returns the result to the upstream microservice. The upstream microservice continues to process the business and assembles the response and returns it to the microservice gateway. The microservice gateway will respond to the front end to complete the entire request.

2. The multi-tenant method based on service and traffic coloring according to claim 1 is characterized in that: The color of the dye information tag used by the upstream microservice instance is different from the color of the dye information tag used by the downstream microservice instance.

3. The multi-tenant method based on service and traffic coloring according to claim 1 is characterized in that: The microservice gateway includes a gateway traffic dyeing module and a gateway service discovery module. The gateway traffic dyeing module is used to read traffic dyeing rules and dye traffic according to the dyeing flag in the request header; The gateway service discovery module is used for communication between the microservice gateway and the microservice registration center and selection of the downstream node list.

4. The multi-tenant method based on service and traffic coloring according to claim 1 is characterized in that: The upstream microservice and the downstream microservice both include a service coloring module and a logic processing module, wherein the service coloring module is used to read the coloring information in the configuration file when the microservice is started, and register it to the microservice registration center to complete the microservice coloring; the logic processing module is a specific business module, which implements specific business functions according to different systems.

5. The multi-tenant method based on service and traffic coloring according to claim 1 is characterized in that: In step S202, the microservice gateway synchronizes the dyeing configuration once every set time T.

6. A multi-tenant system based on service and traffic coloring, characterized in that: The method comprises a readable storage medium in which execution instructions are stored. When the execution instructions are executed by a processor, the execution instructions are used to implement the method according to any one of claims 1 to 5.

7. A multi-tenant system based on service and traffic coloring that implements the method according to any one of claims 1 to 5, characterized in that: include: The dyeing configuration microservice is an independent microservice used by administrators to add, delete or modify traffic dyeing rules. The dyeing configuration microservice includes a traffic dyeing rule configuration module and a microservice dyeing module. The microservice gateway includes a gateway traffic dyeing module and a gateway service discovery module. The gateway traffic dyeing module is used to read traffic dyeing rules and dye traffic according to the dyeing flag in the request header. The gateway service discovery module is used for communication between the microservice gateway and the microservice registration center and selection of the downstream node list; The microservice registration center is used to store and schedule microservices, and realize the mutual communication between microservices and the registration center, and between microservices; Remote dictionary service, used to store dyeing rules of dyeing configuration microservice; The upstream microservice includes an upstream service coloring module and an upstream logic processing module. The upstream service coloring module is used to read the coloring information in the configuration file when the upstream microservice is started, and register it to the microservice registration center to complete the microservice coloring; the upstream logic processing module is a specific business module, which implements specific business functions according to different systems; The downstream microservice includes a downstream service coloring module and a downstream logic processing module. The downstream service coloring module is used to read the coloring information in the configuration file when the downstream microservice is started, and register it to the microservice registration center to complete the microservice coloring; the downstream logic processing module is a specific business module, which implements specific business functions according to different systems.

Citation Information

Patent Citations

  • Traffic scheduling method and device and electronic equipment

    CN113612686A