This is the 10th day of my participation in the November Gwen Challenge. Check out the event details: The last Gwen Challenge 2021

Basic introduction

  • Nacos is dedicated to discovering, configuring, and managing microservices
  • Nacos provides an easy-to-use feature set for fast dynamic service discovery, service configuration, service metadata, and traffic management
  • Nacos makes it more agile and easy to build, deliver, and manage microservices platforms
  • Nacos is the service infrastructure for building modern application architectures that are [service] centric

The characteristics of Nacos

  • Service Service is a first-class citizen of Nacos
  • Nacos supports the discovery, configuration, and management of almost all major types of [services]
  • Key features of Nacos:
    • Service discovery and service health monitoring
    • Dynamically configured service
    • Dynamic DNS Service
    • Service and metadata management
Service discovery and service health monitoring
  • NacosSupport based onDNSAnd based onRPCService discovery of
    • The Service provider registers the Service using the native SDK,OpenAPI, or a separate Agent TODO
    • Service consumers can use DNS TODO or HTTP&API to find and discover services
  • Nacos provides real-time health checks on services to prevent requests from being sent to unhealthy hosts or service instances
  • Nacos supports transport layer PING or TCP and application layer HTTP,MySQL, and user-defined health checks
  • For complex cloud environment and network topology environmentVPC,Edge network and other services health check,NacosprovidesagentThere are two health check modes:
    • Report the pattern
    • Active detection by the server
  • Nacos also provides a unified health check dashboard that manages service availability and traffic based on health status
Dynamically configured service
  • Dynamic configuration services manage application configuration and service configuration for all environments in a centralized, external, and dynamic manner
  • Dynamic configuration eliminates the need to redeploy applications and services when configuration changes, making configuration management more efficient and agile
  • Centralized configuration management makes it easier to implement stateless services and make it easier for services to scale flexibly on demand
  • Nacos provides a simple and easy-to-use UI to manage the configuration of all services and applications
  • Nacos also provides a number of out-of-the-box configuration management features including configuration version tracking, one-click rollback of configuration, and client configuration update status tracking to more securely manage configuration changes and reduce the risk of configuration changes in a production environment
Dynamic DNS Service
  • dynamicDNSThe service supports weighted routing, which is easier to implement:
    • Middle layer load balancing
    • More flexible routing policies and traffic control
    • Simple DNS resolution service on the dc Intranet
  • Dynamic DNS services also make it easier to implement DNS protocol-based service discovery, eliminating the risk of coupling to private service discovery apis
  • Nacos provides some simple DNS APIs TODO manages the service’s associated domain names and available IP:PORT list
Service and metadata management
  • NacosManage all services and metadata of the data center from the perspective of micro-service platform construction, including:
    • The most important metrics statistics
    • The service description
    • The life cycle
    • Service static dependency analysis
    • Service health
    • Service Traffic Management
    • Routing and security policies
    • Service SLA

The basic concept

regional

  • Physical data centers
  • After a resource is created, it cannot be replaced

The available area

  • A physical area within the same area where electricity and network are independent of each other
  • Instances in the same availability zone have low network latency

Access point

  • The entry domain name of a service in a region

The namespace

  • Used for configuration isolation of tenant granularity
  • Different namespaces can have the same Group or Data ID configuration
  • Common scenarios of a Namespace are as follows: Distinguishes and isolates configurations in different environments. For example, configuration of development test and production environments, isolation of services, etc

configuration

  • In the process of system development, developers usually separate some parameters and variables that need to be changed from the code and manage them independently in the form of independent configuration files
  • The goal is to make static system artifacts or deliverables, such as WAR and JAR packages, better match the actual physical operating environment
  • Configuration management is usually performed by system administrators or o&M personnel during system deployment
  • Configuration changes are an effective means of adjusting the behavior of the system at run time

Configuration management

  • System configuration editing, storage, distribution, change management, historical version management, change audit, all configuration related activities

Configuration items

  • A specific configurable parameter and value field, usually in the form param-key=param-value
  • For example, we often configure the log output level of the system:
logLevel=INFO|WARN|ERROR
Copy the code

Configuration set

  • A set of related or unrelated configuration items is called a configuration set
  • In a system, a configuration file is usually a configuration set that contains all aspects of the system configuration
  • A configuration set may contain configuration items such as data sources, thread pools, log levels, and so on

Configuration set ID

  • The ID of a configuration set in Nacos is one of the dimensions of the organization partition configuration
  • The Data ID is typically used to organize the configuration set that divides the system
  • A system or application can contain multiple configuration sets, each of which can be identified by a meaningful name
  • Data ids are typically named using a Java-like package to ensure global uniqueness

Configure grouping

  • A set of configuration sets in Nacos is one of the dimensions of organizational configuration
  • Configuration sets are grouped by a meaningful string to distinguish configuration sets with the same Data ID
  • When creating a configuration on Nacos, DEFAULT_GROUP is used by default if the name of the configuration group is not specified
  • Common scenarios for configuring groups: Different applications or components use the same configuration type. Examples include the database_URL configuration and the MQ_topic configuration

Configure the snapshot

  • Nacos’s client SDK generates a snapshot of the configuration locally
  • If the client cannot connect to the Nacos Server, you can use the configuration snapshot to display the overall disaster recovery capability of the system
  • A configuration snapshot is similar to a local commit in Git, and is similar to a cache in that it is updated at an appropriate time, but there is no concept of a cache expiration

service

  • Software functions provided to clients through a network of predefined interfaces

The service name

  • An identity provided by a service that uniquely identifies the service to which it refers

Service Registry

  • A database that stores service instances and service load balancing policies

Service discovery

  • On computer networks, the addresses and metadata of instances under a service are probed using a service name and provided to clients for query through a predefined interface

Meta information

  • NacosConfiguration and service description of:
    • The service version
    • The weight
    • Disaster strategy
    • Load Balancing Policy
    • Authentication configuration
    • Various custom labels label
  • From the perspective of the scope of action, it can be divided into:
    • Meta information for the service level
    • Meta information about the cluster
    • Meta information about the instance

application

  • Attributes that identify the service of the service provider

Service group

  • Different services can be grouped into the same group

The virtual cluster

  • All service instances of a service form a default cluster
  • Clusters can be further divided according to requirements and can be divided in virtual clusters

The instance

  • A process with an accessible network address IP:Port that provides one or more services

The weight

  • Instance level configuration
  • The weight is a floating point number. The greater the weight, the greater the traffic allocated to the instance

Health check

  • Check the health of Instance mounted to the service in a specified manner to check whether the Instance can provide services
  • Based on the inspection results, Instance is judged to be healthy or unhealthy
  • When a resolution request is made to the service, an unhealthy Instance is not returned to the client

Health protection threshold

  • The health protection threshold should be defined as a floating point number between 0 and 1 to prevent the traffic from flowing to the healthy Instance due to too many unhealthy instances and thus causing an avalanche effect
  • When the ratio of domain name healthy instances to total service instances is smaller than the value, the Instance is returned to the client regardless of whether the Instance is healthy or not
  • This ensures that the remaining healthy Instance of the cluster, Instance, works properly

Nacos architecture

  • Services: Service
    • A service is a software function or a set of software functions. Such as the retrieval of specific information or the execution of a set of operations
    • The purpose is that different clients can reuse it for different purposes. Such as through cross-process network calls
    • NacosSupport mainstream service ecology:
      • Kubernetes Service
      • gRPC|Dubbo RPC Service
      • Spring Cloud RESTful Service
  • Service Registry: Service Registry
    • A service registry 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 the request can be processed
  • Service metadata: Service Metadata
    • Service endpoints
    • Service tag
    • Service Version number
    • Service instance Weight
    • Routing rules
    • Security policy, etc.
  • Service Provider: Service Provider
    • An application that provides reusable and callable services
  • Service Consumer: Service Consumer
    • An application that initiates a call to a service
  • Configuration: Configuration
    • In the process of system development, some parameters and variables that need to be changed are usually separated from the code and managed independently, existing in the form of independent configuration files
    • The goal is to make static system artifacts or deliverables such as WAR and JAR packages fit better with the actual physical operating environment
    • Configuration management is usually performed by system administrators or o&M personnel during system deployment
    • Configuration change is one of the effective means to adjust the behavior of the system at run time
  • Configuration management: Configuration Management
    • In a data center, all configuration-related activities such as editing, storing, distributing, change management, historical version management, and change audit are collectively referred to as configuration management
  • Name service: Naming Service
    • Provides the mapping management service between the names of all objects and entities in a distributed system and the associated metadata
    • ServiceName -> Endpoints Info
    • Distributed Lock Name -> Lock Owner/Status Info
    • DNS Domain Name -> IP List
    • Service discovery and DNS are two application scenarios of name service
  • Configuring services: Configuration Service
    • A service provider that provides dynamic configuration or metadata and configuration management during service or application execution

Nacos components

  • Service management: service CRUD, domain name CRUD, service health status check, service weight management and other functions
  • Configuration management: realize configuration tube CRUD, version management, gray management, monitoring management, push track, aggregation data and other functions
  • Metadata management: Provides metadata CURD and marking capabilities
  • Plug-in mechanism: three modules can be divided and combined to achieve the extension point SPI mechanism
  • Event mechanism: realize asynchronous event notification, SDK data change asynchronous notification and other logic
  • Log module: manages log classification, log level, log portability, log format, exception codes and help documents
  • Callback mechanism: THE SDK notifies the data and calls the user back through 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, can be expanded on demand
  • Transfer channel: solve the performance problems of server and storage,server to server,server to SDK
  • Capacity management: Manages the capacity of each tenant and each group to prevent storage write failures and affect service availability
  • Traffic management: Controls the request frequency, number of long links, packet size, and request flow control according to tenants and groups
  • Cache mechanism: Dr Directory, local cache,server cache mechanism. Tools are required for using Dr Directories
  • Startup mode: Launches different programs and UIs in single-machine mode, configuration mode, service mode, DNS mode, or all mode
  • Consistency protocol: different consistency mechanisms for different data and different consistency requirements
  • Storage module: solve data persistence, non-persistence storage, solve the problem of data fragmentation
  • NameService: Routes from the namespace to the ClusterID and maps the user environment to the nacOS physical environment
  • CMDB: Resolves the connection between the metadata store and the three-party CMDB system
  • Metrics: Expose the standard Metrics data, which is convenient to get through with the three-party monitoring system
  • Trace: Exposes the standard Trace, which facilitates communication with SLA system, flattening log, pushing track and other capabilities, and can also be connected with metering and billing system
  • Access management: the process of assigning identity, capacity, and permissions
  • User management: solve user management, login, SSO and other problems
  • Authority management: solve identity identification, access control, role management and other problems
  • Audit system: Extended interface to facilitate communication with different audit systems
  • Notification system: notification of core data change or data change to corresponding person through SMS system during operation
  • OpenAPI: Standard Rest STYLE HTTP interface to facilitate multi-language integration
  • Console: Easy to use Console, service management and configuration management operations
  • SDK: Multilingual SDK
  • Agent: Similar to the DNS -F mode, integrated with the mesh solution
  • CLI: Implements lightweight product management on the CLI

Nacos domain model

The data model
  • NacosThe data modelKeyUniquely determined by triples:
    • Namespace :Namespace. Default is empty string
    • Public namespace :public
    • Group :Group. The default Group is DEFAULT_GROUP

Service domain model

Configuration domain model
  • To configure the domain model, there are primarily two related entities: accordingIDTo associate
    • Configuration Change History
    • Service tag
      • Mainly used for marking classification, convenient index

Class view

Nacos – SDK class view

Build, deploy, and start up Nacos

  • Nacos supports standard Docker images and constructs of zip or tar.gz zip packages
  • NacosTwo startup modes are supported:
    • The Service Registry and Config Center are deployed together in one process
    • The Service Registry is deployed separately from the Config Center