Microservice cluster registration method, service request processing method and microservice cluster
By dividing the namespace according to regional information and registering microservice nodes in Consul Cluster, the problem of resource waste and complexity caused by regional deployment is solved, and resource utilization is improved and operation and maintenance is simplified.
Patent Information
- Application Number
- CN202210526096.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-16
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2042-05-16
AI Technical Summary
In the existing technology, the regional deployment of Consul Cluster results in a waste of resources, high system complexity and operation and maintenance complexity, and lacks a deployment method for logical isolation and high resource utilization.
By dividing the namespace of the registration center according to the regional information, the microservice nodes are registered in the corresponding spaces, and the registration information of the registration center is pulled in the gateway based on the regional information, and the service request is forwarded to the corresponding microservice node.
It realizes the unified deployment of Consul Cluster in multiple regions, improves resource utilization and reduces system and operation and maintenance complexity.
Smart Images

Figure CN115134413B
Abstract
Description
Technical Field
[0001] The present application relates to the field of microservice technology, and in particular to a registration method for a microservice cluster, a service request processing method, and a microservice cluster. Background Art
[0002] In the prior art, when using Consul Cluster as the microservice registration center, in order to cater to the situation where the same service is deployed in different regions, it is necessary to deploy an independent set of Consul Cluster and Zuul for each region.
[0003] Since Consul Cluster has no database and simple processing logic, it does not have the problem of excessive pressure due to too many accesses. Therefore, in the existing deployment method, deploying a set of Consul Cluster in each region is a waste of resources. In addition, the existing deployment method has high system complexity and high operation and maintenance complexity.
[0004] The existing technology lacks a deployment method that can logically isolate different regions, has high resource utilization, and has low system and operation and maintenance complexity. Summary of the invention
[0005] To solve the above problems, the embodiments of the present application provide a registration method for a microservice cluster, a service request processing method and a microservice cluster, which aim to overcome or partially overcome the above technical problems.
[0006] The present application embodiment adopts the following technical solutions:
[0007] In a first aspect, a registration method for a microservice cluster is provided, the registration method being applicable to a registration center, the registration center being communicatively connected to a microservice node, the registration method comprising:
[0008] Divide the registration center into multiple corresponding spaces according to different regional information;
[0009] receiving a registration request from a microservice node, wherein the registration request includes region information;
[0010] According to the regional information, the microservice node is registered in the corresponding space, and the registration information of the microservice node is saved in the corresponding space, wherein the registration information includes service information.
[0011] In a second aspect, a service request processing method is provided, which is applicable to a gateway, which is respectively connected to a registration center and a microservice node for communication, and the registration center implements the registration method of the microservice cluster, and the processing method includes:
[0012] Receive the service request, parse the service request, and obtain the region information and target service information of the service request;
[0013] According to the regional information, pull the registration information of the microservice node stored in the space corresponding to the registration center;
[0014] Determine whether the target service information in the service request matches the service information in the registration information;
[0015] If so, the service request is forwarded to the corresponding microservice node, so that the service information of the microservice node responds to the service request.
[0016] In a third aspect, a microservice cluster is provided, which includes: a registration center, a gateway, and a microservice node; wherein the registration center is communicatively connected to the microservice node, the gateway is communicatively connected to the registration center and the microservice node respectively, the registration center implements the registration method of the above-mentioned microservice cluster, and the gateway implements the above-mentioned service request processing method.
[0017] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores a microservice registration program, and when the microservice registration program is executed by at least one processor, the registration method of the above-mentioned microservice cluster is implemented.
[0018] In a fifth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores a service request processing program, and the microservice registration program implements the above-mentioned service request processing method when executed by at least one processor.
[0019] In a sixth aspect, an embodiment of the present application further provides a microservice system, the microservice system comprising: a registration center, a gateway, and a microservice node; wherein the registration center is communicatively connected to the microservice node, and the gateway is communicatively connected to the registration center and the microservice node respectively;
[0020] The registration center includes: a first memory and a first processor, the first memory stores a microservice registration program, and when the microservice registration program is executed by the first processor, the registration method of the microservice cluster is implemented;
[0021] The gateway comprises: a second memory and a second processor. The second memory stores a service request processing program. When the service request processing program is executed by the second processor, the above service request processing method is implemented.
[0022] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects:
[0023] This application logically isolates the registration center according to the regional information, and can uniformly deploy a set of Consul Clusters in multiple regions, which improves the resource utilization of the machine and reduces the system complexity and operation and maintenance complexity. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0025] Figure 1 A schematic diagram showing the structure of microservice cluster deployment in the prior art;
[0026] Figure 2 A schematic diagram showing a process of a registration method for a microservice cluster according to an embodiment of the present application is shown;
[0027] Figure 3 A schematic diagram showing an architecture of a registration method for a microservice cluster according to an embodiment of the present application;
[0028] Figure 4 A schematic diagram showing a flow chart of a service request processing method according to an embodiment of the present application;
[0029] Figure 5 A schematic diagram showing an architecture of a method for processing a service request according to an embodiment of the present application;
[0030] Figure 6 A schematic diagram showing the structure of a microservice cluster according to an embodiment of the present application is shown;
[0031] Figure 7 A schematic diagram showing a flow chart of a working method of a microservice cluster according to an embodiment of the present application;
[0032] Figure 8 A schematic diagram of the structure of a microservice system according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0034] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0035] First, the technical features involved in this application are explained.
[0036] Microservices, as a software development technology, is a variation of the service-oriented architecture (SOA) architectural style. Microservices divide a single application into a group of small services that coordinate and cooperate with each other to provide ultimate value to users. Each service runs in its own independent process, and services communicate with each other using lightweight communication mechanisms (such as RESTful API based on HTTP). Each service is built around a specific business and can be independently deployed to a production environment, a production-like environment, etc.
[0037] Consul Cluster is an open source product launched by HashiCorp, which is used to implement service discovery, service isolation, and service configuration of distributed systems. Each of the above functions can be used separately or simultaneously as needed. Consul Cluster is mainly used in service grids. Compared with other distributed service registration and discovery solutions, Consul Cluster's solution is more "one-stop". It has built-in service registration and discovery architecture, distributed consistency protocol implementation, health check, Key / Value storage, and multi-data center solutions, and no longer needs to rely on other tools. Consul Cluster itself is developed in the go language, with the characteristics of cross-platform and efficient operation, which is convenient for use with Docker.
[0038] Zuul is the microservice API gateway in the Spring Cloud family. All requests from devices or websites will pass through Zuul to the backend Netflix application. As a border application, Zuul provides dynamic routing, monitoring, elastic load and security features. Zuul uses various filters at the bottom layer to implement the following functions: (i) authentication and security, identifying each resource that needs to be authenticated and rejecting requests that do not meet the requirements; (ii) performance monitoring, tracking and counting statistics at the service boundary, providing an accurate production view; (iii) dynamic routing, dynamically routing requests to the backend cluster as needed; (iv) stress testing, gradually increasing the traffic to the cluster to understand its performance; (v) load unloading, pre-allocating capacity for each type of request, and automatically discarding requests when they exceed the capacity; (vi) static resource processing, returning certain responses directly at the boundary.
[0039] Next, the prior art is described.
[0040] Figure 1 The schematic diagram of the structure of the microservice cluster deployment in the prior art is shown. Figure 1As shown, when the prior art uses Consul Cluster to deploy microservice clusters, each region needs to deploy a separate registration center (Consul Cluster). In this regional deployment method, resources are extremely wasted. Since multiple sets of Consul Clusters need to be run and maintained at the same time, service information in different clusters is also physically isolated, so the system is highly complex and difficult to operate and maintain. In the prior art, when a service request arrives, the service request will be directly routed to the corresponding region, and then routed to the target service instance of the service instance corresponding to the region, so as to process and feedback the service request.
[0041] In view of the drawbacks of the above-mentioned existing technologies, the idea of this application is: for the same service, only one set of Consul Cluster is deployed for multiple regions, and instances in different regions are isolated through namespace logic, thereby improving the resource utilization of the machine and reducing the system complexity and operation and maintenance complexity.
[0042] Figure 2 A flow chart of a registration method for a microservice cluster according to an embodiment of the present application is shown. The method is applicable to a registration center that is communicatively connected to a microservice node.
[0043] from Figure 2 It can be seen that this embodiment at least includes steps S210 to S230:
[0044] Step S210: Divide the registration center into a plurality of corresponding spaces according to different regional information.
[0045] According to different regional information, the registration center (Consul cluster) is divided into multiple spaces, each space corresponds to a region. Different regional information can be but is not limited to different regional information divided according to provinces. Each space can be named according to its corresponding region, and a unique identification number can also be assigned according to its corresponding region. This application is not limited to the above division method, as long as the correspondence between the multiple spaces divided by the registration center and the different regional information is guaranteed.
[0046] Step S220: receiving a registration request from a microservice node, wherein the registration request includes region information.
[0047] After the microservice node is started, it establishes a communication connection with the registration center. The microservice node sends a registration request with region information to the registration center. The registration center responds after receiving the registration request.
[0048] Step S230: register the microservice node in the corresponding space according to the regional information, and save the registration information of the microservice node in the corresponding space, wherein the registration information includes service information.
[0049] The registration center responds to the registration request and registers the microservice node in the corresponding space according to the regional information included in the registration request. After the microservice node is registered, the registration information of the microservice node is saved in the corresponding space. The registration information at least includes service information (Service), which may include the functions that can be implemented by the microservice node, such as function name, service instance (Service Instance), etc. The registration information may also include, but is not limited to, address information, which may include the Internet Protocol address, port number, regional information, etc. of the microservice node.
[0050] Depend on Figure 2 It can be seen from the method shown that the present application divides the registration center into multiple corresponding spaces according to different regional information, receives the registration request including regional information of the microservice node, registers the microservice node in the corresponding space according to the regional information, and saves the registration information of the microservice node in the corresponding space. The present application logically isolates the registration center according to the regional information, and can uniformly deploy a set of Consul Clusters for multiple regions, which improves the resource utilization of the machine and reduces the system complexity and operation and maintenance complexity.
[0051] In some embodiments of the present application, the registration center includes multiple local nodes, and the registration method also includes: selecting a first registration node as a master node from the multiple local nodes; the master node divides the memory of the registration center into multiple corresponding spaces according to different regional information; the master node receives the registration request of the microservice node; according to the regional information, the master node registers the microservice node in the corresponding space, and saves the registration information of the microservice node in the corresponding space.
[0052] For the registration center, it can include multiple local nodes (Consul), adopting a one-master-multiple-slave node distribution method. The leader node (Leader Consul) is the first registration node elected from multiple local nodes, and the follower node (Follower) is the backup node of the leader node. Information from different regions is registered in the master node of the registration center. Through the master node, different namespaces are divided for different regions in the memory of the registration center to achieve logical isolation. The master node registers the microservice node in the corresponding logically isolated space, and synchronously saves the registration information of the microservice node in the corresponding logically isolated space. The election method of the master node can be, but is not limited to, random election, or election based on the order of computing speed.
[0053] In some embodiments of the present application, after the step of electing a first registration node as a master node from multiple local nodes, the registration method further includes: if the first registration node fails, electing a second registration node from the local nodes other than the first registration node, and making the second registration node the master node.
[0054] If the first registration node fails (for example, no response), a second registration node is elected from the slave nodes so that the second registration node serves as the new master node and assumes the corresponding role. The election method of the second registration node can be, but is not limited to, random election or election based on the order of computing speed.
[0055] When the registration center includes multiple local nodes, according to the above logic: the first registration node is elected as the master node among the multiple local nodes; when the first registration node fails, the second registration node is elected as the new master node among the local registration nodes except the first registration node; when the second registration node fails, the master node continues to be selected from the local registration nodes except the first registration node and the second registration node; and so on, to ensure a valid master node in the registration center.
[0056] Figure 3 The schematic diagram of the architecture of the registration method of the microservice cluster of an embodiment of the present application is shown. Figure 3 It can be seen that the architecture includes a registration center and microservice nodes that communicate with each other. The registration center includes a master node and multiple slave nodes. The master node divides the memory of the registration center into multiple corresponding spaces according to different regional information. After receiving the registration request including regional information from the microservice node, the microservice node is registered in the corresponding space, and the registration information including service information is saved in the corresponding space.
[0057] Figure 4 A flow chart of a service request processing method according to an embodiment of the present application is shown. The method is applicable to a gateway, which is respectively communicated with a registration center and a microservice node, and the registration center implements the registration method of the above-mentioned microservice cluster.
[0058] from Figure 4 It can be seen that this embodiment at least includes steps S410 to S440:
[0059] Step S410: receiving a service request, parsing the service request, and obtaining the region information and target service information of the service request.
[0060] The service request processing method of this embodiment uses the gateway (Zuul) as the execution subject. When a service request arrives at the gateway, the gateway analyzes the service request to obtain the region information and target service information included therein.
[0061] Step S420: Pull the registration information of the microservice node stored in the space corresponding to the registration center according to the regional information.
[0062] According to the regional information, the corresponding space is determined in the registration center, and the registration information of the microservice nodes registered in the space corresponding to the registration center is pulled to the gateway.
[0063] Step S430: Determine whether the target service information in the service request matches the service information in the registration information.
[0064] The registration information of the microservice node pulled by the gateway includes service information, and the service request received by the gateway includes target service information. The service information included in the registration information is retrieved to determine whether it matches the target service information in the service request.
[0065] Step S440: If yes, the service request is forwarded to the corresponding microservice node, so that the service information of the microservice node responds to the service request.
[0066] If there is service information in the registration information that matches the target service information in the service request, the service request is forwarded to the microservice node, so that the service information of the microservice node responds to the service request.
[0067] Depend on Figure 4 It can be seen from the method shown that, due to the change in the architecture of the registration method of the microservice cluster, the process of processing service requests has also changed accordingly, and the routing method of the gateway has changed. The service request processing method of the present application reduces the system complexity and operation and maintenance complexity.
[0068] In some embodiments of the present application, the registration information of the microservice nodes stored in the space corresponding to the registration center is pulled according to the regional information, including: according to the regional information, the registration information of the microservice nodes stored in the corresponding space by the master node of the registration center is pulled.
[0069] When the registration center includes multiple local nodes, it is always guaranteed that a valid registration node is elected as the master node. Therefore, the gateway pulls the registration information of the microservice node stored in the corresponding space from the registration center according to the regional information. The microservice node is registered by the master node.
[0070] In some embodiments of the present application, before the step of forwarding the service request to the microservice node so that the microservice node responds to the service request, the processing method also includes: determining whether the service information meets the preset conditions; if so, forwarding the service request to the microservice node so that the microservice node responds to the service request.
[0071] When there is service information in the registration information that matches the target service information in the service request, the availability of the service information is further determined. Determine whether the service information meets the preset conditions. If the preset conditions are met, it means that the service information is available, and then forward the service request to the microservice node so that the microservice node responds to the service request. The preset conditions may include but are not limited to the interruption frequency being lower than a fixed value, or the ratio of the interruption time to the duration being lower than a fixed value, etc. The preset conditions of this application are not limited to this.
[0072] Figure 5 The schematic diagram of the architecture of the service request processing method of the microservice cluster of one embodiment of the present application is shown. Figure 5 It can be seen that the architecture includes a gateway, a registration center, and a microservice node. The gateway is connected to the registration center and the microservice node in communication. The gateway receives the service request sent by the front end, parses the service request, and obtains the region information and target service information of the service request. According to the region information, the registration information including the service information of the microservice node stored in the space corresponding to the registration center is pulled. After determining that the target service information in the service request matches the service information of the registration information, and further determining that the service information is available, the gateway forwards the service request to the microservice node so that the service information of the microservice node responds to the service request.
[0073] Figure 6 A schematic diagram of the structure of a microservice cluster according to an embodiment of the present application is shown. Figure 6 It can be seen that the microservice cluster includes: a registration center, a gateway, and a microservice node. The registration center is connected to the microservice node in communication, and the gateway is connected to the registration center and the microservice node in communication. The registration center implements the registration method of the microservice cluster, and the gateway implements the service request processing method.
[0074] The microservice cluster of the present application includes a registration center, a gateway, and microservice nodes, which are connected to each other in communication. The registration center divides different spaces according to information from different regions, registers microservice nodes in corresponding spaces, and saves the registration information of microservice nodes in corresponding spaces. The gateway pulls the registration information saved in the corresponding space according to the service request sent by the front end, and matches the target service information included in the service request with the service information included in the registration information. After further determining that the service information is available, the service request is forwarded to the corresponding microservice node. Finally, the corresponding microservice node responds to the service request.
[0075] Figure 7 A flow chart of a working method of a microservice cluster of an embodiment of the present application is shown. The microservice cluster includes: a registration center, a gateway, and microservice nodes that are respectively connected to each other for communication. The registration center includes a master node and multiple slave nodes.
[0076] from Figure 7 It can be seen that this embodiment at least includes steps S7101 to S7205.
[0077] Step S7101: The registration center selects a first registration node from multiple local nodes.
[0078] For example: select the first registered node with the fastest computing speed from multiple local nodes.
[0079] Step S7102: determine whether the first registered node is invalid; if not, use the first registered node as the master node; if yes, select a second registered node from the local nodes except the first registered node and use the second registered node as the master node.
[0080] For example, when the first registered node is valid, the first registered node is used as the master node; when the first registered node fails, the second registered node with the second fastest computing speed is selected from multiple local nodes as the master node.
[0081] Step S7103: The master node divides the registration center memory into multiple corresponding spaces according to different regional information.
[0082] For example, different regional information includes zj (Zhejiang), hb (Hebei), and hn (Henan); the master node divides the registration center memory into corresponding "zj", "hb", and "hn" spaces according to the above three regional information.
[0083] Step S7104: The master node receives a registration request from the microservice node, where the registration request includes region information.
[0084] For example, the registration request of microservice node 1 includes zj region information, and the master node receives the registration request including zj region information; the registration request of microservice node 2 includes hb region information, and the master node receives the registration request including hb region information.
[0085] Step S7105: According to the regional information, the master node registers the microservice node in the corresponding space and saves the registration information of the microservice node in the corresponding space, wherein the registration information includes service information.
[0086] For example: the registration information of microservice node 1 includes ServiceA (service information A) and ServiceB (service information B). The master node registers microservice node 1 including zj area information in the "zj" space, and saves ServiceA and ServiceB in the "zj" space; the registration information of microservice node 2 includes ServiceC (microservice information C) and ServiceD (service information D). The master node registers microservice node 2 including hb area information in the "hb" space, and saves ServiceC and ServiceD in the "hb" space.
[0087] Step S7201: The gateway receives the service request, parses the service request, and obtains the region information and target service information of the service request.
[0088] For example, the service request is http: / / zuul.com:8080 / qt / zj / ServiceA / test. After the gateway parses the service request, it determines that the region information is zj and the target service information is ServiceA.
[0089] Step S7202: According to the regional information, pull the registration information of the microservice node stored in the corresponding space by the master node of the registration center.
[0090] For example: according to the address information zj, the gateway pulls the ServiceA and ServiceB service information of microservice node 1 stored in the "zj" space by the master node of the registration center.
[0091] Step S7203: Determine whether the target service information in the service request matches the service information in the registration information.
[0092] For example: the ServiceA target service information in the service request matches the ServiceA service information in the registration information, so the gateway determines a match.
[0093] Step S7204: If yes, determine whether the service information meets the preset conditions.
[0094] For example, the preset condition is that the interruption frequency is less than 1 time / day, and the interruption frequency of the service information is 0.8 times / day; therefore, the gateway determines that the service information meets the preset condition.
[0095] Step S7205: If yes, forward the service request to the corresponding microservice node so that the microservice node responds to the service request.
[0096] For example, the gateway forwards the service request to microservice node 1, so that the ServiceA service information of microservice node 1 responds to the service request.
[0097] The embodiment of the present application further provides a computer-readable storage medium, which stores a microservice registration program. When the microservice registration program is executed by at least one processor, it implements a registration method for a microservice cluster and is specifically used to execute:
[0098] Divide the registration center into multiple corresponding spaces according to different regional information;
[0099] receiving a registration request from a microservice node, wherein the registration request includes region information;
[0100] According to the regional information, the microservice node is registered in the corresponding space, and the registration information of the microservice node is saved in the corresponding space, wherein the registration information includes service information.
[0101] The embodiment of the present application further provides a computer-readable storage medium, which stores a service request processing program. When the service request processing program is executed by at least one processor, the service request processing method is implemented, and is specifically used to execute:
[0102] Receive the service request, parse the service request, and obtain the region information and target service information of the service request;
[0103] According to the regional information, pull the registration information of the microservice node stored in the space corresponding to the registration center;
[0104] Determine whether the target service information in the service request matches the service information in the registration information;
[0105] If so, the service request is forwarded to the corresponding microservice node so that the service information of the microservice node responds to the service request.
[0106] Figure 8 A schematic diagram of the structure of a microservice system according to an embodiment of the present application is shown. Figure 8 It can be seen that the microservice system includes: a registration center, a gateway, and a microservice node. The registration center is connected to the microservice node in communication, and the gateway is connected to the registration center and the microservice node in communication. The registration center includes: a first memory and a first processor, the first memory stores a microservice registration program, and the microservice registration program implements the registration method of the microservice cluster when it is executed by the first processor. The gateway includes: a second memory and a second processor, the second memory stores a service request processing program, and the service request processing method is implemented when the service request processing program is executed by the second processor.
[0107] The registration center includes a first memory and a first processor, and the first memory and the first processor can communicate with each other through a program bus, but are not limited to. The first memory can be a storage unit inside the registration center (such as a hard disk or memory, etc.), the first memory can also be a storage device outside the registration center (such as a plug-in hard disk or a smart memory card, etc.), or the first memory includes both a storage unit inside the registration center and an external storage device. In addition to storing the microservice registration program, the first memory can also be divided into corresponding storage spaces according to different regional information. The first processor can be a central processing unit, a microprocessor or other data processing chip, which is used to run the microservice registration program stored in the first memory, so as to register the microservice node in the space corresponding to the first memory, and store the registration information of the microservice node in the space corresponding to the first memory.
[0108] Specifically, the microservice registration program stored in the first memory implements the registration method of the microservice cluster when executed by the first processor, and is used to execute:
[0109] Divide the registration center into multiple corresponding spaces according to different regional information;
[0110] receiving a registration request from a microservice node, wherein the registration request includes region information;
[0111] According to the regional information, the microservice node is registered in the corresponding space, and the registration information of the microservice node is saved in the corresponding space, wherein the registration information includes service information.
[0112] The gateway includes a second memory and a second processor, and the second memory and the second processor can communicate with each other through a program bus, but is not limited to. The second memory can be a storage unit inside the gateway (such as a hard disk or memory, etc.), the second memory can also be a storage device outside the gateway (such as a plug-in hard disk or a smart memory card, etc.), or the second memory includes both a storage unit inside the gateway and an external storage device. A service request processing program is stored on the second memory. The second processor can be a central processing unit, a microprocessor or other data processing chip, which is used to run the service request processing program stored in the second memory, so as to forward the service request to the corresponding microservice node, so that the service information of the microservice node responds to the service request.
[0113] Specifically, the service request processing program stored in the second memory implements the service request processing method when executed by the second processor, and is used to execute:
[0114] Receive the service request, parse the service request, and obtain the region information and target service information of the service request;
[0115] According to the regional information, pull the registration information of the microservice node stored in the space corresponding to the registration center;
[0116] Determine whether the target service information in the service request matches the service information in the registration information;
[0117] If so, the service request is forwarded to the corresponding microservice node so that the service information of the microservice node responds to the service request.
[0118] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0119] The present application is described with reference to the flowcharts and / or block diagrams of the methods, systems, and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0120] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0121] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0122] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0123] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0124] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0125] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0126] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A registration method for a microservice cluster, characterized in that: The registration method is applicable to a registration center, the registration center is in communication connection with a microservice node, and the registration method includes: Dividing the registration center into a plurality of corresponding spaces according to different regional information; receiving a registration request from a microservice node, wherein the registration request includes region information; According to the region information, the microservice node is registered in the corresponding space, and the registration information of the microservice node is saved in the corresponding space, wherein the registration information includes service information.
2. The registration method of a microservice cluster according to claim 1, characterized in that: The registration center includes a plurality of local nodes, and the registration method further includes: Selecting a first registered node from the plurality of local nodes as a master node; The master node divides the memory of the registration center into a plurality of corresponding spaces according to information of different regions; The master node receives a registration request from a microservice node; According to the regional information, the master node registers the microservice node in the corresponding space and saves the registration information of the microservice node in the corresponding space.
3. The registration method of a microservice cluster according to claim 2, characterized in that: After the step of selecting a first registration node from the plurality of local nodes as a master node, the registration method further comprises: If the first registration node fails, a second registration node is elected from local nodes except the first registration node, and the second registration node is used as the master node.
4. A service request processing method, characterized in that: The processing method is applicable to a gateway, the gateway is respectively connected to a registration center and a microservice node in communication, the registration center implements the registration method of the microservice cluster according to any one of claims 1 to 3, and the processing method includes: Receiving a service request, parsing the service request, and obtaining region information and target service information of the service request; Pulling the registration information of the microservice node stored in the space corresponding to the registration center according to the regional information; Determining whether the target service information in the service request matches the service information in the registration information; If so, the service request is forwarded to the corresponding microservice node, so that the microservice node responds to the service request.
5. The service request processing method according to claim 4, characterized in that: Pulling the registration information of the microservice node stored in the space corresponding to the registration center according to the regional information includes: According to the regional information, the registration information of the microservice node stored in the corresponding space by the master node of the registration center is pulled.
6. The service request processing method according to claim 4, characterized in that: Before the step of forwarding the service request to the corresponding microservice node so that the microservice node responds to the service request, the processing method further includes: Determining whether the service information of the registration information meets a preset condition; If so, the service request is forwarded to the corresponding microservice node, so that the microservice node responds to the service request.
7. A microservice cluster, characterized in that: The microservice cluster includes: a registration center, a gateway, and a microservice node; wherein the registration center is communicatively connected to the microservice node, and the gateway is communicatively connected to the registration center and the microservice node respectively, the registration center implements the registration method of the microservice cluster described in any one of claims 1-3, and the gateway implements the service request processing method described in any one of claims 4-6.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a microservice registration program, and when the microservice registration program is executed by at least one processor, the registration method for the microservice cluster according to any one of claims 1 to 3 is implemented.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a service request processing program, and when the service request processing program is executed by at least one processor, the service request processing method according to any one of claims 4 to 6 is implemented.
10. A microservice system, characterized in that: The microservice system includes: a registration center, a gateway, and a microservice node; wherein the registration center is communicatively connected to the microservice node, and the gateway is communicatively connected to the registration center and the microservice node respectively; The registration center includes: a first memory and a first processor, the first memory stores a microservice registration program, and when the microservice registration program is executed by the first processor, the registration method of the microservice cluster according to any one of claims 1 to 3 is implemented; The gateway comprises: a second memory and a second processor, wherein a service request processing program is stored in the second memory, and when the service request processing program is executed by the second processor, the service request processing method according to any one of claims 4 to 6 is implemented.
Citation Information
Patent Citations
Service registration method and device, registration center management equipment and storage medium
CN109547570A
A micro-service injection molding MES cloud platform
CN109714358A
