Routing method for service call request, method and device for creating service

By receiving the environmental indication information of the service call request in the cloud computing platform and performing dynamic routing, the problem of high microservice governance costs in the existing technology is solved, and the effects of dynamic routing and cost reduction are achieved.

CN114938396BActive Publication Date: 2024-09-10ALIBABA (CHINA) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210499122.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-09
Publication Date
2024-09-10
Estimated Expiration
2042-05-09

AI Technical Summary

Technical Problem

When implementing microservice governance capabilities, existing cloud computing platforms rely on registration centers or service grid methods, especially in scenarios such as full-link stress testing, full-link grayscale, and environmental isolation, resulting in relatively high costs and operation and maintenance costs. High, and it is difficult to implement dynamic routing.

Method used

By receiving the environment indication information in the service call request, it determines the environment to which the request belongs, and performs dynamic routing based on the environment indication information and domain name to avoid relying on the registration center and realize dynamic routing of service call requests in different environments.

Benefits of technology

It realizes dynamic routing of service call requests in different environments, reduces the cost of microservice governance, improves the ability to manage complex microservices, and avoids dependence on the registration center.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114938396B
    Figure CN114938396B
Patent Text Reader

Abstract

The present application provides a method for routing a service call request, a method for creating a service, a device and an electronic device. The routing method includes: receiving a first service call request, the first service call request carries environment indication information and a first domain name, and is used to call a first service based on the first domain name, and the environment indication information is used to indicate the environment to which the first service call request belongs; determining whether the first service call request belongs to a second environment according to the environment indication information, and determining whether a second service is deployed in the second environment according to the second domain name; when the first service call request belongs to the second environment and the second environment has a second service deployed, routing the second service call request to the second service based on the second domain name, and the second service call request carries a second domain name, and is used to call the second service based on the second domain name. The technical solution of the present application can realize the microservice governance capability of a cloud computing platform at a relatively low cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of cloud computing technology, and in particular to a method for routing service call requests, a method, device and electronic device for creating services. Background Art

[0002] With the development of cloud computing technology, the concept of cloud native has emerged. Cloud native is a set of cloud technology product systems based on technologies such as containers, microservices, and development and operation (DevOps). Cloud computing platforms can use container technology to provide users with containers to run microservices, and use container management platforms (for example, Kubernetes, or K8s for short) to create and manage containers.

[0003] With the rapid growth of the number of microservices, more complex microservice governance capabilities need to be implemented, such as full-link stress testing, full-link grayscale, and environmental isolation. These scenarios require the routing of service call requests on links composed of multiple services. However, current routing solutions usually rely on a registration center to implement service discovery, or implement service discovery based on a service mesh, which has high implementation and operation and maintenance costs. Summary of the invention

[0004] In view of this, the embodiments of the present application are committed to providing a method for routing service call requests, a method, device and electronic device for creating services, which can realize the microservice governance capability of a cloud computing platform at a relatively low cost.

[0005] In a first aspect, an embodiment of the present application provides a method for routing a service call request, including: receiving a first service call request, the first service call request carrying environment indication information and a first domain name, for calling a first service based on the first domain name, the environment indication information being used to indicate the environment to which the first service call request belongs; determining whether the first service call request belongs to a second environment according to the environment indication information, and determining whether a second service is deployed in the second environment according to a second domain name, the second service being a new version of a third service deployed in the first environment, and the second domain name being a domain name of the second service; when the first service call request belongs to the second environment and the second service is deployed in the second environment, routing the second service call request to the second service based on the second domain name, the second service call request carrying the second domain name, for calling the second service based on the second domain name.

[0006] In a second aspect, an embodiment of the present application also provides a method for creating a service, including: creating a first service and a third service in a first environment according to a first configuration file of the first service and a third configuration file of the third service, wherein the third service is configured downstream of the first service; determining environment indication information according to the second configuration file, the second configuration file containing environment indication information, and the environment indication information is used to indicate that the second service call request belongs to the traffic of the second environment; determining a second domain name based on the environment indication information and the third domain name; creating a second service based on the second domain name, wherein the second service is configured downstream of the first service, and wherein the second service is a new version of the third service deployed in the first environment.

[0007] In a third aspect, an embodiment of the present application provides a routing device for a service call request, characterized in that it includes: a receiving module, used to receive a first service call request, the first service call request carries environment indication information and a first domain name, and is used to call the first service based on the first domain name, and the environment indication information is used to indicate the environment to which the service call request belongs; a determination module, used to determine whether the first service call request belongs to the second environment according to the environment indication information, and determine whether the second environment has a second service deployed according to the second domain name, the second service is a new version of the third service deployed in the first environment, and the second domain name is the domain name of the second service; a routing module, used to route the second service call request to the second service based on the second domain name when the first service call request belongs to the second environment and the second service is deployed in the second environment, the second service call request carries the second domain name, and is used to call the second service based on the second domain name.

[0008] In a fourth aspect, an embodiment of the present application provides a device for creating a service, comprising: a creation module, used to create a first service and a third service in a first environment according to a first configuration file of the first service and a third configuration file of the third service, wherein the third service is configured downstream of the first service; a determination module, used to determine environment indication information according to a second configuration file, the second configuration file containing environment indication information, the environment indication information being used to indicate that the second service call request belongs to the traffic of the second environment, and determine a second domain name based on the environment indication information and the third domain name, wherein the creation module is further used to create a second service based on the second domain name, wherein the second service is configured downstream of the first service, and wherein the second service is a new version of the third service deployed in the first environment.

[0009] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising: a processor; and a memory for storing processor executable instructions, wherein the processor is used to execute the routing method of the first aspect above.

[0010] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program is used to execute the routing method of the first aspect above.

[0011] In a seventh aspect, an embodiment of the present application provides a computer program product, wherein the computer program product includes instructions, and when the instructions are executed by a processor of a computer device, the computer device is enabled to execute the method steps in the above-mentioned implementation mode.

[0012] The embodiment of the present application provides a method for routing service call requests, by preferentially routing the second service call request to the second service when the received first service call request is the traffic of the second environment and the second environment has deployed the second service (i.e. the new version service corresponding to the formal service of the first environment), thereby ensuring that the traffic belonging to the second environment is preferentially routed in the second environment. Since the routing of the service call request in the second environment can be realized based on the domain name of the second service only by judging whether the first service call request belongs to the traffic of the second environment, it is possible to realize dynamic routing of service call requests in different environments without relying on the registration center for service discovery, thereby realizing complex microservice governance capabilities at a lower cost. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 The figure is a schematic diagram of the architecture of a cloud computing system provided by an exemplary embodiment of the present application;

[0014] Figure 2 The figure shows a schematic diagram of the system architecture of a K8s cluster provided by an exemplary embodiment of the present application;

[0015] Figure 3 Shown is a flow chart of a method for creating a service provided by an exemplary embodiment of the present application;

[0016] Figure 4 Shown is a schematic diagram of a routing environment for a service call request provided by an exemplary embodiment of the present application;

[0017] Figure 5 Shown is a flow chart of a method for routing a service call request provided by an exemplary embodiment of the present application;

[0018] Figure 6 Shown is a flow chart of a method for routing a service call request provided by another exemplary embodiment of the present application;

[0019] Figure 7 Shown is a flow chart of a method for routing a service call request provided by another exemplary embodiment of the present application;

[0020] Figure 8Shown is a schematic diagram of a calling process between services provided by an exemplary embodiment of the present application;

[0021] Fig. 9 Shown is a schematic diagram of a calling process between services provided by another exemplary embodiment of the present application;

[0022] Fig.10 Shown is a schematic diagram of a calling process between services provided by another exemplary embodiment of the present application;

[0023] Fig.11 FIG. 1 is a schematic diagram of a grayscale service scaling-down process provided by another exemplary embodiment of the present application;

[0024] Fig.12 Shown is a schematic diagram of the structure of a routing device for a service call request provided by an exemplary embodiment of the present application;

[0025] Fig.13 Shown is a schematic diagram of the structure of an apparatus for creating a service provided by another exemplary embodiment of the present application;

[0026] Fig.14 The figure shows a block diagram of an electronic device provided by an exemplary embodiment of the present application for executing the method of the above embodiment. DETAILED DESCRIPTION

[0027] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0028] The technical solution of the embodiment of the present application can be applied to cloud computing scenarios that provide container operation services.

[0029] In order to facilitate understanding of the technical solutions of the embodiments of the present application, the technical terms appearing in the specification are first explained in detail below.

[0030] Microservice architecture: is an architectural concept that aims to decouple the solution by breaking down the application's functionality into discrete services, and to isolate services by allowing each service to have its own process and run in a container.

[0031] K8s Cluster: is an open source container management platform for managing containers on cloud computing platforms. K8s Service is the external access interface of a group of Pods that provide the same service. With the help of K8s Service, service discovery and load balancing can be easily implemented. K8s Service provides each Pod with its own Internet Protocol (IP) address and provides the same Domain Name System (DNS) for a group of Pods. Each Pod in the group runs the same service and load balancing can be performed between Pods. K8sService is responsible for establishing and maintaining the mapping relationship between Service and Pod.

[0032] Full-link grayscale: When a new version of a service that is running stably needs to be released, problems can be discovered in a timely manner by diverting a small amount of traffic to the new version of the service. Sometimes a new function requires multiple services to be upgraded and launched at the same time. Full-link grayscale is to perform small-traffic grayscale verification on multiple different versions of services by building an environment isolation from the service gateway to the entire backend service.

[0033] Full-link stress testing: refers to stress testing the entire business chain by simulating massive service call requests and data based on actual production business scenarios and system environments.

[0034] Environmental isolation testing: refers to the use of request routing technology to distinguish the distributed call services of the test environment and the production environment to prevent mutual interference between different environments.

[0035] HttpClient: It is a toolkit for client programming and supports the latest version and recommendations of HyperText Transfer Protocol (HTTP). Java applications can directly access network resources through HTTP protocol.

[0036] Java agent technology: also known as Java probe or byte stub, is a technology that can intercept and modify bytecode when loading bytecode and can modify the loaded bytecode during the operation of the virtual machine. For example, the bytecode of the Java agent program can be loaded into the virtual machine together with the bytecode of the main program to run, that is, the Java class can be modified by bytecode enhancement to achieve the desired function.

[0037] Spring Boot: Spring framework is an open source application framework on the Java platform. Spring Boot inherits the excellent features of the original Spring framework, and further simplifies the entire construction and development process of Spring applications by simplifying configuration.

[0038] With the popularity of cloud native, Spring Boot applications can use simple HttpClient tools to call K8sService to achieve intercommunication between services. Since HttpClient is simple and convenient to use with K8s, it is becoming more and more popular among some small and medium-sized enterprises. However, it is difficult to meet the service governance needs of enterprises after the number of microservices increases by simply using HttpClient to call K8s Service. For example, this method can only realize service discovery but not routing, so it is difficult to realize microservice governance capabilities such as grayscale release, full-link grayscale, full-link stress testing, and environmental isolation testing.

[0039] A microservice governance solution requires users to connect Spring Boot applications to the service grid system and add a sidecar to the Pod of the Spring Boot application. In other words, the service governance function is separated from the application itself as a separate process, placed on a host with the main application, and deployed in their own processes or containers. At the same time, the full link also requires the use of SDK for link tracing (Trace) transparent transmission, which results in performance loss (one more hop for each call). In addition, improvements to the microservice architecture will also lead to increased operation and maintenance costs, raising the technical threshold for users.

[0040] Another microservice governance solution requires users to connect Spring Boot applications to Spring Cloud and set up an additional registration center for service discovery, which increases costs.

[0041] In view of the above technical problems, the embodiments of the present application can use a Java agent and K8s's microservice engine (Microservice Engine, MSE) to non-invasively implement dynamic routing capabilities in the scenario where HttpClient and K8s Service are combined. It does not need to access the service grid system or rely on the registration center, aiming to achieve complex microservice governance capabilities at a lower cost.

[0042] Exemplary Systems

[0043] Figure 1The cloud computing system 100 provided by an exemplary embodiment of the present application is shown as a schematic diagram of the architecture, which shows an application scenario of routing service call requests. The cloud computing system 100 may include a user terminal 110, a service gateway 120, an API interface 130 and a service 140.

[0044] The user terminal 110 is connected to the service gateway 120. The user terminal 110 can be a terminal device, such as a mobile phone, a tablet, a notebook, etc. The service gateway 120 is connected to the service 140 deployed in the cloud (for example, a K8s cluster) through the API interface 130.

[0045] The user terminal 110 can call the service deployed in the cloud through, for example, a web browser. Specifically, the user can access a service, such as an order service, on the user interface of the user terminal 110. The client on the user terminal 110 can send a service call request to the service gateway 120 according to the user's access operation.

[0046] The service gateway 120, also known as the ingress controller, is used to forward the traffic of the service call request according to the load distribution rules. For example, after receiving the service call request, the service gateway 120 can send the service call request to a group of Pods corresponding to the service 140 according to the load distribution rules, so that the service 140 provides a service response. In addition, in one embodiment, the service gateway can also distribute the traffic of different environments according to the attribute information carried by the service call request, for example, distribute the traffic of the formal environment to the service of the formal environment, and distribute the traffic of the gray environment to the service of the gray environment.

[0047] In some cases, multiple services 140 can call each other, that is, one service can call another service by sending a service call request to another service. For example, the order service can also call the payment service, and the payment service can call the logistics service, etc. After the call and response between the services, the service gateway finally responds to the user terminal.

[0048] Figure 2 The system architecture diagram of the K8s cluster 200 provided by an exemplary embodiment of the present application is shown. The K8s cluster 200 is also called the K8s container management platform, and may include a master node 210, multiple nodes 220, and an Etcd database 230. The master node 210 is used to run the management control module of the cluster. The node 220 is used to run the container. The Etcd database 230 is used to store the status information of the cluster. Alternatively, the Etcd database 230 may also be included in the master node 210.

[0049] The master node 210 may include management and control modules such as a scheduler 211, a microservice engine component 213, a DNS 214, and an API server 212. The scheduler 211 is used to select nodes for the newly established Pod and is responsible for resource scheduling of the K8s cluster. The API server 212 serves as the entrance to the K8s system and provides service calls to external clients and internal components in the form of an API interface. The microservice engine component is used to provide microservice governance capabilities. For example, the microservice engine component can be the MSE pilot component in K8s, which can monitor the Yaml configuration files uploaded by users and automatically create microservices based on the Yaml configuration files. DNS 214 is used to provide a mapping relationship between the domain name of the service and the IP address of the corresponding Pod.

[0050] Node 220 is also called a worker node, and may include Kubelet 221, Kube proxy 222, and multiple Pods 223. Each Pod 223 is provided with at least one container 224. Kubelet 221 is used to manage and control containers, monitor container operation status, and report to API server 212. Kube proxy 222 is used to obtain the mapping relationship between the domain name of the service and the IP address of the corresponding Pod from API server 212, and implement the routing from the service to the Pod according to the mapping relationship.

[0051] It should be understood that on the K8s container management platform, in addition to the Pods that run services, functional modules such as Kubelet 221 and Kubeproxy 222 can also be implemented using Pods.

[0052] It should be noted that the above application scenarios are only shown to facilitate understanding of the spirit and principle of the present application, and the embodiments of the present application are not limited thereto. On the contrary, the embodiments of the present application can be applied to any scenario that may be applicable.

[0053] Exemplary Methods

[0054] In order to facilitate understanding of the technical solutions of the embodiments of the present application, Figure 3 and Figure 4 , the service creation process is described by taking the K8s scenario as an example. It should be understood that the embodiments of the present application are not limited to the K8s scenario, and can also be applied to other scenarios where service discovery is performed based on domain names.

[0055] Figure 3 Shown is a flowchart of a method for creating a service provided by an exemplary embodiment of the present application. Figure 4 Shown is a schematic diagram of a routing environment for a service call request provided by an exemplary embodiment of the present application. Figure 3 The method can be used by the server, for example Figure 2The master node in the container management platform of the K8s cluster is used for execution. Figure 3 As shown, the method includes the following contents.

[0056] 310: Obtain a first configuration file of the first service and a third configuration file of the third service.

[0057] Specifically, the MSE microservice engine component on the K8s container management platform can obtain the service configuration file input by the user so as to create a service according to the configuration file. For example, the configuration file can be a YAML configuration file, including a deployment part and a service part, which can be manually written by the user.

[0058] 320: Create a first service and a third service according to the first configuration file and the third configuration file, and the third service is configured downstream of the first service.

[0059] Specifically, Kubelet 221 of the K8s container management platform can create a Deployment resource, i.e., a Pod containing a container, according to the Deployment part of the Yaml configuration file, and create a Service resource, i.e., a service running in the container, for the Deployment resource according to the Service part of the Yaml configuration file. Each service corresponds to a group of Pods, and each Pod in the group of Pods can divert a portion of the traffic and run the same service. The first service and the third service can be services that are running stably, hereinafter also referred to as formal services, normal services, or stable services.

[0060] Whenever a new service is created, the DNS server of the K8s cluster will add a mapping between the domain name of the service and the IP address of the Pod running the service, so that the service can be provided through the IP address inside the K8s cluster.

[0061] For example, in the K8s scenario, each service has a unique domain name, and a group of Pods running the service share the domain name, so the service can be called based on the domain name. When creating each service, you can configure the downstream services of each service. For example, see Figure 4, assuming that the implementation of service A needs to call service B, and the implementation of service B needs to call service C, then when creating service A, you can configure downstream service B for it, and when creating service B, you can configure downstream service C for it. When a user wants to access service A, he can send a service call request to the service gateway through the user terminal, the service gateway sends the service call request to service A, service A sends the service call request to service B, and service B sends the service call request to service C. Each service responds after performing its respective tasks, and finally the service gateway responds to the user terminal, thus forming a link including multiple services, thereby realizing the routing of service call requests on the entire service link.

[0062] 330: Obtain a second configuration file of the second service.

[0063] In order to achieve microservice governance, an informal environment (also called an abnormal environment, a test environment, or a gray environment) corresponding to the formal environment can also be established, that is, an informal service corresponding to the formal service is created as needed, hereinafter also referred to as a new version service. The second configuration file can be similar to the first configuration file and is manually generated by the user.

[0064] Alternatively, the second configuration file may only carry the Deployment part, and the K8s microservice engine component, for example, the MSE pilot component, may automatically generate the Service part based on the Deployment part, thereby reducing the workload of manual code writing and improving user experience.

[0065] 340: Determine environment indication information according to the second configuration file.

[0066] The process of creating a new version of a service is similar to the process of creating a formal service. The difference is that the Yaml configuration file of the new version of the service can further carry environment indication information (for example, grayscale environment indication information gray), which can also be called environment tags, environment variables or environment parameters. For example, in the K8s container management platform, the MSE Pilot component can be used to identify the environment indication information in the second configuration file.

[0067] 350: Determine a second domain name based on the environment indication information and the third domain name.

[0068] The K8s container management platform can create a new version of the service based on the environment indication information, and the domain name of the newly created new version of the service is different from the domain name of the formal service. As an example, the domain name of the new version of the service can be automatically spliced ​​by the MSE component 213 by the domain name of the corresponding formal service and the environment indication information, that is, the second domain name is spliced ​​by the third domain name and the environment indication information. The DNS server can add a mapping relationship between the second domain name and the IP address of the corresponding Pod.

[0069] For example, see Figure 2 When it is necessary to deploy Deployment resources, the MSE component 213 receives the Yaml file uploaded by the user, reads the environment indication information from the Yaml file, and generates the domain name of the second service according to the environment indication information. Parameters such as the port in the Service part can be extracted from the Deployment part. The MSE component 213 generates the Service part of the Yaml file according to the domain name and these parameters. In addition, the MSE component 213 can also inject the installation logic of the Java agent program into the Yaml file, and finally send the Yaml file to the Api server 212 for subsequent creation of Deployment resources and corresponding Services.

[0070] 360: Create a second service based on the second domain name, and the second service is configured downstream of the first service as a new version of the third service, wherein the second service is a new version of the third service deployed in the first environment.

[0071] When creating a Deployment resource, the K8s container management platform can first create an initialization container and a main container according to the installation logic of the Java agent program in the YAML file. The initialization container can be run first, and the Java agent program can be downloaded by the initialization container and installed in the main container.

[0072] The second service and the third service are both downstream services of the first service. Part of the traffic of the first service is routed to the second service, and the other part of the traffic is routed to the third service.

[0073] For example, see again Figure 4 , Service D is the new version of Service A, and Service E is the new version of Service C. Service D and Service E constitute an abnormal environment. In this way, the traffic for the official version is sent by the user device, passing through the service gateway, Service A, Service B, and Service C in turn, while the traffic for the new version service is sent by the user device, passing through the service gateway, Service D, Service B, and Service E in turn.

[0074] An embodiment of the present application provides a method for creating a service, by determining environment indication information according to a configuration file carrying the environment indication information, determining the domain name of a new version of the service based on the environment indication information and the domain name of the official service, and creating a new version of the service based on the domain name of the new version of the service, so that service discovery can be performed through the association relationship between the domain names of the official service and the new version of the service without relying on a registration center, thereby realizing dynamic routing of service call requests, thereby realizing complex microservice governance capabilities at a lower cost.

[0075] Taking full-link grayscale as an example, the new version of the service can be implemented by another group of Pods, each of which is deployed with the new version of the service, to divert part of the traffic of the official service for full-link grayscale. For example, after the new version of the service is verified, all the traffic of the official service can be switched to the new version of the service. Therefore, the implementation process of full-link grayscale is also a process of gradually establishing new Pods to run the new version of the service and gradually destroying the Pods of the official service until all the traffic is switched to the new version of the service, at which point the new version of the service becomes the official service.

[0076] The above describes the process of service creation. After the service is created, the related service can be called according to the service call request sent by the user terminal to realize dynamic routing of the service call request in different environments.

[0077] In order to facilitate understanding of the technical solutions of the embodiments of the present application, Figure 5 to Figure 6 A method for routing service call requests according to an embodiment of the present application is introduced.

[0078] Figure 5 Shown is a flow chart of a method for routing a service call request provided by an exemplary embodiment of the present application. Figure 5 The method can be executed by a computing device. Taking the K8s scenario as an example, the computing device can be Figure 2 Specifically, when the service it runs calls other services, the working node can act as a client, and when the service it runs is called by other services, the working node can act as a server. It should be understood that the service of the embodiment of the present application can be based on Figure 3 After the service is created, Figure 5 As shown, each service can implement dynamic routing of service call requests in the following way.

[0079] 510: Receive a first service call request, where the first service call request carries environment indication information and a first domain name, and is used to call a first service based on the first domain name, and the environment indication information is used to indicate an environment to which the service call request belongs.

[0080] Specifically, the first service can be a service created in the first environment or a service created in the second environment. The first domain name is a domain name set for the first service when the first service is created, and is used as the target domain name of the first service call request when the first service is called. The first domain name can be pre-configured according to the configuration file provided by the user when the first service is created. Different from the method of using IP for service discovery, using domain names for service discovery does not rely on the registration center, so that complex microservice governance capabilities can be achieved at a lower cost.

[0081] The first environment may refer to a formal environment (also called a normal environment or a stable environment) in which the service is running stably, and the second environment may be an informal environment (also called an abnormal environment or an unstable environment) used for development or testing, for example, a grayscale environment, an isolated environment, or a stress testing environment.

[0082] The environment indication information may be set in a header attribute in the service call request, or may be set in a reserved field outside the header attribute in the service call request. The environment indication information may be an inherent attribute in the service call request, or may be additional information added to indicate the environment to which the service call request belongs. For example, the environment indication information may be an environment tag (e.g., a grayscale tag) used to indicate that the service call request is a second environment (e.g., a grayscale environment).

[0083] The first service call request may be a request message generated by using a Remote Procedure Call (RPC) protocol of the application layer, for example, a request message generated by using an Http protocol, an RPC protocol, or a dubbo protocol.

[0084] Taking the Http protocol as an example, the first service call request may be an Http request. The Http request may carry the first domain name as the target address to implement routing.

[0085] In one embodiment, when the first service is the first service accessed on the service link, the first service call request may be a service call request from a service gateway. For example, when a user wants to access the first service, the user may send a service call request to the service gateway through a web browser on the user terminal, and the service gateway sends the first service call request to the first service in response to the service call request.

[0086] In another embodiment, the first service call request may also be a service call request from a client of another service. For example, the other service sends the first service call request to the first service in response to the service call request sent by the service gateway.

[0087] 520: Determine whether the first service call request belongs to the second environment according to the environment indication information, and determine whether the second environment has a second service deployed according to the second domain name, the second service is a new version of the third service deployed in the first environment, and the second domain name is the domain name of the second service.

[0088] Specifically, when the environment indication information meets the preset conditions, it is determined that the first service call request belongs to the traffic of the second environment. In one embodiment, it can be determined whether the first service call request belongs to the traffic of the second environment based on the attribute information carried in the first service call request. The environment indication information can be request feature information or traffic feature information carried by the service call request itself, which is used to indicate traffic with some commonality, for example, traffic belonging to a certain network segment or computer room is the traffic of the second environment. As another embodiment, it can be determined whether the first service call request belongs to the traffic of the second environment based on the environment tag carried in the first service call request.

[0089] The third service (official service) is the service of the first environment (official environment), and the second service (grayscale service) is the new version service of the second environment.

[0090] It should be understood that the embodiment of the present application does not limit the execution order of the step of determining whether the first request belongs to the second environment and the step of determining whether the second service is deployed in the second environment.

[0091] 530: When the first service call request belongs to the second environment and the second service is deployed in the second environment, the second service call request is routed to the second service based on the second domain name, and the second service call request carries the second domain name for calling the second service based on the second domain name.

[0092] In one embodiment, if the first service call request belongs to the second environment, it can be further determined whether a second service is deployed in the second environment. For example, it can be determined whether a new version of the service corresponding to the formal service to be called is deployed in the grayscale environment. If the second service is deployed in the second environment, a second service call request carrying environment indication information is generated, and the second service call request is routed to the second service based on the second domain name of the second service, thereby ensuring that the traffic belonging to the second environment is routed preferentially in the second environment.

[0093] In one embodiment, a third service call request may be generated first, and then the environment indication information may be added to the third service call request to obtain the second service call request. The third service call request is used to call the third service based on a third domain name, and the third domain name is the domain name of the third service.

[0094] In one embodiment, a third service calling request may be generated first, and then the third domain name in the third service calling request may be modified to the second domain name to obtain the second service calling request.

[0095] The embodiment of the present application provides a method for routing service call requests, by preferentially routing the second service call request to the second service when the received first service call request is the traffic of the second environment and the second environment has deployed the second service (i.e. the new version service corresponding to the formal service of the first environment), thereby ensuring that the traffic belonging to the second environment is preferentially routed in the second environment. Since the routing of the service call request in the second environment can be realized based on the domain name of the second service only by judging whether the first service call request belongs to the traffic of the second environment, it is possible to realize dynamic routing of service call requests in different environments without relying on the registration center for service discovery, thereby realizing complex microservice governance capabilities at a lower cost.

[0096] Optionally, as another embodiment, Figure 5 The routing method also includes: when the first service call request belongs to the second environment and the second environment does not deploy the second service, routing the third service call request to the third service based on the third domain name, where the third domain name is the domain name of the third service.

[0097] Specifically, in some cases, although the first service call request belongs to the traffic of the second environment, the downstream service of the first service does not deploy the service of the second environment. In this case, the third service call request can be routed to the third service based on the third domain name of the third service. For example, the first service call request belongs to the grayscale traffic, and the third service belongs to the formal service. Because the third service does not run at the same time as the grayscale service, the first service call request can be routed to the third service, so that downgrade processing can be achieved to ensure the normal operation of the entire service link.

[0098] Optionally, as another embodiment, Figure 5 The routing method also includes: when the first service call request belongs to the traffic of the first environment, routing the fourth service call request to the third service based on the third domain name.

[0099] Specifically, if the first service call request belongs to the traffic of the formal environment, the first service call request can be directly routed to the third service that also belongs to the formal environment, so that the formal service can be routed in the formal environment.

[0100] Optionally, as another embodiment, in 520, the domain name system of the container management platform may be used to perform domain name resolution on the second domain name, and when the domain name resolution is successful, it is determined that the second service is deployed in the second environment.

[0101] For example, in K8s, the client of the first service can send a PING command to the DNS server to detect whether the second domain name exists, and determine whether the second domain name exists based on the response of the DNS server. If the DNS service returns a successful response, it can be determined that the second environment has deployed the second service.

[0102] By setting the mapping relationship between the domain name of the second service and the corresponding Pod on the DNS server when creating the second service, and determining whether the domain name exists through DNS detection to determine whether the second service is deployed in the second environment, the second service can be discovered without the registration center, thereby enabling the routing of the second service call request to be achieved at a lower cost.

[0103] Optionally, as another embodiment, Figure 5 The routing method also includes: before routing the second service call request to the second service based on the second domain name, generating a third service call request, and adding environment indication information to the third service call request to obtain the second service call request.

[0104] In order to realize the link tracking function, environment indication information can be added to the service call request, so that the environment indication information can be transparently transmitted on the service link along with the service call request to realize various functions related to link tracking. In addition, it is also possible to determine whether the service call request belongs to the second environment based on the environment indication information carried in the service call request, so that the environment to which the traffic belongs can be determined without parsing other attribute information of the service call request, thereby simplifying the processing flow.

[0105] Specifically, the bytecode of the Java agent program can be added to the bytecode of the main program of the first service, the bytecode of the main program is used to generate a third service call request, and the bytecode of the Java agent program is used to add environment indication information to the third service call request. Here, the main program refers to the source code for implementing the first service.

[0106] For example, the second service call request can be an Http request generated by the HttpClient tool on the client of the first service, and the bytecode of the Java agent program can be added to the bytecode of the main program of the first service in a bytecode enhancement manner, and the environment indication information can be added to the Http request using the bytecode of the Java agent program running in the client of the first service.

[0107] Specifically, in the Http client, the bytecodes formed after the Java class is compiled can be loaded and executed by the Java Virtual Machine (JVM), and the Java proxy technology can be used to obtain these bytecodes before they are executed, and modify these bytecodes to complete the function of adding grayscale environment indication information for Http requests by running these bytecodes in the virtual machine. Since the method of intercepting and modifying the bytecodes does not modify the source code of the service, the function of adding environment indication information can be implemented in a non-intrusive manner, thereby realizing link tracking (trace).

[0108] When the Http client of the first service uses Java proxy technology to enhance HttpClient, the bytecode of the Java proxy program with the following functions can be added when the bytecode of the main program is loaded: before the client of the first service calls the third service, it first determines the environment in which the current traffic is located. If the current traffic is in a grayscale environment, a DNS detection is performed on the domain name of the second service. If the DNS detection fails, the third service in the formal environment is called.

[0109] In one embodiment, a third service calling request may be generated first, and then the third domain name in the third service calling request may be modified to the second domain name to obtain the second service calling request.

[0110] Specifically, the bytecode of the Java agent program can be added to the bytecode of the main program of the first service, the bytecode of the main program is used to generate a third service call request, and the bytecode of the Java agent program is used to modify the third domain name in the third service call request to the second domain name.

[0111] In one embodiment, the second domain name can be determined by the third domain name of the third service and the environment tag, that is, there is a corresponding relationship between the second domain name and the third domain name, specifically, there is a conversion relationship between the second domain name and the third domain name, for example, the second domain name can be spliced ​​by the third domain name and the environment tag, that is, it is added at a position adjacent to the third domain name in the third service call request. For example, the third domain name is: http: / / weeget-bullet-goods-rest-svc.namespace.svc.cluster.local:9390, and accordingly, after splicing the environment tag {tag} on the third domain name, the second domain name can be: http: / / weeget-bullet-goods-rest-svc-{tag}.namespace.svc.cluster.local:9390.

[0112] Specifically, the target address carried by the Http request can be modified from the third domain name to the second domain name by using the Java agent program. That is, without changing the service source code, the byte code of the main program is first used to generate an Http request for calling the third service (i.e., the formal service), wherein the Http request includes the third domain name as the target address, and by running the byte code of the Java agent program, the environment indication information is added to the position after the third domain name, so that the routing of the service call request can be realized in a non-invasive manner without changing the service source code.

[0113] Specifically, the Http request can be modified by using a Java agent to perform bytecode enhancement, so as to add environment indication information to the Http request and modify the domain name of the target service. Since this modification operation is achieved by combining the compiled bytecode of the main program with the compiled bytecode of the Java agent, the source code of the service will not be modified, so that the routing and link tracking of the Http request in the gray environment can be achieved non-invasively.

[0114] It should be understood that the environment indication information in the domain name of the second service and the environment indication information used to indicate the traffic of the second environment can be set in different positions in the second service call request, and the two can be the same or different. The embodiments of the present application are not limited to this.

[0115] In one embodiment, a diversion rule for determining the flow of the second environment may also be set, and the flow that meets the diversion rule enters the new version service for processing, and the flow that does not meet the diversion rule enters the formal service for processing. The diversion rule may be deployed on the user terminal or service gateway, or on the client of each service. If the device that deploys the flow rule determines that the current flow meets the flow rule, the environment indication information may be added to the service call request sent to the next hop.

[0116] Specifically, it is possible to determine whether the first service call request belongs to the second environment traffic based on the preset diversion rules and the user attribute information carried in the first service call request. For example, the attribute User-agent in the header of the Http request can indicate the name and version of the operating system and browser used by the client, and the attribute Cookie can be used to identify the user identity, etc. Therefore, it is possible to determine that a portion of the user traffic is the second environment traffic based on these user attribute information. If the user attribute information carried in the first call service request meets the preset diversion rules, for example, the browser used by the user is a certain brand of browser, then the first service call request is considered to be the traffic of the second environment.

[0117] In another embodiment, if the service gateway or other service that calls the first service has added the environment indication information to the first service call request, for example, added it to the attribute information in the header of the first service call request, then the client of the first service can directly determine that the first service call request belongs to the traffic of the second environment based on the environment indication information carried in the first service call request. For example, the environment indication information can be added to the Baggage attribute in the header. Since most RPC protocols support the Baggage attribute, setting the storage location of the environment indication information in this way can improve the universality of the embodiments of the present application.

[0118] The embodiment of the present application does not limit the position of the environment indication information in the header. For example, the environment indication information can be set in the Baggage attribute or in other attribute items. In addition, the embodiment of the present application does not limit the form of the environment indication information. For example, it can be determined whether the first service call request belongs to the second environment based on whether there is information in a reserved bit. If there is information in the reserved bit, it means that it belongs to the second environment, and if there is no information in the reserved bit, it means that it does not belong to the first environment. It can also be determined whether the first service call request belongs to the second environment based on whether there is specific information in a certain position, for example, whether the value of the specific information in the position is 1 or gray.

[0119] It should be understood that the first service and the second service can be created by the K8s container management platform, and the above routing method can be implemented, for example, by a Java agent program running on the client of the first service.

[0120] Optionally, as another embodiment, Figure 5 The routing method may also include: receiving an online message sent by a first provider of the second service, the online message including identification information of the first provider; adding identification information to a provider list, the provider list including identification information of providers running the second service; receiving a going offline message sent by the first provider, the going offline message including identification information for indicating that the first provider is about to go offline; deleting the identification information from the provider list according to the going offline message; when the provider list is empty, stopping calling the second service, adding environment indication information to a fifth service call request, and routing the fifth service call request to the third service based on a third domain name of the third service.

[0121] The specific implementation of this embodiment can be found in Fig.11 The embodiments of the present invention will not be described in detail here.

[0122] Figure 6 Shown is a flow chart of a method for routing a service call request provided by another exemplary embodiment of the present application. Figure 6 The routing method is Figure 5 , and the detailed description is omitted here.

[0123] 610: Receive a first service invocation request sent by a service gateway or a service client based on a first domain name of a first service.

[0124] 620: Parse the first service call request and obtain a parsing result.

[0125] For example, when determining whether the first service call request belongs to the traffic of the second environment, it can be achieved by parsing the attribute information of the first service call request.

[0126] In one embodiment, the parsing result may include environment indication information, which is used to indicate that the first service call request is traffic of the second environment. For example, in the first service call request, the environment indication information may be included in the attribute information of the header of the first service call request.

[0127] In another embodiment, the parsing result may include user attribute information to indicate which type of user the first service call request belongs to, for example, a user using a certain type of browser, a user within a certain IP address range, etc., so that appropriate user traffic can be preferentially selected for testing or verification.

[0128] 630: Determine whether the first service call request belongs to the second environment according to the parsing result. If yes, execute 650; otherwise, execute 640.

[0129] Specifically, it can be determined that the first service call request belongs to the traffic of the second environment according to the environment indication information, or it can be determined that the first service call request belongs to the traffic of the second environment when the user attribute information meets a preset condition.

[0130] 640: Generate a third service call request, and route the fourth service call request to the third service based on the third domain name.

[0131] It should be understood that step 640 is optional and may be implemented in other ways.

[0132] 650: Determine whether the second service is deployed in the second environment. If yes, execute 660; otherwise, execute 680.

[0133] Specifically, whether the second service is deployed in the second environment can be detected based on the second domain name, and when the second domain name is detected, it is determined that the second service is deployed in the second environment, wherein the second domain name can be spliced ​​by the domain name of the third service and the environment indication information.

[0134] 660: Generate a third service call request, and add environment indication information to the third service call request to obtain a second service call request.

[0135] For example, when the third service call request is an Http request, the environment indication information can be added to the attribute information of the header of the Http request by using the Java agent program running in the client of the first service.

[0136] 670: Routing the second service call request to the second service based on the second domain name of the second service.

[0137] Specifically, when the first service call request belongs to the traffic of the first environment, the second service call request is routed to the second service based on the second domain name.

[0138] Specifically, the target domain name carried in the second service call request may be modified from the third domain name to the second domain name by using the Java agent program running in the client of the first service.

[0139] 680: Generate a third service call request and add environment indication information to the third service call request.

[0140] 690: Routing the third service call request carrying the environment indication information to the third service based on the third domain name of the third service.

[0141] Specifically, when the first service call request belongs to the traffic of the second environment and the second service is not deployed in the second environment, environment indication information is added to the third service call request, and the third service call request is routed to the third service based on the third domain name of the third service.

[0142] It should be understood that steps 680 and 690 are optional steps and may be implemented in other ways.

[0143] Combine the following Figures 7 to 11 Taking the use of HttpClient+K8s service in a cloud-native scenario as an example to call the service, the process of realizing the full-link grayscale capability by non-invasively enhancing HttpClient in an embodiment of the present application is described.

[0144] Specifically, when it is necessary to create a service A named ServiceA, K8s can create a Pod according to the Deployment part in the Yaml configuration file of service A provided by the user, and use Deployment as the resource object to create service A according to the Service part in the Yaml configuration file.

[0145] When a user creates a grayscale service B (i.e., a new version of service B) for service A in the formal environment, the grayscale environment tag gray can be added to the Yaml configuration file of grayscale service B. For example, add the code: xxxcloud.service.tag=gray to the Yaml configuration file. After receiving the Yaml configuration file, the K8s microservice engine automatically identifies the grayscale environment tag through the msepilot component, and then concatenates the grayscale environment tag with the domain name of the formal service to obtain the domain name of the grayscale service B, and creates grayscale service B based on the domain name.

[0146] For example, K8s can first create a new Pod based on the YAML configuration file of the deployment of the grayscale service B provided by the user, and use the new Pod as the object to create the corresponding grayscale service B according to the YAML configuration file of the grayscale service B, where the name of the grayscale service B can be 'svcname'+'-'+'environmental indication information', and Mse pilot will automatically create a corresponding K8s service 'svcname'+'-'+'environmental indication information' for the grayscale service B, for example, serviceA-gray.

[0147] For example, the domain name of service A can be one of the following:

[0148] http: / / weeget-bullet-goods-rest-svc.namespace.svc.cluster.local:9390;

[0149] http: / / weeget-bullet-goods-rest-svc.namespace:9390;

[0150] http: / / weeget-bullet-goods-rest-svc:9390.

[0151] According to an embodiment of the present application, by concatenating the domain name of service A in the formal environment with the grayscale label, the domain name of the corresponding grayscale service B can be obtained. For example, the domain name of the grayscale service B can be one of the following:

[0152] http: / / weeget-bullet-goods-rest-svc-{tag}.namespace.svc.cluster.local:9390;

[0153] http: / / weeget-bullet-goods-rest-svc-{tag}.namespace:9390;

[0154] http: / / weeget-bullet-goods-rest-svc-{tag}:9390.

[0155] Figure 7 Shown is a flow chart of a method for routing a service call request provided by another exemplary embodiment of the present application. Figure 7 The routing method is Figure 5 Examples of routing methods. Figure 7 As shown, the routing method of the service call request includes the following contents.

[0156] 710: The user terminal sends an HTTP request to the service gateway.

[0157] 715: The service gateway sends an HTTP request to the first service.

[0158] 720: The first service parses the new HTTP request and obtains a parsing result.

[0159] 725: The first service determines whether the HTTP request belongs to the grayscale environment according to the parsing result. If yes, execute 740; otherwise, execute 730.

[0160] 730: The first service generates an HTTP request and adds a grayscale environment tag to the HTTP request.

[0161] See also Figure 8 , the Http client may be, for example, an Ok Http client, an Apache Http client, or a JDK Http client. Specifically, the HttpClient tool on the Http client (also called the service consumer) may be used to generate an Http request. For example, the bytecode compiled by the main program is enhanced by the bytecode compiled by the Java agent. When the bytecodes are loaded and run by the Java virtual machine, the bytecode of the main program is first used to generate an Http request, and then the bytecode of the Java agent is used to add a grayscale environment tag to the Http request.

[0162] like Figure 8As shown, the user attribute env=gray in the service call request indicates that the service call request is grayscale traffic, and the user attribute env=base in the service call request indicates that the service call request is formal traffic. The bytecode of the main program of the Http client is loaded and run in the virtual machine, and an Http request for calling the third service is generated, which includes the target domain name http: / / rest-svc:8080 / sayHello of the third service (formal service). When the Java agent is loaded and run in the virtual machine, if the received Http request is grayscale traffic, a gray label is added to the attribute in the header of the newly generated Http request, and the target domain name and the grayscale environment label gray are concatenated to obtain the domain name http: / / rest-svc-gray:8080 / sayHello. Then a DNS probe is performed to determine whether the domain name http: / / rest-svc-gray:8080 / sayHello exists. If so, the target domain name of the Http request is modified to http: / / rest-svc-gray:8080 / sayHello, and the Http request is routed to the provider of the second service in the grayscale environment through the mapping relationship between the service provided by K8s and the IP address of the corresponding service provider (or Pod).

[0163] See also Fig. 9 If a DNS error occurs, that is, after DNS detection, it is found that the domain name http: / / rest-svc-gray:8080 / sayHello does not exist, the mapping relationship between the service provided by K8s and the IP address of the corresponding service provider (or Pod) can be used to route the Http request carrying the grayscale environment label to the provider of the third service in the formal environment, thereby realizing automatic service degradation. In this way, the grayscale environment label can be used as a trace identifier (trace id) to be transmitted along with the Http request in the service link, thereby realizing the full-link grayscale capability.

[0164] In addition, if the Http request is traffic from the formal environment, the Http request is directly routed to the provider of the third service in the formal environment through the above mapping relationship provided by K8s.

[0165] 735: The first service sends an HTTP request to the third service.

[0166] 740: The first service detects whether the domain name of the second service exists. If yes, execute 755; otherwise, execute 745.

[0167] 745: The first service generates an HTTP request and routes the HTTP request to the third service.

[0168] 750: The third service sends an HTTP response to the first service.

[0169] 755: The first service adds a grayscale environment tag to the HTTP request and changes the target address in the HTTP request from the third domain name to the second domain name.

[0170] 760: The first service routes the HTTP request to the second service.

[0171] 765: The second service makes a service response to the first service.

[0172] 770: The first service sends an HTTP response to the service gateway.

[0173] 775: The service gateway sends an HTTP response to the user terminal.

[0174] According to the embodiments of the present application, based on HttpClient as the client and K8s service discovery mechanism, without changing the existing architecture or the source code of the service, HttpClient is enhanced through Java agent technology so that it cooperates with the service discovery mechanism of K8s Service to achieve full-link grayscale and other capabilities.

[0175] Combine the following Fig.10 and Fig.11 The downscaling process of the service in the grayscale environment of the embodiment of the present application is described.

[0176] Fig.10 Shown is a schematic diagram of a calling process between services provided by another exemplary embodiment of the present application.

[0177] According to the embodiments of the present application, when the client of the service calls the service normally, it follows the principle that the service of the formal environment calls the service of the formal environment, and the service of the gray environment preferentially calls the service of the gray environment. If the service of the gray environment experiences pod shrinkage (the service is actively offline), the embodiments of the present application can ensure that the traffic is automatically switched back (or rolled back to) the default formal environment service through a lossless offline mechanism.

[0178] Fig.11 Shown is a schematic diagram of a scaling-down process of a service in a grayscale environment provided by another exemplary embodiment of the present application. Fig.11 The shrinking process includes the following contents.

[0179] 1110: The HTTP client of the first service sends an HTTP request to the provider of the second service in the grayscale environment to call the second service.

[0180] As mentioned above, under normal circumstances, when receiving an Http request in a grayscale environment, the Http client of the first service can send an http request to the provider of the second service to call the second service.

[0181] 1120: The HTTP client of the first service may maintain and cache a list of addresses of called service providers.

[0182] Specifically, the Http request carries the IP address of the provider (Pod) of the first service as the source address. After receiving the Http request, the provider of the second service can send an online message to the provider of the first service. The online message carries the IP address of the provider of the second service, and caches the IP address in the address list.

[0183] 1130: When the provider of the second service is ready to scale down to 0, assuming that the last provider of the service is ready to go offline, it enters the pre-stop phase and the provider of the second service marks itself as being offline.

[0184] 1140: The provider of the second service may proactively notify the Http client of the first service of the upcoming offline message. After receiving the upcoming offline message, the Http client will proactively refresh the cached address list.

[0185] 1150: When the Http client finds that the address list is empty, it stops accessing the second service and actively accesses the service in the formal environment.

[0186] 1160. When the second service provider finds that the request processing is complete, it starts to execute the offline process.

[0187] According to an embodiment of the present application, if the Pod corresponding to the service in the grayscale environment is reduced in capacity, the traffic can be automatically switched back to the formal environment through a lossless offline mechanism, thereby ensuring the normal operation of the service and improving the user experience.

[0188] It should be understood that in the scenario of full-link stress testing or environmental isolation, the routing process of the service call request and the service scaling process are similar to the full-link grayscale scenario in the above-mentioned embodiment, and will not be repeated here. Unlike the full-link grayscale, in the scenario of full-link stress testing or environmental isolation, the user device can determine whether the service call request belongs to the second environment, and add environmental indication information to the service call request sent to the service gateway. Accordingly, after receiving the service call request, the service gateway can first parse the service call request to obtain the environmental indication information, and carry the environmental indication information in the service call request sent to the downstream service, and each downstream service can route the service call request according to the routing method of the above-mentioned embodiment.

[0189] Exemplary Devices

[0190] Fig.12 FIG. 1 is a schematic diagram of a structure of a routing device 1200 for a service call request provided by an exemplary embodiment of the present application. Fig.12 As shown, the routing device 1200 includes: a receiving module 1210 , a determining module 1220 and a routing module 1230 .

[0191] The receiving module 1210 is used to receive a first service call request, which carries environment indication information and a first domain name and is used to call a first service based on the first domain name. The environment indication information is used to indicate the environment to which the first service call request belongs.

[0192] Determination module 1220 is used to determine whether the first service call request belongs to the second environment according to the environment indication information, and determine whether the second environment has a second service deployed according to the second domain name, the second service is a new version of the third service deployed in the first environment, and the second domain name is the domain name of the second service.

[0193] Routing module 1230 is used to route the second service call request to the second service based on the second domain name when the first service call request belongs to the second environment and the second service is deployed in the second environment. The second service call request carries the second domain name and is used to call the second service based on the second domain name.

[0194] The embodiment of the present application provides a routing device for service call requests, which preferentially routes the second service call request to the second service when the received first service call request is the traffic of the second environment and the second environment has deployed the second service (i.e., the new version service corresponding to the formal service of the first environment), thereby ensuring that the traffic belonging to the second environment is preferentially routed in the second environment. Since the routing of the service call request in the second environment can be realized based on the domain name of the second service only by judging whether the first service call request belongs to the traffic of the second environment, it is possible to realize dynamic routing of service call requests in different environments without relying on the registration center for service discovery, thereby realizing complex microservice governance capabilities at a lower cost.

[0195] Optionally, as another embodiment, the routing module 1230 is also used to generate a third service call request before routing the second service call request to the second service based on the second domain name, the third service call request being used to call a third service based on a third domain name, the third domain name being the domain name of the third service; adding environment indication information to the third service call request to obtain the second service call request.

[0196] Optionally, as another embodiment, the routing module 1230 is further used to add the bytecode of the Java agent program to the bytecode of the main program of the first service in a bytecode enhancement manner. The routing module 1230 is used to generate a third service call request using the bytecode of the main program, and to add environment indication information to the third service call request using the bytecode of the Java agent program.

[0197] Optionally, as another embodiment, the routing module 1230 is also used to generate a third service call request before routing the second service call request to the second service based on the second domain name, the third service call request being used to call a third service based on a third domain name, where the third domain name is the domain name of the third service; the third domain name in the third service call request is modified to the second domain name to obtain the second service call request.

[0198] Optionally, as another embodiment, the routing module 1230 is also used to add the bytecode of the Java agent program to the bytecode of the main program of the first service in a bytecode enhancement manner, and use the bytecode of the main program to generate a third service call request, the third service call request is used to call a third service based on a third domain name, the third domain name is the domain name of the third service, and use the bytecode of the Java agent program to modify the third domain name in the third service call request to the second domain name to obtain a second service call request.

[0199] In one embodiment, the determination module 1220 is used to perform domain name resolution on the second domain name by using the domain name system of the container management platform, and if the domain name resolution is successful, determine that the second environment has the second service deployed.

[0200] Optionally, as another embodiment, the routing module 1230 is also used to route the third service call request to the third service based on the third domain name when the first service call request belongs to the second environment and the second service is not deployed in the second environment, where the third domain name is the domain name of the third service.

[0201] In one embodiment, the environment indication information includes an environment tag, and the environment tag is used to indicate that the first service call request belongs to the second environment, and the second domain name is determined by the domain name of the third service and the environment indication information of the second environment.

[0202] In one embodiment, the receiving module 1210 is used to receive a first service call request sent by a service gateway or a client of a fourth service based on a first domain name, and the first service call request carries an environment tag of a second environment. The determining module 1220 is used to parse the first service call request, obtain the environment tag, and determine that the first service call request belongs to the traffic of the second environment according to the environment tag.

[0203] In one embodiment, the receiving module 1210 is used to receive a first service call request sent by a service gateway or a client of a fourth service based on a first domain name, parse the first service call request, obtain attribute information, and when the attribute information meets a preset condition, determine that the first service call request belongs to the traffic of the second environment.

[0204] Optionally, as another embodiment, the routing module 1230 is also used to receive an online message sent by the first provider of the second service, the online message including identification information of the first provider; add the identification information to a provider list, the provider list including identification information of the provider running the second service; receive a going offline message sent by the first provider, the going offline message including identification information for indicating that the first provider is about to go offline; delete the identification information from the provider list according to the going offline message; when the provider list is empty, stop calling the second service, add environment indication information to the fifth service call request, and route the fifth service call request to the third service based on the third domain name.

[0205] In one embodiment, the first environment is a formal environment, the second environment is a grayscale environment, an isolated environment, or a stress testing environment, the first service call request is generated by an HttpClient tool, and the first service is created by a K8s container management platform.

[0206] It should be understood that the operations and functions of the receiving module 1210, the determining module 1220, the routing module 1230, and the creating module 1240 in the above embodiment can refer to the above Figure 5 or Figure 6 The description of the routing method provided in the embodiment will not be repeated here to avoid repetition.

[0207] Fig.13 FIG. 1 is a schematic diagram of a structure of an apparatus 1300 for creating a service provided by an exemplary embodiment of the present application. Fig.13 As shown, the device 1300 includes: a creation module 1310 and a determination module 1320 .

[0208] The creation module 1310 is used to create a first service and a third service in a first environment according to a first configuration file of the first service and a third configuration file of the third service, wherein the third service is configured downstream of the first service.

[0209] The determination module 1320 is used to determine the environment indication information according to the second configuration file, the second configuration file includes the environment indication information, the environment indication information is used to indicate that the second service call request belongs to the traffic of the second environment, and determine the second domain name based on the environment indication information and the third domain name.

[0210] The creation module 1310 is further used to create a second service based on the second domain name, wherein the second service is configured downstream of the first service, and wherein the second service is a new version of the third service deployed in the first environment.

[0211] An embodiment of the present application provides a method for creating a service, by determining environment indication information according to a configuration file carrying the environment indication information, determining the domain name of a new version of the service based on the environment indication information and the domain name of the official service, and creating a new version of the service based on the domain name of the new version of the service, so that service discovery can be performed through the association relationship between the domain names of the official service and the new version of the service without relying on a registration center, thereby realizing dynamic routing of service call requests, thereby realizing complex microservice governance capabilities at a lower cost.

[0212] It should be understood that the operations and functions of the creation module 1310 and the determination module 1320 in the above embodiment can refer to the above Figure 3 To avoid repetition, the description of the method for creating a service provided in the embodiment will not be repeated here.

[0213] Fig.14 FIG. 1 is a block diagram of an electronic device 1400 for executing the method of the above embodiment provided by an exemplary embodiment of the present application.

[0214] Reference Fig.14 , the electronic device 1400 includes a processing component 1410, which further includes one or more processors, and a memory resource represented by a memory 1420 for storing instructions executable by the processing component 1410, such as an application. The application stored in the memory 1420 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1410 is configured to execute instructions to perform the routing method of the above embodiment.

[0215] The electronic device 1400 may also include a power supply component configured to perform power management of the electronic device 1400, a wired or wireless network interface configured to connect the electronic device 1400 to a network, and an input / output (I / O) interface. The electronic device 1400 may be operated based on an operating system stored in the memory 1420, such as Windows Server 2003. TM , MacOS X TM , Unix TM , Linux TM , FreeBSD TM or similar.

[0216] A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by the processor of the electronic device 1400, enables the electronic device 1400 to execute the routing method of the above embodiment.

[0217] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, and will not be described one by one here.

[0218] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0219] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0220] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0221] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0222] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0223] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program check codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0224] It should be noted that, in the description of this application, the terms "first", "second", "third", etc. are used for descriptive purposes only and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, the meaning of "plurality" is two or more.

[0225] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A method for routing service call requests, It is characterized in that include: receiving a first service call request, the first service call request carrying environment indication information and a first domain name, for calling the first service based on the first domain name, the environment indication information being used to indicate an environment to which the first service call request belongs; Determining whether the first service call request belongs to the second environment according to the environment indication information, and determining whether the second environment has a second service deployed according to the second domain name, where the second service is a new version of a third service deployed in the first environment, and the second domain name is the domain name of the second service; the third service is a downstream service of the first service; If the first service call request belongs to the second environment and the second environment has a second service deployed, generating a second service call request based on the third service call request; The third service call request is generated by using the bytecode of the main program of the first service; The second service call request is routed to the second service based on the second domain name, wherein the second service call request carries the second domain name and is used to call the second service based on the second domain name.

2. The routing method according to claim 1, It is characterized in that Before routing the second service call request to the second service based on the second domain name, the method further includes: Generate a third service invocation request, where the third service invocation request is used to invoke the third service based on a third domain name, where the third domain name is the domain name of the third service; The environment indication information is added to the third service calling request to obtain the second service calling request.

3. The routing method according to claim 2, It is characterized in that Also includes: Adding the bytecode of the Java agent program to the bytecode of the main program of the first service in a bytecode enhancement manner; The generating of the third service call request includes: Generate the third service call request using the bytecode of the main program; The adding of the environment indication information of the second environment in the third service call request includes: The environment indication information is added to the third service call request using the bytecode of the Java agent program.

4. The routing method according to claim 1, It is characterized in that Before routing the second service call request to the second service based on the second domain name, the method further includes: Generate a third service invocation request, where the third service invocation request is used to invoke the third service based on a third domain name, where the third domain name is the domain name of the third service; The third domain name in the third service calling request is modified to the second domain name to obtain the second service calling request.

5. The routing method according to claim 4, It is characterized in that The routing method further comprises: Adding the bytecode of the Java agent program to the bytecode of the main program of the first service in a bytecode enhancement manner; The generating of the third service call request includes: Generate a third service call request using the bytecode of the main program, where the third service call request is used to call the third service based on a third domain name, where the third domain name is the domain name of the third service; The step of modifying the third domain name in the third service call request to the second domain name includes: The third domain name in the third service call request is modified to the second domain name by using the bytecode of the Java agent program to obtain the second service call request.

6. The routing method according to claim 1, It is characterized in that The determining, according to the second domain name, whether the second environment has a second service deployed therein includes: The second domain name is resolved by using the domain name system of the container management platform, and when the domain name resolution is successful, it is determined that the second environment has the second service deployed.

7. The routing method according to claim 1, It is characterized in that Also includes: When the first service call request belongs to the second environment and the second service is not deployed in the second environment, the third service call request is routed to the third service based on a third domain name, where the third domain name is the domain name of the third service.

8. The routing method according to claim 1, It is characterized in that The environment indication information includes an environment tag, and the environment tag is used to indicate that the first service call request belongs to the second environment. The second domain name is determined by the domain name of the third service and the environment indication information of the second environment.

9. The routing method according to claim 8, It is characterized in that The receiving a first service call request comprises: receiving the first service call request sent by the service gateway or the client of the fourth service based on the first domain name, wherein the first service call request carries the environment tag of the second environment, Wherein, determining whether the first service call request belongs to the second environment according to the environment indication information includes: Parsing the first service call request to obtain the environment tag; Determine, according to the environment tag, that the first service call request belongs to traffic of the second environment.

10. The routing method according to claim 1, It is characterized in that The environment indication information includes attribute information of the first service call request, and the receiving the first service call request includes: Receiving the first service call request sent by a service gateway or a client of a fourth service based on the first domain name; The determining, according to the environment indication information, whether the first service call request belongs to the second environment includes: Parsing the first service call request to obtain the attribute information; When the attribute information meets a preset condition, it is determined that the first service call request belongs to the traffic of the second environment.

11. The routing method according to claim 1, It is characterized in that Also includes: receiving an online message sent by a first provider of the second service, wherein the online message includes identification information of the first provider; Add the identification information to a provider list, wherein the provider list includes identification information of a provider running the second service; receiving a message sent by the first provider indicating that the first provider is about to go offline, wherein the message indicates that the first provider is about to go offline; Deleting the identification information from the provider list according to the going offline message; When the provider list is empty, stop calling the second service, add the environment indication information in the fifth service call request, and route the fifth service call request to the third service based on a third domain name; the third domain name is the domain name of the third service.

12. The routing method according to any one of claims 1 to 11, It is characterized in that The first environment is a formal environment, the second environment is a grayscale environment, an isolated environment or a stress testing environment, the first service call request is generated by an HttpClient tool, and the first service is created by a K8s container management platform.

13. A method for creating a service, It is characterized in that include: Creating the first service and the third service in a first environment according to a first configuration file of the first service and a third configuration file of the third service, wherein the third service is configured downstream of the first service; Determine environment indication information according to a second configuration file, where the second configuration file includes the environment indication information, and the environment indication information is used to indicate that the second service call request belongs to traffic of the second environment; Determine a second domain name based on the environment indication information and the third domain name; The third domain name is the domain name of the third service; The second service is created based on the second domain name, wherein the second service is configured downstream of the first service, and wherein the second service is a new version of the third service deployed in the first environment.

14. An electronic device, It is characterized in that include: processor; a memory for storing instructions executable by the processor, The processor is used to execute the routing method for service call requests described in any one of claims 1 to 12 or the method for creating services described in claim 13.