A method for unified registration, discovery and invocation of multiple types of services

By building a microservice architecture in the internal IT system of the enterprise, and using the service registry and registration center to achieve unified registration and discovery of service instances, the management problems brought about by the heterogeneity of multiple types of services are solved, reducing costs and improving the system Operability.

CN118714191BActive Publication Date: 2024-11-15XIAN SINGULARITY ENERGY TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411189600.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-28
Publication Date
2024-11-15
Estimated Expiration
2044-08-28

AI Technical Summary

Technical Problem

In the internal IT system of the enterprise, there are differences in many different types of systems and microservice architectures, making unified service registration, discovery and invocation difficult, and requires high-cost and high-risk adaptation and integration.

Method used

Build a microservice architecture, including a service registry, a registration center and a service gateway. Through the service registry, service instance information is obtained from different clusters and synchronized to the registration center. The registration center adopts the server registration method to achieve decoupling from the service, and the service gateway Called from the registry synchronize service instance list.

Benefits of technology

It realizes unified service registration, discovery and call without changing the heterogeneous system deployment and service architecture, reduces management operation and maintenance costs, improves the operability and convenience of the system, and supports multiple services under heterogeneous clusters. Type services are managed uniformly.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118714191B_ABST
    Figure CN118714191B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of microservice registration discovery and service call, and in particular to a method for unified registration, discovery and call of multiple types of services, comprising the following steps: building a microservice architecture, including a service registrar, a registration center and a service gateway; the service registrar is used to obtain service instance information from different clusters and synchronize it to the registration center; the registration center is used to provide service information of service management, service registration, service discovery and service instance list, and the registration center adopts a server-side registration method to realize decoupling of the registration center and the service; the service gateway is used to synchronize the service instance list from the registration center and select the service instance to call; the service registrar configures the access cluster API according to the cluster where the service is deployed and correctly synchronizes the service instance information; the present invention enables different services of different systems to achieve unified service registration and discovery as well as service call without the need for deployment and microservice architecture transformation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of microservice registration discovery and service invocation, and in particular to a method for unified registration, discovery and invocation of multiple types of services. Background Art

[0002] In the internal IT systems of enterprises, there are often systems from various sources, such as purchased, self-developed, and open source. Different systems often use different technology stacks and microservice architectures, such as the common Springcloud, Dubbo, or monolithic service architectures; the deployment architectures of different systems are usually different, such as deployment based on fixed hosts, using distributed resource scheduling and management frameworks such as mesos and K8s; in this case, each project or system usually needs to maintain its own registration center and service load balancing, making it very difficult to build a unified cross-system service call, service and API management, service monitoring, link tracking, etc. for the company. Integrating or adapting the scattered heterogeneous system services requires huge costs and faces huge risks.

[0003] Therefore, without changing the deployment and service architecture of various heterogeneous systems, how to implement a unified service registration, discovery and call mechanism to reduce the management and operation costs of services is an urgent problem to be solved. Summary of the invention

[0004] The purpose of the present invention is to overcome the defects of the prior art and provide a method for unified registration, discovery and invocation of multiple types of services.

[0005] The present invention provides a method for unified registration, discovery and invocation of multiple types of services, characterized in that it includes the following steps:

[0006] Step 1: Build a microservice architecture, including a service registrar, a registration center, and a service gateway;

[0007] The service registrar is used to obtain service instance information from different clusters and synchronize it to the registration center; the registration center is used to provide service information for service management, service registration, service discovery, and service instance list. The registration center adopts the server-side registration method to achieve the decoupling of the registration center and the service; the service gateway is used to synchronize the service instance list from the registration center and select the service instance to call;

[0008] Step 2: The service registrar configures the access cluster API and correctly synchronizes the service instance information according to the cluster where the service is deployed;

[0009] Step 3: When a service instance changes, the cluster service instance information is compared with the full service instance information obtained from the registration center, and the service instance information is updated according to the comparison result and synchronized to the service registrar;

[0010] Step 4: The service registrar obtains the updated service instance information and registers it with the registration center, so that the registration center obtains the latest service instance information;

[0011] Step 5: The service gateway obtains the latest service instance information from the registration center, matches the most appropriate service instance information according to the service request, initiates a service call, and forwards it to the service requester.

[0012] Further, in step 4, the mode in which the service registrar obtains service instance information includes:

[0013] 1) Event monitoring mode: If the cluster supports service event monitoring, the service registrar will implement a listener and register it with the cluster to capture service status change events. When an event is captured, the registrar will obtain the latest status information of the relevant service instance;

[0014] 2) Polling mode: If the cluster does not support event monitoring, the service registrar will use polling mode to periodically call the cluster API to obtain the list and status information of service instances.

[0015] Furthermore, in step 4, after the service instance information is registered in the registration center, the following steps are also included:

[0016] Step 4-1, synchronization of service registrar and registration center: the service registrar compares the obtained service instance information with the information in the registration center, identifies and processes service instances in different states. When a service instance exists in the cluster but not in the registration center, it is added to the registration center and identified as a newly added instance; when a service instance does not exist in the cluster but exists in the registration center, it is deleted from the registration center and identified as a stopped instance; when a service instance exists in both the cluster and the registration center, no processing is performed and it is identified as an existing instance;

[0017] Step 4-2, traverse and synchronize all service instances: The service registrar loops through all service instances and repeats step S4-1 until all service instances are processed.

[0018] Further, in step 5, the service gateway obtains the latest service instance information from the registration center, matches the most appropriate service instance information according to the service request, initiates a service call, and forwards it to the service requester, specifically including:

[0019] Step 5-1, the service gateway refreshes the service instance cache: the service gateway periodically polls the registration center to obtain the latest service instance information and refreshes the local cache;

[0020] Step 5-2, service call: Service request A initiates an access request to service instance B to the service gateway. After receiving the request, the service gateway queries the local service instance cache, matches the most suitable service instance B, initiates a service call, and forwards it to service request A.

[0021] Furthermore, the service call in step 5 specifically includes:

[0022] 1) Query service instance: The service gateway queries the latest service instance information based on the service name and version number information in service request A;

[0023] 2) Load balancing: Select the appropriate service instance B from the service instance list according to the load balancing policy corresponding to the service. If there is no available instance, it returns failure.

[0024] 3) Signature verification: The service gateway verifies the signature of the request. The signature verification algorithm uses the request path combined with the timestamp and key MD5 signature authentication. If the verification fails, it returns failure.

[0025] 4) Permission verification: Verify the API call permission. If the verification fails, it will return failure;

[0026] 5) Logging: The service gateway records relevant information about the service call, including the call time, caller, callee, and request parameters;

[0027] 6) Forward request: The service gateway forwards service request A to service instance B, waits for the return result, and returns the result information to service request A.

[0028] Furthermore, the load balancing strategies include random, round-robin and consistent hashing.

[0029] Furthermore, the registration center adopts a distributed master-slave architecture with a coordinator and multiple workers. The coordinator is used for service registration, discovery and service interface management. After accepting the service registration, the coordinator writes the service instance information into the service instance database. The service instance database is used to store all service instance information of the registration center and service instance information collection. The service instance database is a closure tree table structure, which is used to convert service instance retrieval into a dynamic binary tree search algorithm.

[0030] The worker node is used to communicate with the service gateway. The worker node obtains the full service instance information and refreshes the local cache of the registration center through regular communication with the coordinator node.

[0031] Compared with the prior art, the present invention has the following beneficial effects:

[0032] The present invention builds a microservice architecture, which includes a service registrar, a registration center, and a service gateway; the service registrar is used to obtain service instance information from different clusters and synchronize it to the registration center; the registration center is used to provide service information of service management, service registration, service discovery, and service instance list, and the registration center adopts a server-side registration method to achieve decoupling of the registration center and the service; the service gateway is used to synchronize the service instance list from the registration center and select the service instance to call; there is no mandatory requirement for the technology stack and deployment method used by the service itself, and the registration center adopts a server-side registration method, and the cluster where the service registrar is located obtains the updated service instance information through event monitoring or polling, and registers it to the registration center, and supports other types of clusters by extending the service registrar to achieve unified service registration and discovery under heterogeneous clusters, and incorporates various types and services of different deployment methods into a unified microservice communication and management system. In this way, the decoupling of the service and the registration center is achieved, and the service itself does not need to be modified, which greatly improves the operability and convenience of unified management of systems and services in a complex IT architecture environment of the enterprise, and reduces the access cost;

[0033] This application is applicable to the unified registration, discovery, and invocation of multiple types of services in heterogeneous cluster deployment scenarios, so that different services of different systems do not need to be deployed and transformed into microservice architecture, and unified service registration, discovery, and service invocation can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] The following drawings are only used to illustrate and explain the present invention, and are not used to limit the scope of the present invention, wherein:

[0035] Figure 1 : Schematic diagram of the service access registration center structure of different clusters of the present invention;

[0036] Figure 2 : Schematic diagram of the multi-type service registration and discovery process of the present invention;

[0037] Figure 3 : Schematic diagram of the multi-type service calling process of the present invention;

[0038] Figure 4 : Schematic diagram of the unified registration, discovery and call structure of multiple types of services in the heterogeneous cluster deployment scenario of the present invention. DETAILED DESCRIPTION

[0039] In order to make the purpose, technical solution, design method and advantages of the present invention clearer, the present invention is further described in detail by specific embodiments in conjunction with the accompanying drawings. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0040] like Figure 1-Figure 4 As shown, the present invention provides a method for unified registration, discovery and invocation of multiple types of services, including the following steps:

[0041] Step 1: Build a microservice architecture, including a service registrar, a registration center, and a service gateway;

[0042] The service registrar is used to obtain service instance information from different clusters and synchronize it to the registration center; the registration center is used to provide service information for service management, service registration, service discovery and service instance list. The registration center adopts a server-side registration method, and the cluster where the service registrar is located obtains the updated service instance information through event monitoring or polling, and registers it to the registration center. By extending the service registrar to support other types of clusters, unified service registration and discovery under heterogeneous clusters are realized, and services of various types and different deployment methods are included in a unified microservice communication and management system. In this way, the decoupling of the registration center and the service is realized; the service gateway is used to synchronize the service instance list from the registration center and select the service instance to call;

[0043] The registration center adopts a distributed master-slave architecture with a coordinator and multiple workers. The coordinator is used for service registration, service discovery and service interface management. After accepting the service registration, the coordinator writes the service instance information into the service instance database. The service instance database is used to store all service instance information of the registration center and service instance information collection. The service instance database is a closure tree table structure, which is used to convert service instance retrieval into a dynamic binary tree search algorithm.

[0044] The worker node is used to communicate with the service gateway. It is used to obtain full service instance information and refresh the local cache of the registration center through regular communication between the worker node and the coordinator node.

[0045] The microservice architecture of this application is as attached Figure 1 , Figure 1 The microservice architecture includes the following:

[0046] 1) Registration center: The registration center provides service management, service registration, and service discovery functions. This registration center is different from traditional registration centers such as eureka (service registration and discovery) / nacos (Dynamic Naming and Configuration Service, registration configuration center). Traditional registration centers mostly use client registration, that is, the service itself needs to establish a connection with the registration center and maintain a heartbeat to achieve service discovery and registration; the registration center of this application adopts a server-side registration method, that is, the registration center does not interact directly with the service, and the cluster where the service is located, including the host agent, K8s (Kubernetes, Google's open source container cluster management system), mesos (a framework for implementing this type of distributed computing), Alibaba Cloud ACR (Alibaba Cloud Container Registry, Alibaba Cloud Container Mirror Service), etc., obtains the latest status and address of the service instance through event monitoring or polling, and updates it to the registration center. In this way, the registration center and the service are decoupled, and any type of service can be connected to the registration center without feeling.

[0047] 2) Service Registry: To support Figure 1 The services of various clusters in the registration center are connected. This application provides different service registrars for different clusters. The service registrar is mainly responsible for monitoring or polling service changes from different clusters and synchronizing them to the registration center.

[0048] 3) Service Gateway: Traditional microservice calls are usually client-side load balancing. The client itself stores a list of service instances, which is obtained by synchronization from the registration center, and the load balancing call is implemented through the client's built-in load balancing algorithm. This application adopts the server-side load balancing method. The service caller and the callee do not communicate directly. The service call and the callee are uniformly implemented through the service gateway routing. The service gateway and the registration center synchronize the service instance list regularly. In this way, on the one hand, the decoupling of the registration center and the service is achieved, and the service call only needs to interact with the service gateway; on the other hand, through the service gateway, it is easy to implement service management, service call record tracking, API (Application Programming Interface) management, and permission control functions;

[0049] It should be noted that this application builds a microservice architecture, which includes a registration center, a service registrar and a service gateway. The registration center adopts a server-side registration method, that is, the registration center does not interact directly with the service. The cluster where the service is located obtains the latest status and address of the service instance through event monitoring or polling, and updates it to the registration center. In this way, the decoupling of the registration center and the service is achieved, and any type of service can be connected to the registration center without feeling; the service registrar is mainly responsible for monitoring or polling service changes from different clusters and synchronizing them to the registration center; the server-side load balancing method is adopted, and the service caller and the callee do not communicate directly. The service call and the callee are uniformly implemented through the service gateway. The service gateway and the registration center periodically synchronize the service instance list, where the service instance list is used to record the service configuration; in this way, on the one hand, the decoupling of the registration center and the service is achieved, and the service call only needs to interact with the service gateway; on the other hand, through the service gateway, it is convenient to implement service management, service call record tracking, API management, and permission control functions; by extending the service registrar to support other types of clusters, unified registration, discovery, and calling of multiple types of services in heterogeneous clusters are achieved, and security and management functions such as signature verification, permission verification, and logging are provided;

[0050] Step 2: The service registrar configures the access cluster API and correctly synchronizes the service instance information according to the cluster where the service is deployed;

[0051] Step 3: When a service instance changes, the cluster service instance information is compared with the full service instance information obtained from the registration center, and the service instance information is updated according to the comparison result and synchronized to the service registrar;

[0052] Step 4: The service registrar obtains the updated service instance information and registers it with the registration center, so that the registration center obtains the latest service instance information;

[0053] Among them, the modes in which the service registrar obtains service instance information include:

[0054] 1) Event monitoring mode: If the cluster supports service event monitoring, the service registrar will implement a listener and register it with the cluster to capture service status change events. When an event is captured, the registrar will obtain the latest status information of the relevant service instance;

[0055] 2) Polling mode: If the cluster does not support event monitoring, the service registrar will use the polling mode to periodically call the cluster API to obtain the list and status information of service instances;

[0056] In step 4, after registering the updated service instance information to the registration center, it also includes:

[0057] Step 4-1, synchronization of service registrar and registration center: the service registrar compares the obtained service instance information with the information in the registration center, identifies and processes service instances in different states. When a service instance exists in the cluster but not in the registration center, it is added to the registration center and identified as a newly added instance; when a service instance does not exist in the cluster but exists in the registration center, it is deleted from the registration center and identified as a stopped instance; when a service instance exists in both the cluster and the registration center, no processing is performed and it is identified as an existing instance;

[0058] Step 4-2, traverse and synchronize all service instances: The service registrar loops through all service instances and repeats step S4-1 until all service instances are processed;

[0059] like Figure 2 As shown in the figure, a complete multi-type service registration and discovery process is as follows:

[0060] S1, based on the cluster where the service is deployed and started, when new services are released, existing services are restarted, services are scaled up or down, or services drift due to their own failures, the instance information on the deployment cluster where the service is located changes. Here, there are mature process solutions and APIs based on different cluster types, such as mesos clusters;

[0061] S2: When all service instance information changes are completed, that is, the old instance is stopped and the new service is started, the service registrar obtains the updated service instance information and registers it to the registration center; specifically:

[0062] When a cluster such as a mesos cluster supports service event monitoring mode, the service registrar implements the listener and registers to monitor cluster service status change events;

[0063] When the cluster, such as Alibaba Cloud ack (Acknowledge character, indicating that the received character is error-free), does not support service event monitoring, the cluster API is called periodically in polling mode to obtain all instance information of the service.

[0064] S3, the service registrar synchronizes with the registration center, obtains the full amount of service instance information from the registration center, traverses the services, and compares them with the cluster service instances obtained in S2. When the service name, API version, IP, port and other information are consistent, they are considered to be the same instance. The following are identified: First, the instance exists in the cluster but not in the registration center. This is a new instance, so add this instance to the registration center; Second, the instance does not exist in the cluster but exists in the registration center. This instance has been stopped and is deleted from the registration center; Third, the instance exists in both the cluster and the registration center, so it is skipped directly;

[0065] S4, loop S3 until all services are traversed.

[0066] Step 5: The service gateway obtains the latest service instance information from the registration center, matches the most appropriate service instance information according to the service request, initiates a service call, and forwards it to the service requester.

[0067] Among them, the service caller initiates the service call through the service gateway, such as Figure 3 As shown in the figure, a complete multi-type service call process is as follows:

[0068] Step 5-1, the service gateway refreshes the service instance cache: the service gateway periodically polls the registration center to obtain the latest service instance information and refreshes the local cache;

[0069] Step 5-2, service call: Service request A initiates an access request to service instance B to the service gateway. After receiving the request, the service gateway queries the local service instance cache, matches the most suitable service instance B, initiates a service call, and forwards it to service request A;

[0070] In step 5-2, the service call specifically includes:

[0071] 1) Query service instance: The service gateway queries the latest service instance information based on the service name and version number information in service request A;

[0072] 2) Load balancing: Select the appropriate service instance B from the service instance list according to the load balancing policy corresponding to the service. If there is no available instance, it returns failure.

[0073] The load balancing strategies include random, round-robin, and consistent hashing;

[0074] 3) Signature verification: The service gateway verifies the signature of the request. The signature verification algorithm uses the request path combined with the timestamp and the key MD5 (Message Digest Algorithm MD5, Message Digest Algorithm Version 5) signature authentication. If the verification fails, a failure is returned.

[0075] 4) Permission verification: Verify the API call permission. If the verification fails, it returns failure;

[0076] 5) Logging: The service gateway records relevant information about the service call, including the call time, caller, callee, and request parameters;

[0077] 6) Forwarding request: The service gateway forwards service request A to service instance B, waits for the result to be returned, and returns the result information to service request A;

[0078] In the application, the registration center uniformly defines the service structure as follows:

[0079] kind: registration type, service type or other type;

[0080] specVersion: service specification version number;

[0081] name: service name;

[0082] apiVersion: API version;

[0083] group: service group information;

[0084] environment: environment, such as dev, test, prod, etc.

[0085] cluster: the cluster ID, such as marathon, mesos, etc.

[0086] sandBox: sandbox information;

[0087] containerType: container type, such as docker, node, etc.

[0088] metadata: service metadata, such as memory, cpu, environment variables, mount points, etc.

[0089] loadbalance: load balancing strategy, such as random, weight-based, load-based, etc.

[0090] List <instance>: Instance list, including access protocol type such as Http, container IP, port, load weight and other information.

[0091] like Figure 4 As shown in the figure, the implementation of the registration center needs to support high performance and high availability, and the implementation structure adopts a distributed master-slave architecture with one admin (coordinator) and multiple workers.

[0092] Among them, the coordinator is used for service registration, service interface management, etc. The coordinator itself can also achieve high availability through load balancing. And because the coordinator node only communicates with the management page and the service registrar, the number of concurrency is not high, so there is no need for special performance optimization. After receiving the service registration, the coordinator writes the service instance information into the service instance database; among them, the service instance list is used to record the service configuration array; the service instance database is used to store the service instance information and the collection of the service instance list.

[0093] The service instance database is used to store all services and instance information of the registration center. In order to achieve high-performance reading and writing of service instances, the service instance database is implemented using a closure tree table structure. For each service instance, a key (path) is generated. The path key structure is: registration type / service specification version number / service name / API version / service group / environment identifier / cluster identifier / instance ID. The service instance list is designed with a tree table structure. Each level of directory in the path is an independent node, and the leaf node is the service instance. The service instance database uses a closure tree table structure to convert service instance retrieval into a dynamic binary tree search algorithm. In order to further improve the search efficiency, a Closure Table is constructed to store the node relationship and hierarchical information of the service instance tree nodes. This can reduce the service instance retrieval time complexity to the O(n) level.

[0094] A service instance tree and closure table data structure is as follows:

[0095] Node / / Service instance node

[0096] {

[0097] String parentKey; / / parent node path Key

[0098] String absoluteKey; / / This node path key

[0099] ... / / Other information of the instance

[0100] List <node>nodes; / / child node list

[0101] }

[0102] NodePath / / Service instance tree closure table

[0103] {

[0104] String ancestor; / / ancestor information

[0105] String descendant; / / descendant information

[0106] Integer depth; / / Tree depth level

[0107] };

[0108] The worker nodes of the registration center are mainly used for communication with the service gateway. The worker nodes obtain the full service instance information and refresh the local cache through regular communication with the coordinator node. The worker nodes use memory as a service instance cache to improve read and write efficiency. Multiple worker nodes achieve high availability through external load balancing such as nginx (lightweight / high-performance reverse proxy Web server) and SLB (Server Load Balance, network load balancing server).

[0109] Among them, heterogeneous cluster deployment scenarios include but are not limited to: containerized or non-containerized deployment based on fixed hosts, localized deployment based on K8s (Kubernetes, Google's open source container cluster management system) or k3s cluster (a lightweight version of K8s), localized deployment based on mesos+marathon (implementing service discovery and load balancing and other functions) clusters, deployment based on cloud native capabilities such as Alibaba Cloud ack / Taobao Jushita, etc.; multi-type services include but are not limited to JAVA microservices based on Springcloud (a full-family bucket technology stack), JAVA microservices based on Dubbo (a remote call distributed service framework), JAVA services using SSH (secure shell, secure shell protocol) or SSM (framework integration of Spring, SpringMVC, and Mybatis) frameworks, web (communication network) services built using Node.js (Javascript code running environment), web services built based on Python (a high-level programming language), etc.

[0110] It is worth noting that, compared with various existing open source and commercial registration centers and microservice framework solutions, the registration center and service gateway component introduced in the present invention has no mandatory requirements on the technology stack and deployment method used by the service itself, and adopts the server-side registration and service gateway load method to achieve the decoupling of the service and the microservice framework. The service itself does not perceive the microservice suite, which provides the service with extremely strong scalability and compatibility; the microservice suite itself can be horizontally expanded through high-performance components and high-availability design, and a high concurrent processing capability can be achieved in a simple way;

[0111] Through this solution, services of various types and deployment methods, such as JAVA services, Node (operating environment) services, etc., can be incorporated into a unified microservice communication and management system, and the services themselves do not need to be modified. This greatly improves the operability and convenience of unified management of systems and services in the complex IT architecture environment of the enterprise, and reduces access costs. This solution is highly innovative and practical in actual business system integration.

[0112] Embodiment 1: The registration center is implemented using JAVA (programming language) technology and Mysql (open source relational database management system) database structure, the service instance database is implemented using a closure tree table structure, and the implementation algorithm is a dynamic binary tree search algorithm.

[0113] Service registrar, this embodiment describes the technical method for implementing the K8s (Kubernetes, Google's open source container cluster management system) cluster, and the implementation methods of other clusters are similar. The K8s service registrar communicates with the K8s cluster by introducing the client-javaSDK package. The introduction method is:

[0114] <dependency>

[0115] <groupid> io.kubernetes< / groupid>

[0116] <artifactid> client-java< / artifactid>

[0117] < / dependency> ;

[0118] The K8s cluster service uses the nodeport (port range) method to access the K8s cluster Service from outside the cluster without going through load balancing or Ingress (entrance). The registrar starts two scheduled tasks A and B. Scheduled task A regularly calls the registration center API to obtain the full service instance list and caches it in local memory; scheduled task B calls the K8s cluster API to obtain all K8s cluster services. For each service, the service discovery list is obtained through the API, and the local memory cache is queried to obtain the service instance list, which is compared with step S3, and the stopped instances are removed from the registration center and new instances are added.

[0119] Service gateway, in this embodiment, OpenResty (network platform) script is used to implement a high-performance and highly available API gateway. Specifically, OpenResty is a high-performance Web platform based on Nginx (lightweight HTTP server) and Lua, which integrates a large number of sophisticated Lua (scripting language) libraries, third-party modules and most dependencies. It is used to easily build dynamic Web applications, Web services and dynamic gateways that can handle ultra-high concurrency and high scalability. In this embodiment, multiple Lua scripts can be written to realize the processing and forwarding of requests, such as request authentication, load balancing, etc. This method is all prior art.

[0120] In the specific implementation, the implementation of the method of unified registration, discovery and invocation of multiple types of services in the heterogeneous cluster deployment scenario is as follows from the steps of microservice architecture construction, service registration and discovery, and service invocation:

[0121] 1) Select appropriate technical methods to implement microservice architecture: registration center, service registrar and service gateway;

[0122] Registration center: It is implemented using Java (programming language) technology and Mysql (open source relational database management system) database, and adopts a closed tree table structure to store service instance information. The registration center is used to provide service management, service registration, service discovery, and service instance list service information. The registration center adopts a server-side registration method to achieve decoupling of the registration center and the service;

[0123] Service Registry: For K8s cluster, use the client-java SDK (Software Development Kit) package to communicate with the K8s cluster. The service registrar needs to implement two scheduled tasks to obtain service instance status information from the K8s cluster at regular intervals and synchronize it to the registration center.

[0124] Service Gateway: Use OpenResty (network platform) script to implement high-performance API gateway, which is used to handle request authentication, load balancing and other functions, synchronize the service instance list from the registration center, and select the service instance to call;

[0125] 2) Configure the access service registrar according to the cluster where the service is deployed.

[0126] Configure the K8s service registrar according to the K8s cluster where the service is deployed, and ensure that the service registrar can access the K8s cluster API and correctly synchronize service instance information;

[0127] 3) Automatically or manually publish the service to the deployment cluster. When the service is started, the old instance is stopped and the new instance is started.

[0128] Automatically or manually publish the service to the K8s cluster. After the service is published, the old instance is stopped and the new instance is started;

[0129] 4) The service registrar obtains the updated service instance information and registers it with the registration center, so that the registration center obtains the latest service instance information;

[0130] Specifically, scheduled task A of the K8s cluster service registrar obtains the full service instance list from the registration center and caches it in local memory.

[0131] Scheduled task B calls the K8s cluster API (Kubernetes Application Programming Interface) to obtain all Service and Endpoints information.

[0132] Scheduled task B compares the service instance information in the local cache and the K8s cluster, and updates the service instance list in the registration center based on the comparison results;

[0133] 5) The service gateway obtains the latest service instance information from the registration center, matches the most appropriate service instance information according to the service request, initiates the service call, and forwards it to the service requester;

[0134] The service gateway refreshes the service instance cache: The service gateway periodically polls the registration center to obtain the latest service instance information and refreshes the local cache;

[0135] Service call: Service request A initiates an access request to service instance B to the service gateway. After receiving the request, the service gateway queries the local service instance cache, matches the most suitable service instance B, initiates a service call, and forwards it to service request A.

[0136] It should be noted that the service registrar synchronizes the service instance status information with the registration center, ensuring the accuracy of service discovery; the service gateway, as a unified entry point for services, implements routing and load balancing of service calls, improving the scalability and maintainability of the system; the registration center uses a closure tree table structure to store service instance information, supporting complex service management and query requirements. Service instance synchronization: The synchronization of service instances is achieved through the scheduled tasks of the service registrar, ensuring that the information in the registration center is consistent with the actual status of the service. Multi-cluster support: Although this embodiment is only described for K8s clusters, the service registrar can be extended to support other types of clusters to achieve unified service registration and discovery under heterogeneous clusters.

[0137] It is worth noting that this application is applicable to the unified registration, discovery and invocation of multiple types of services in heterogeneous cluster deployment scenarios, so that different services of different systems do not need to be deployed and transformed into microservice architecture, and unified service registration and discovery as well as service invocation can be achieved;

[0138] By building a microservice architecture, the microservice architecture includes a service registrar, a registration center, and a service gateway; the service registrar is used to obtain service instance information from different clusters and synchronize it to the registration center; the registration center is used to provide service information for service management, service registration, service discovery, and service instance list, and the registration center adopts a server-side registration method to achieve decoupling of the registration center and the service; the service gateway synchronizes the service instance list from the registration center and selects the service instance to call; there is no mandatory requirement for the technology stack and deployment method used by the service itself, and the registration center adopts a server-side registration method, and the cluster where the service is located obtains the updated service instance information through event monitoring or polling, and registers it to the registration center. In this way, the decoupling of the service and the registration center is achieved, and services of various types and different deployment methods, such as JAVA services, Node.js services, etc. can be included in a unified registration center, and the registration center is used to provide service information for service management, service registration, service discovery, and service instance list, and the registration center adopts a server-side registration method to achieve decoupling of the registration center and the service; and the service itself does not need to be modified, which greatly improves the operability and convenience of unified management of systems and services in the complex IT architecture environment of the enterprise, and reduces the access cost.

[0139] The embodiments of the present invention have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.< / node> < / instance>

Claims

1. A method for unified registration, discovery and invocation of multiple types of services, characterized in that: The steps include: Step 1: Build a microservice architecture, including a service registrar, a registration center, and a service gateway; The service registrar is used to obtain service instance information from different clusters and synchronize it to the registration center; the registration center is used to provide service management, service registration, service discovery and service instance list service information. The registration center adopts the server-side registration method to achieve decoupling of the registration center and the service; The service gateway is used to synchronize the service instance list from the registration center and select the service instance to call; Step 2: The service registrar configures the access cluster API and correctly synchronizes the service instance information according to the cluster where the service is deployed; Step 3: When a service instance changes, the cluster service instance information is compared with the full service instance information obtained from the registration center, and the service instance information is updated according to the comparison result and synchronized to the service registrar; Step 4: The service registrar obtains the updated service instance information and registers it with the registration center, so that the registration center obtains the latest service instance information; The modes for the service registry to obtain service instance information include: 1) Event monitoring mode: If the cluster supports service event monitoring, the service registrar will implement a listener and register it with the cluster to capture service status change events. When an event is captured, the registrar will obtain the latest status information of the relevant service instance; 2) Polling mode: If the cluster does not support event monitoring, the service registrar will use the polling mode to periodically call the cluster API to obtain the list and status information of service instances; After registering the updated service instance information to the registration center, it also includes: Step 4-1, synchronization of service registrar and registration center: the service registrar compares the obtained service instance information with the information in the registration center, identifies and processes service instances in different states. When a service instance exists in the cluster but not in the registration center, it is added to the registration center and identified as a newly added instance; when a service instance does not exist in the cluster but exists in the registration center, it is deleted from the registration center and identified as a stopped instance; when a service instance exists in both the cluster and the registration center, no processing is performed and it is identified as an existing instance; Step 4-2, traverse and synchronize all service instances: The service registrar loops through all service instances and repeats step S4-1 until all service instances are processed; Step 5: The service gateway obtains the latest service instance information from the registration center, matches the most appropriate service instance information according to the service request, initiates a service call, and forwards it to the service requester, including: Step 5-1, the service gateway refreshes the service instance cache: the service gateway periodically polls the registration center to obtain the latest service instance information and refreshes the local cache; Step 5-2, service call: Service request A initiates an access request to service instance B to the service gateway. After receiving the request, the service gateway queries the local service instance cache, matches the most suitable service instance B, initiates a service call, and forwards it to service request A.

2. The method for unified registration, discovery and invocation of multiple types of services according to claim 1, characterized in that: The service call in step 5 specifically includes: 1) Query service instance: The service gateway queries the latest service instance information based on the service name and version number information in service request A; 2) Load balancing: Select the appropriate service instance B from the service instance list according to the load balancing policy corresponding to the service. If there is no available instance, it returns failure. 3) Signature verification: The service gateway verifies the signature of the request. The signature verification algorithm uses the request path combined with the timestamp and the MD5 signature authentication of the key. If the verification fails, a failure is returned. 4) Permission verification: Verify the API call permission. If the verification fails, it returns failure; 5) Logging: The service gateway records relevant information about the service call, including the call time, caller, callee, and request parameters; 6) Forward request: The service gateway forwards service request A to service instance B, waits for the return result, and returns the result information to service request A.

3. The method for unified registration, discovery and invocation of multiple types of services according to claim 2, characterized in that: The load balancing strategies include random, round-robin, and consistent hashing.

4. The method for unified registration, discovery and invocation of multiple types of services according to claim 1, characterized in that: The registration center adopts a distributed master-slave architecture with a coordinator and multiple workers. The coordinator is used for service registration, service discovery and service interface management. After accepting the service registration, the coordinator writes the service instance information into the service instance database. The service instance database is used to store all service instance information of the registration center and service instance information collection. The service instance database is a closure tree table structure, which is used to convert service instance retrieval into a dynamic binary tree search algorithm; The worker node is used to communicate with the service gateway. The worker node obtains the full service instance information and refreshes the local cache of the registration center by regularly communicating with the coordinator node.