Nacos. IO/useful – cn/docs /…

1. The service

A service is a software function or set of software functions (such as the retrieval of specific information or the execution of a set of operations) that can be reused by different clients for different purposes (such as through cross-process network calls). Nacos support mainstream ecological Service, such as Kubernetes Service, gRPC | Dubbo RPC Service or Spring Cloud RESTful Service.

Name service

Service mapping, such as ServiceName -> Endpoints Info, Distributed Lock Name -> Lock Owner/Status Info, DNS Domain Name -> IP List, Service discovery and DNS are two scenarios of name services.

2. Registry

Service registry, which is a database of services, instances, and metadata. Service instances are registered with the service registry at startup and unregistered at shutdown. Clients of services and routers query the service registry to find available instances of services. The service registry may invoke the health check API of the service instance to verify that it can handle the request.

3. The metadata

Service Metadata

Service metadata refers to data describing services, including endpoints, service labels, service version numbers, service instance weights, routing rules, and security policies.

4. Provider / Consumer 

The application that provides reusable and callable services/the application that initiates a call to a service.

5. Configure the center

Configuration and management In the process of system development, some parameters and variables that need to be changed are usually separated from the code and managed independently, and exist in the form of independent configuration files. Configuration change is one of the effective means to adjust the behavior of the system at run time. All configuration-related activities in the system, such as editing, storing, distributing, change management, historical version management, and change audit, are collectively referred to as configuration management. A service provider that provides dynamic configuration or metadata and configuration management during service or application execution.

6. Logical architecture

  • Console The Console is used for service management and configuration management.
  • SDK Multi-language SDK.
  • Agent DNS -F is similar to the Agent DNS -F mode, or it can be integrated with solutions such as mesh.
  • The CLI command line lightweight product management, as easy to use as Git.
  • OpenAPI exposes the standard Rest style HTTP interface, which is easy to use and easy to integrate into multiple languages.
  • Service management Service CRUD, domain name CRUD, service health status check, service weight management and other functions.
  • Configuration management to achieve configuration tube CRUD, version management, gray management, monitoring management, push track, data aggregation and other functions.
  • Metadata management provides metadata CURD and marking capabilities.
  • Nameserver resolves the routing problem from the Namespace to the ClusterID and the mapping problem between the user environment and the nacOS physical environment.
  • CMDB solves metadata storage, docking problems with the three-party CMDB system, and solving the relationship between application, people and resources.
  • Metrics Exposes standard Metrics data for easy access to third-party monitoring systems.
  • Trace exposes the standard Trace, which facilitates communication with SLA system, log whiteness, track push, and other capabilities. It can also communicate with metering and billing system.
  • Access management is equivalent to the process of aliyun opening services and assigning identities, capacities and permissions.
  • User management Solve user management, login, sso, and other problems.
  • Rights management Solves problems such as identity identification, access control, and role management.
  • The extended interface of the audit system facilitates the connection with audit systems of different companies.
  • Notify the system of core data change, or operation, convenient through SMS system, notify the corresponding person of data change.
  • Plug-in mechanism to achieve the ability of three modules can be divided and combined, the implementation of SPI mechanism extension point.
  • The event mechanism realizes asynchronous event notification, SDK data change asynchronous notification and other logic.
  • The log module manages log classification, log level, log portability (especially conflict avoidance), log format, exception codes + help documentation.
  • Callback mechanism THE SDK notifies the data and calls the user back in a unified mode for processing. Interfaces and data structures need to be extensible.
  • Addressing mode Address IP, domain name, Nameserver, broadcast and other addressing modes, need to be extensible.
  • The push channel solves the performance problems of push between servers and storage, between servers, and between servers and SDKS.
    • Capacity management This section describes how to manage the capacity of each tenant and each group to prevent storage overwrite from affecting service availability.
  • Traffic management controls request frequency, number of long links, packet size, and request flow control by tenant and group.
  • Cache mechanism Dr Directory, local cache, server cache mechanism. Tools are required for using Dr Directories.
  • Startup mode Launches different programs +UI in single-machine mode, configuration mode, service mode, DNS mode, or all mode.
  • Consistency protocols address different data consistency requirements and different consistency mechanisms.
  • Storage module to solve the data persistent, non-persistent storage, solve the problem of data fragmentation.

7. Data model

Nacos data model keys are uniquely determined by triples, Namespace defaults to empty strings, common namespaces (public), and groups default to DEFAULT_GROUP.

The SDK class view

8. Nacos 2.X

GRPC Rsocket Long connection RPC call and push capability

  • Communication layer unified togRPCAt the same time, improve the client and server traffic control and load balancing capabilities, improve the overall throughput.
  • The storage and consistency model has been fully abstracted and layered, making the architecture simpler and clearer and the performance more powerful.
  • Extensible interfaces are designed to enhance integration capabilities, such as enabling users to implement their own security mechanisms.

8.1. Service discovery upgrade

Consistency model Service discovery in Nacos2 architecture, the client initiates the request to register service or subscribe service through gRPC. The Client object is used by the server to record which services are published and subscribed by the Client using the gRPC connection, and to synchronize the Client between services. Because the actual usage habit is the mapping between the service and the client, that is, the client instances under the service; Therefore, the 2.0 server will quickly generate Service information similar to that in 1.x by building indexes and metadata, and push the Service data through the Grpc Stream.

8.2. Configuration management upgrade

Communication mechanism configuration management before using Http1.1 Keep Alive mode 30 seconds to send a heartbeat simulation long link, memory consumption is large, weak push performance. The 2.0 gRPC solves these problems completely and reduces memory consumption greatly.

8.3. Summarize

  1. The client no longer needs to periodically send the instance heartbeat, just a Keepalive message to maintain the connection. Repeated TPS can be drastically reduced.
  2. TCP connection disconnection can be quickly detected to improve the response speed.
  3. Long connection streaming push, more reliable than UDP; Nio’s mechanism has higher throughput and, thanks to reliable push, can extend the time the client spends checking the list of services and even delete the related requests. Repeated invalid QPS can be drastically reduced.
  4. Long connections can greatly alleviate TIME_ WAIT problems by avoiding frequent connection overhead.
  5. Real long connection, solve configuration module GC problem.
  6. More fine-grained synchronization content, reducing communication stress between service nodes.

9. In the future