A microservice governance platform based on Nacos
By using a Nacos-based microservice governance platform, the limitations of traditional microservice governance methods are overcome, enabling end-to-end service governance, improving service availability and stability, and reducing costs.
Patent Information
- Application Number
- CN202310719306.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-16
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2043-06-16
AI Technical Summary
Traditional microservice governance approaches suffer from issues such as single point of failure in the registry center, inconsistent configurations, and inconsistencies between production and pre-production environments, lacking a comprehensive service governance solution.
A microservice governance platform based on Nacos is adopted, including a registration module, a traffic governance module, a fault tolerance module, a fault recovery module, and a security management module. By leveraging Nacos' high availability, multi-datacenter features, dynamic configuration, metadata management, and canary release capabilities, end-to-end service governance is achieved.
It improves service availability and stability, overcomes the limitations of traditional service governance methods, reduces development and operation costs, and improves development efficiency and code quality.
Smart Images

Figure CN116708123B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more specifically to a microservice governance platform based on Nacos. Background Technology
[0002] The banking and financial industry uses enterprise-level architecture methodologies to streamline and construct enterprise-level business processes. This involves decomposing enterprise strategies into strategic capabilities and injecting them into business models. IT then implements these business models to ensure the strategy is put into practice. The value of enterprise architecture lies in enabling the construction and reuse of enterprise-level capabilities, facilitating the rapid launch of product innovations. The core principle is that the task components carrying business capabilities must fully correspond to the IT services that interface with them. This includes ensuring that the data tables accessed and updated by IT services, and the call relationships between IT services, are consistent with the business architecture modeling results. Only then can IT simultaneously support flexible assembly as businesses flexibly combine and innovate using task components.
[0003] As enterprises deepen their digital transformation, microservice architecture has gradually become one of the mainstream architectures for enterprise development. Service governance is particularly important in microservice architecture. Traditional service governance methods mainly include service registry, configuration center, circuit breaker, rate limiting, and degradation. The service registry is responsible for registering and discovering service instances, while the configuration center manages service configuration information. During service discovery, consumers query the service provider's location information through the registry and then obtain the service's runtime parameters, environment variables, and other configuration information through the configuration center. Circuit breaker, rate limiting, and degradation are the core components of the service protection mechanism, used to ensure service reliability and stability. A circuit breaker can promptly stop calls to a service, preventing a cascading failure caused by slow response or unavailability. A rate limiter can restrict service request traffic, preventing service crashes due to excessive load. Degradation provides alternative solutions, such as returning cached data or default values, thereby ensuring service availability and stability. However, these governance methods have certain limitations, such as single point of failure of the service registry, inconsistent configurations, and inconsistencies between production and pre-production environments.
[0004] Therefore, a full-chain service governance solution is urgently needed. Summary of the Invention
[0005] The purpose of this invention is to overcome the above-mentioned technical deficiencies and provide a Nacos-based microservice governance platform applicable to financial technology or other related technical fields, thereby solving the technical problem of the single service governance method in the existing technology.
[0006] To achieve the above-mentioned technical objectives, the present invention adopts the following technical solution:
[0007] A microservice governance platform based on Nacos includes:
[0008] The registration module provides an interface for service registrants to register service instances and an access interface for service consumers to access service instances.
[0009] The traffic management module is used to limit the number of requests to the service instance and to degrade the service instance when it is abnormal.
[0010] The fault tolerance module is used to perform fault tolerance processing on the service instance when the service instance encounters an error.
[0011] The fault recovery module is used to perform fault recovery processing on the service instance when the service instance fails.
[0012] The security management module is used to manage the access permissions and configuration information of the service instances.
[0013] In some embodiments, the registration module includes:
[0014] A connection configuration unit is used to configure the server and client so that the client can connect to the server;
[0015] The service registry creation unit is used to create a service registry and allow service providers to register service instances to the service registry.
[0016] An interface providing unit is used to provide the client with an interface for accessing service instances.
[0017] In some embodiments, the traffic management module includes:
[0018] A traffic rule configuration unit is used to configure traffic rules, wherein the traffic rules are used to limit the request volume of the service instance and to degrade the service instance when the service instance is abnormal;
[0019] The provider traffic rule reading unit is used to allow the service provider's Nacos client to read the traffic rules via API and apply them to the service instance;
[0020] The consumer traffic rule reading unit is used to enable Nacos clients serving consumers to read the traffic rules via API and select the service instance based on the traffic rules.
[0021] In some embodiments, the fault-tolerant module includes:
[0022] A health check rule configuration unit is used to configure health check rules based on a first health checker.
[0023] The provider health check rule reading unit is used to allow the service provider's Nacos client to read the health check rules via API and apply them to the service instance;
[0024] The consumer health check rule reading unit is used to enable the Nacos client serving the consumer to read the health check rules via API and select the service instance according to the health check rules.
[0025] In some embodiments, the health check rules are specifically as follows:
[0026] A first heartbeat request is sent to the service instance within a preset interval to check whether the service instance is alive. If the service instance does not respond to the first heartbeat request within the preset time or the returned status code is not the first preset status code, the service instance is considered unhealthy; otherwise, the service instance is considered healthy.
[0027] In some embodiments, the fault recovery module includes:
[0028] The fault recovery rule configuration unit is used to configure fault recovery rules based on the second health checker and the flow controller;
[0029] The provider fault recovery rule reading unit is used to allow the service provider's Nacos client to read the fault recovery rules via API and apply them to the service instance;
[0030] The consumer fault recovery rule reading unit is used to enable the Nacos client of the service consumer to read the fault recovery rules through the API and select the service instance according to the fault recovery rules.
[0031] In some embodiments, the fault recovery rule is specifically:
[0032] A second heartbeat request is sent to the service instance at a predetermined time to check whether the service instance is available. If the service instance fails to respond to the second heartbeat request for several consecutive times or the returned status code is not the second preset status code, the service instance is deemed unavailable, and traffic to the service instance is redirected according to a preset traffic control policy. Otherwise, the service instance is deemed available.
[0033] In some embodiments, the security management module includes:
[0034] The security management rule configuration unit is used to configure security management rules;
[0035] The provider security management rule reading unit is used to allow the service provider's Nacos client to read the security management rules via API and apply them to the service instance;
[0036] The consumer security management rule reading unit is used to enable Nacos clients serving consumers to read the security management rules via API, thereby ensuring the security of requests.
[0037] In some embodiments, the security management rules include at least authentication and authorization management sub-rules and secure communication sub-rules.
[0038] In some embodiments, the first health checker and the second health checker are one of a TCP health checker, an HTTP health checker, a MySQL health checker, and a custom health checker, and the traffic controller is one of a round-robin scheduler, a weighted scheduler, and an IP hash-based scheduler.
[0039] Compared with existing technologies, the Nacos-based microservice governance platform provided by this invention solves many problems of traditional service governance methods, improves service availability and stability, leverages the high availability and multi-datacenter features of Nacos to perform multi-datacenter service governance, utilizes Nacos's dynamic configuration, metadata management, canary release, and service monitoring functions to achieve end-to-end service governance, and uses the interface document management center to conveniently manage interface documents, improving development efficiency and code quality. It has the following advantages:
[0040] 1. Feature-rich: Nacos provides multiple functional modules such as service registration and discovery, load balancing, fault detection and tolerance, and configuration center, and supports clients in multiple languages to meet the needs of different scenarios;
[0041] 2. High ease of use: Nacos is simple and easy to use. It only requires the introduction of the corresponding dependencies and configuration to use, without the need for complex code modifications and configurations.
[0042] 3. Lower cost: Nacos is open source and free to use, which can reduce the development and maintenance costs for enterprises;
[0043] 4. High activity level: Nacos has an active open-source community, which provides timely technical support and version updates, resulting in more stable and reliable services. Attached Figure Description
[0044] Figure 1 This is a structural block diagram of a Nacos-based microservice governance platform provided in an embodiment of the present invention;
[0045] Figure 2 This is a structural block diagram of the registration module in the Nacos-based microservice governance platform provided in this embodiment of the invention;
[0046] Figure 3 This is a structural block diagram of the traffic governance module in the Nacos-based microservice governance platform provided in this embodiment of the invention.
[0047] Figure 4 This is a structural block diagram of the fault tolerance module in the Nacos-based microservice governance platform provided in this embodiment of the invention.
[0048] Figure 5 This is a structural block diagram of the fault recovery module in the Nacos-based microservice governance platform provided in this embodiment of the invention.
[0049] Figure 6 This is a structural block diagram of the security management module in the Nacos-based microservice governance platform provided in this embodiment of the invention. Detailed Implementation
[0050] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0051] The banking and financial industry uses enterprise-level architecture methodologies to streamline and construct enterprise-level business processes. This involves decomposing enterprise strategies into strategic capabilities and injecting them into business models. IT then implements these business models to ensure the strategy is put into practice. The value of enterprise architecture lies in enabling the construction and reuse of enterprise-level capabilities, facilitating the rapid launch of product innovations. The core principle is that the task components carrying business capabilities must fully correspond to the IT services that interface with them. This includes ensuring that the data tables accessed and updated by IT services, and the call relationships between IT services, are consistent with the business architecture modeling results. Only then can IT simultaneously support flexible assembly as businesses flexibly combine and innovate using task components.
[0052] As enterprises deepen their digital transformation, microservice architecture has gradually become one of the mainstream architectures for enterprise development. Within microservice architecture, service governance is particularly important. Traditional service governance methods mainly include service registry, configuration center, circuit breakers, rate limiting, and degradation. However, these governance methods have certain limitations, such as single point of failure in the service registry, inconsistent configurations, and inconsistencies between production and pre-production environments.
[0053] Based on the above-mentioned defects, please refer to Figure 1The present invention provides a microservice governance platform based on Nacos, including a registration module 100, a traffic governance module 200, a fault tolerance module 300, a fault recovery module 400, and a security management module 500, wherein the traffic governance module 200, the fault tolerance module 300, the fault recovery module 400, and the security management module 500 are all connected to the registration module 100.
[0054] The registration module 100 provides a service instance registration interface for service registrants and an access interface for service instances for service consumers.
[0055] The traffic management module 200 is used to limit the number of requests to the service instance and to degrade the service instance when it is abnormal.
[0056] The fault tolerance module 300 is used to perform fault tolerance processing on the service instance when the service instance encounters an error.
[0057] The fault recovery module 400 is used to perform fault recovery processing on the service instance when the service instance fails.
[0058] The security management module 500 is used to manage the access permissions and configuration information of the service instance.
[0059] This embodiment provides a full-link service governance technology based on Nacos. Nacos is an open-source service discovery, configuration management, traffic management and service governance platform that provides a series of service governance components, including service registration, traffic governance, fault tolerance mechanisms, fault recovery and security management.
[0060] Specifically, this invention builds upon traditional registry centers by leveraging the high availability and multi-datacenter capabilities of Nacos to construct a Nacos-based registry center. This addresses the single point of failure issue of traditional registry centers and facilitates service governance across multiple data centers, improving service availability and stability. Nacos employs various techniques to handle single-point anomalies, specifically:
[0061] a. Clustered Architecture: Nacos employs a clustered architecture, where multiple nodes form a cluster that collaborates and synchronizes data. This ensures that if a single node fails, the other nodes continue to function normally, preventing disruption to the overall system operation.
[0062] b. Master-slave failover: Each node in a Nacos cluster can be configured with a master-slave relationship. When the master node fails, the slave node will automatically take over the work of the master node to ensure system availability.
[0063] c. Pre-caching: Nacos adds a pre-caching mechanism on the server side, storing a copy of the metadata in the cache nodes. This allows for faster access to the cached data, improving system access speed. A heartbeat mechanism further ensures timely updates to the cached data.
[0064] d. Rate limiting and circuit breaking: Nacos supports rate limiting and circuit breaking, which can effectively prevent service outages. It prevents system overload by limiting the rate and frequency of system requests and automatically breaking irregular requests.
[0065] Furthermore, this embodiment of the invention utilizes the dynamic configuration capabilities provided by Nacos to construct a Nacos-based configuration center. This solves the problem of inconsistent configurations in traditional configuration centers and allows for real-time configuration updates, avoiding discrepancies between production and pre-production environments and improving service availability and stability.
[0066] Furthermore, this embodiment of the invention utilizes the metadata management functionality provided by Nacos to construct an interface documentation management center. This center facilitates the management of interface documentation, improves development efficiency and code quality, and reduces the misuse and abuse of interfaces.
[0067] Furthermore, in service governance, canary release is an important technique in this embodiment of the invention. Utilizing the canary release functionality provided by Nacos, end-to-end canary releases based on Nacos can be achieved. This facilitates robustness testing and monitoring, improving service availability and stability.
[0068] Furthermore, this embodiment of the invention utilizes the service monitoring capabilities provided by Nacos to achieve end-to-end monitoring based on Nacos. This function allows for real-time monitoring of service operational status and performance metrics, enabling the identification and resolution of problems, and improving service availability and stability.
[0069] This invention provides multiple functional modules such as service registration and discovery, load balancing, fault detection and tolerance, and a configuration center. It also supports clients in multiple languages to meet the needs of different scenarios. Furthermore, Nacos is simple and easy to use; it only requires the inclusion of the corresponding dependencies and configurations, without the need for complex code modifications or configurations. In addition, Nacos is open source and free to use, which can reduce the development and maintenance costs for enterprises. Moreover, Nacos has an active open source community, providing timely technical support and version updates, resulting in more stable and reliable services.
[0070] In some embodiments, please refer to Figure 2The registration module 100 includes a connection configuration unit 110, a registration center creation unit 120, and an interface providing unit 130, wherein the connection configuration unit 110, the registration center creation unit 120, and the interface providing unit 130 are connected in sequence.
[0071] The connection configuration unit 110 is used to configure the server and the client so that the client can connect to the server.
[0072] The registration center creation unit 120 is used to create a service registration center and to allow service providers to register service instances to the service registration center.
[0073] The interface providing unit 130 is used to provide the client with an interface for accessing service instances.
[0074] In this embodiment, Nacos provides a service registry. Service providers register their service instances in the registry, and service consumers can query available service instances through the registry. Service registration is the foundation of service governance and a prerequisite for traffic governance, fault tolerance mechanisms, and fault recovery.
[0075] In practice, service registration is achieved through the following steps:
[0076] 1. Configure the Nacos server and client to ensure that the Nacos server can start normally and the client can connect to the Nacos server;
[0077] 2. Write the code for the service provider and service consumer, add the Nacos client dependency to the code, and use the Nacos client API to register and discover services;
[0078] 3. Create a service registry in the Nacos console and register the service providers to the registry;
[0079] 4. In the service consumer, the service provider is discovered through the Nacos client API, and a request is sent to it.
[0080] In some embodiments, please refer to Figure 3 The traffic management module 200 includes a traffic rule configuration unit 210, a provider traffic rule reading unit 220, and a consumer traffic rule reading unit 230, wherein the traffic rule configuration unit 210 is connected to the provider traffic rule reading unit 220 and the consumer traffic rule reading unit 230.
[0081] Traffic rule configuration unit 210 is used to configure traffic rules, wherein the traffic rules are used to limit the request volume of the service instance and to degrade the service instance when the service instance is abnormal.
[0082] The provider traffic rule reading unit 220 is used to enable the service provider's Nacos client to read the traffic rules via API and apply them to the service instance.
[0083] The consumer traffic rule reading unit 230 is used to enable Nacos clients serving consumers to read the traffic rules via API and select the service instance based on the traffic rules.
[0084] In this embodiment, Nacos provides two traffic management methods: service rate limiting and service degradation. Service rate limiting can restrict the number of requests to a service based on metrics such as concurrent requests and request processing time, preventing service unavailability due to excessive requests. Service degradation can handle abnormal service conditions or high-concurrency traffic, ensuring the availability of core services. Service rate limiting and service degradation are based on service registration and require the registry center to provide available service information.
[0085] Specifically, first configure the traffic rules in the Nacos console and apply them to the service provider. Then, use the Nacos client API in the service provider to read the traffic rules and limit traffic according to the rules. Specifically, the Nacos client API can read the traffic rules through the following steps:
[0086] 1. Add the Nacos client dependency: Add the Nacos client dependency to your project. For example, in a Maven project, you can add the following dependency to your pom.xml file:
[0087] <dependency>
[0088] <groupid> com.alibaba.nacos< / groupid>
[0089] <artifactid> nacos-client< / artifactid>
[0090] <version> ${nacos.client.version}< / version>
[0091] < / dependency>
[0092] 2. Create a Nacos client instance: Create a Nacos client instance using the Nacos client API, specifying the Nacos Server address, namespace, access key, and other information. For example:
[0093]
[0094]
[0095] 3. Retrieve Traffic Rules via API: By calling the `getFlowRule` method of the Nacos client API, specifying parameters such as service name, group, cluster, and namespace, you can retrieve the traffic rules for a specific service. For example:
[0096] String flowRules=namingService.getFlowRule(serviceName,group,cluster,namespaceId);
[0097] System.out.println(flowRules);
[0098] The code above will return a string containing the traffic rules information for the service, which can be parsed and processed according to business needs.
[0099] When a service consumer accesses a service instance, it uses the Nacos client API to read traffic rules and selects the appropriate service provider based on those rules.
[0100] In some embodiments, please refer to Figure 4 The fault-tolerant module 300 includes a health check rule configuration unit 310, a provider health check rule reading unit 320, and a consumer health check rule reading unit 330.
[0101] The health check rule configuration unit 310 is used to configure health check rules based on the first health checker.
[0102] The provider health check rule reading unit 320 is used to enable the service provider's Nacos client to read the health check rules via API and apply them to the service instance.
[0103] The consumer health check rule reading unit 330 is used to enable the Nacos client serving the consumer to read the health check rules via API and select the service instance according to the health check rules.
[0104] In this embodiment, Nacos provides two fault tolerance mechanisms: service circuit breaking and service fault tolerance. Service circuit breaking automatically disconnects calls to a service when an exception occurs or a timeout occurs, preventing a cascading failure. Service fault tolerance automatically switches to a backup service or returns a default value when a service becomes unavailable. Service circuit breaking and service fault tolerance need to be used in conjunction with a service registry to obtain available service information in real time, thereby enabling circuit breaking or fault tolerance processing.
[0105] First, configure the health check rules in the Nacos console and apply them to the service provider. Specifically, in the Nacos console, health check rules are implemented through the first health checker. The health checker is a mechanism used by Nacos Server to determine whether a service instance is healthy.
[0106] Optionally, the health check rules are as follows:
[0107] A first heartbeat request is sent to the service instance within a preset interval to check whether the service instance is alive. If the service instance does not respond to the first heartbeat request within the preset time or the returned status code is not the first preset status code, the service instance is considered unhealthy; otherwise, the service instance is considered healthy.
[0108] In this embodiment, the health checker sends heartbeat requests to the service instance at regular intervals to check if the service instance is alive. If the service instance does not respond to the heartbeat request in a timely manner, or if the returned status code is not 200, the service instance is considered unhealthy, thereby triggering the corresponding traffic control policy. Nacos provides several types of health checkers, allowing users to select the appropriate one based on the specific scenario. Details are as follows:
[0109] TCP Health Checker: Sends TCP connection requests to the service instance to determine whether the service instance is responding normally.
[0110] HTTP Health Checker: Sends HTTP requests to service instances to check whether the service instances are responding normally. It can be configured with parameters such as request path and request method.
[0111] MySQL Health Checker: Connects to the MySQL database, executes SQL queries, and checks whether the service instance is responding normally.
[0112] Custom health checker: Customize the health checker according to business needs, such as checking whether the service instance is normal by calling a certain interface or sending a certain request.
[0113] In the Nacos console, you can add health check rules to service instances by configuring the health checker. The specific steps are as follows:
[0114] 1. Log in to the Nacos console, select the relevant service, and go to the "Service Details" page.
[0115] 2. In the "Instance List", select the service instance to which you want to add health check rules and click the "Configuration Management" button.
[0116] 3. On the "Configuration Management" page, select the "Health Check" tab to configure health check rules, including parameters such as health check type, check interval, check timeout, and number of checks.
[0117] 4. Click the "Save" button to save the health check rules. Nacos Server will periodically send heartbeat requests to the service instance and determine whether the service instance is healthy based on the service instance's response.
[0118] After the health check rules are configured, the service provider uses the Nacos client API to read the health check rules and determine its own health status based on the rules. The service consumer uses the Nacos client API to read the health check rules and select an available service provider based on the rules. In addition, the service consumer uses the Nacos client API to perform load balancing, select an available service provider, and send the request to it for processing.
[0119] In some embodiments, please refer to Figure 5 The fault recovery module 400 includes a fault recovery rule configuration unit 410, a provider fault recovery rule reading unit 420, and a consumer fault recovery rule reading unit 430, wherein the provider fault recovery rule reading unit 420 and the consumer fault recovery rule reading unit 430 are both connected to the fault recovery rule configuration unit 410.
[0120] The fault recovery rule configuration unit 410 is used to configure fault recovery rules based on the second health checker and the flow controller.
[0121] The provider fault recovery rule reading unit 420 is used to enable the service provider's Nacos client to read the fault recovery rules via API and apply them to the service instance.
[0122] The consumer fault recovery rule reading unit 430 is used to enable the Nacos client of the service consumer to read the fault recovery rule through API and select the service instance according to the fault recovery rule.
[0123] In this embodiment, Nacos provides service health checks and automatic fault detection capabilities. Service providers can perform self-checks through Nacos, uploading service status information to Nacos, which can then use this information to monitor the service status in real time. When a service failure occurs, Nacos can quickly detect and locate the fault, and perform fault recovery through service circuit breaking and fault tolerance mechanisms.
[0124] Specifically, first, configure the fault recovery rules in the Nacos console and apply them to the service provider. The fault recovery rules are configured through a combination of the second health checker and the flow control. When a service instance is marked as unavailable due to a fault, the fault recovery rules will decide whether to redirect traffic to the service instance based on certain policies.
[0125] Optionally, the fault recovery rule is specifically as follows:
[0126] A second heartbeat request is sent to the service instance at a predetermined time to check whether the service instance is available. If the service instance fails to respond to the second heartbeat request for several consecutive times or the returned status code is not the second preset status code, the service instance is deemed unavailable, and traffic to the service instance is redirected according to a preset traffic control policy. Otherwise, the service instance is deemed available.
[0127] In this embodiment, the health checker periodically sends heartbeat requests to service instances to check their health. If a service instance fails to respond to heartbeat requests for several consecutive times, or returns a status code other than 200, it will be marked as unavailable, triggering a fault recovery process. When a service instance is marked as unavailable, the traffic controller will decide whether to redirect traffic to that service instance based on configured rules. The second health checker is one of a TCP health checker, an HTTP health checker, a MySQL health checker, or a custom health checker. The traffic controller is one of a round-robin scheduler, a weighted scheduler, or an IP hash-based scheduler. The round-robin scheduler sends requests sequentially to different service instances to achieve load balancing. The weighted round-robin scheduler assigns different weights to different service instances and schedules requests according to the weight ratio. The IP hash-based scheduler sends requests to the corresponding service instance based on the source IP address of the request, ensuring that requests from the same client are always routed to the same service instance.
[0128] In the Nacos console, you can configure fault recovery rules to achieve fault recovery and traffic control for service instances. The specific steps are as follows:
[0129] 1. Log in to the Nacos console, select the relevant service, and go to the "Service Details" page.
[0130] 2. On the "Service Details" page, select the "Fault Recovery" tab and configure the fault recovery rules, including parameters such as the number of retries, retry interval, recovery interval, and weight.
[0131] 3. Click the "Save" button to save the fault recovery rules. Nacos Server will automatically perform fault recovery and traffic control according to the rules.
[0132] After the fault recovery rules are configured, the service provider uses the Nacos client API to read the fault recovery rules and performs fault recovery according to the rules; the service consumer also uses the Nacos client API to read the fault recovery rules and performs fault recovery according to the rules.
[0133] In some embodiments, please refer to Figure 6 The security management module 500 includes a security management rule configuration unit 510, a provider security management rule reading unit 520, and a consumer security management rule reading unit 530, wherein the provider security management rule reading unit 520 and the consumer security management rule reading unit 530 are both connected to the security management rule configuration unit 510.
[0134] The security management rule configuration unit 510 is used to configure security management rules.
[0135] The provider security management rule reading unit 520 is used to enable the service provider's Nacos client to read the security management rules via API and apply them to the service instance.
[0136] The consumer security management rule reading unit 530 is used to enable Nacos clients serving consumers to read the security management rules via API to ensure the security of requests.
[0137] In this embodiment, Nacos provides security management functions such as service access control and configuration encryption. Service providers can use Nacos to perform access control, controlling the access permissions and scope of services to prevent malicious access or attacks. Nacos also supports encryption of configuration information to ensure the security of sensitive information.
[0138] Specifically, first, configure the security management rules in the Nacos console and apply them to the service provider. Optionally, the security management rules should include at least authentication and authorization management sub-rules and secure communication sub-rules. The authentication and authorization sub-rules specifically address access control for services in Nacos by configuring corresponding authentication and authorization rules. Nacos supports multiple authentication methods, including username / password, JWT, and OAuth2. After authentication, ACL rules can be configured to authorize different users or roles, thereby controlling access to service resources. The secure communication sub-rules specifically address the security of communication between services by configuring SSL / TLS secure communication in Nacos. Specifically, encryption and authentication of communication between services can be achieved by configuring SSL certificates, keys, CA certificates, etc.
[0139] In practice, service resources can be protected and managed by configuring security management rules in the Nacos console. The specific steps are as follows:
[0140] 1. Log in to the Nacos console, select the relevant service, and go to the "Service Details" page.
[0141] 2. On the "Service Details" page, select the "Security Management" tab and configure authentication and authorization rules, including parameters such as username, password, and ACL rules.
[0142] 3. In the "SSL / TLS" tab, configure SSL / TLS secure communication parameters, including certificates, keys, CA certificates, etc.
[0143] 4. Click the "Save" button to save the security management rules. Nacos Server will then use the rules to control access to and protect the service resources.
[0144] Once the security management rules are configured, the service provider uses the Nacos client API to read the security management rules and perform security management accordingly. The service consumer also uses the Nacos client API to read the security management rules and ensure the security of requests accordingly.
[0145] In summary, the Nacos-based microservice governance platform provided by this invention features closely interconnected and interdependent components within Nacos, including service registration, traffic governance, fault tolerance mechanisms, fault recovery, and security management. These components form a complete service governance system. Service registration is the foundation of service governance; traffic governance, fault tolerance mechanisms, and fault recovery are crucial for ensuring service availability and stability; and security management is a necessary condition for ensuring service security. Therefore, when using Nacos for service governance, it is essential to comprehensively consider the interrelationships between these components and use them in a coordinated manner to build a complete service governance system, thereby ensuring service stability and security.
[0146] This invention solves many problems of traditional service governance methods, improves service availability and stability, leverages the high availability and multi-datacenter features of Nacos to perform multi-datacenter service governance, utilizes Nacos's dynamic configuration, metadata management, canary release, and service monitoring functions to achieve end-to-end service governance, and uses the interface documentation management center to easily manage interface documentation, improving development efficiency and code quality. It has the following advantages:
[0147] 1. Feature-rich: Nacos provides multiple functional modules such as service registration and discovery, load balancing, fault detection and tolerance, and configuration center, and supports clients in multiple languages to meet the needs of different scenarios;
[0148] 2. High ease of use: Nacos is simple and easy to use. It only requires the introduction of the corresponding dependencies and configuration to use, without the need for complex code modifications and configurations.
[0149] 3. Lower cost: Nacos is open source and free to use, which can reduce the development and maintenance costs for enterprises;
[0150] 4. High activity level: Nacos has an active open-source community, which provides timely technical support and version updates, resulting in more stable and reliable services.
[0151] The specific embodiments of the present invention described above do not constitute a limitation on the scope of protection of the present invention. Any other corresponding changes and modifications made in accordance with the technical concept of the present invention should be included within the scope of protection of the claims of the present invention.
Claims
1. A microservice governance platform based on Nacos, characterized in that, include: The registration module provides an interface for service registrants to register service instances and an access interface for service consumers to access service instances. The traffic management module is used to limit the number of requests to the service instance and to degrade the service instance when it is abnormal. The fault tolerance module is used to perform fault tolerance processing on the service instance when the service instance encounters an error. The fault recovery module is used to perform fault recovery processing on the service instance when the service instance fails. The security management module is used to manage the access permissions and configuration information of the service instances; The fault-tolerant module includes: A health check rule configuration unit is used to configure health check rules based on a first health checker. The provider health check rule reading unit is used to allow the service provider's Nacos client to read the health check rules via API and apply them to the service instance; The consumer health check rule reading unit is used to enable the Nacos client serving the consumer to read the health check rules via API and select the service instance according to the health check rules; The specific rules for the health check are as follows: A first heartbeat request is sent to the service instance within a preset interval to check whether the service instance is alive. If the service instance does not respond to the first heartbeat request within the preset time or the returned status code is not the first preset status code, the service instance is considered unhealthy; otherwise, the service instance is considered healthy. Health detection rules are implemented through the first health checker, which has various types and is a mechanism used to determine whether a service instance is healthy. By leveraging the dynamic configuration capabilities provided by Nacos, a configuration center based on Nacos can be built. Nacos adopts a clustered architecture, with multiple nodes forming a cluster. Each node in the Nacos cluster can be configured with a master-slave relationship. When the master node fails, the slave node will automatically take over the work of the master node.
2. The microservice governance platform based on Nacos according to claim 1, characterized in that, The registration module includes: A connection configuration unit is used to configure the server and client so that the client can connect to the server; The service registry creation unit is used to create a service registry and allow service providers to register service instances to the service registry. An interface providing unit is used to provide the client with an interface for accessing service instances.
3. The Nacos-based microservice governance platform according to claim 2, characterized in that, The traffic management module includes: A traffic rule configuration unit is used to configure traffic rules, wherein the traffic rules are used to limit the request volume of the service instance and to degrade the service instance when the service instance is abnormal; The provider traffic rule reading unit is used to allow the service provider's Nacos client to read the traffic rules via API and apply them to the service instance; The consumer traffic rule reading unit is used to enable Nacos clients serving consumers to read the traffic rules via API and select the service instance based on the traffic rules.
4. The Nacos-based microservice governance platform according to claim 3, characterized in that, The fault recovery module includes: The fault recovery rule configuration unit is used to configure fault recovery rules based on the second health checker and the flow controller; The provider fault recovery rule reading unit is used to allow the service provider's Nacos client to read the fault recovery rules via API and apply them to the service instance; The consumer fault recovery rule reading unit is used to enable the Nacos client of the service consumer to read the fault recovery rules through the API and select the service instance according to the fault recovery rules.
5. The Nacos-based microservice governance platform according to claim 4, characterized in that, The specific fault recovery rules are as follows: A second heartbeat request is sent to the service instance at a predetermined time to check whether the service instance is available. If the service instance fails to respond to the second heartbeat request for several consecutive times or the returned status code is not the second preset status code, the service instance is deemed unavailable, and traffic to the service instance is redirected according to a preset traffic control policy. Otherwise, the service instance is deemed available.
6. The Nacos-based microservice governance platform according to claim 5, characterized in that, The security management module includes: The security management rule configuration unit is used to configure security management rules; The provider security management rule reading unit is used to allow the service provider's Nacos client to read the security management rules via API and apply them to the service instance; The consumer security management rule reading unit is used to enable Nacos clients serving consumers to read the security management rules via API, thereby ensuring the security of requests.
7. The Nacos-based microservice governance platform according to claim 6, characterized in that, The security management rules include at least authentication and authorization management sub-rules and secure communication sub-rules.
8. The Nacos-based microservice governance platform according to claim 7, characterized in that, The first health checker and the second health checker are one of the following: TCP health checker, HTTP health checker, MySQL health checker, and custom health checker. The traffic controller is one of the following: round-robin scheduler, weight-based scheduler, and IP hash-based scheduler.
Citation Information
Patent Citations
Micro-service governance system
CN114090368A
