Beginner’s mind

Start working on NACOS today.

Why study this? Nacos is now recommended….. Although, we haven’t started using…. yet Prepare ahead of time.

Nacos has two main functions. One is registration discovery and one is configuration management

We now register using Eureka and configuration management using the Configuration center of Spring Cloud. Nacos contains two aspects below. From the server cost point of view, seems to save some server costs. After all, the two become one

Nacos is compared with Eureka and the Configuration center of Spring Cloud. Why does everyone recommend Nacos?

We can’t say yes just because someone else said yes. We really need to know what’s good about it and why? Understand his strengths, the better to extract its essence.

Why is more important than how

A preliminary research scheme was drawn up:

  1. What is Nacos, its pros and cons, its benefits

  2. Compare nacOS and Eureka, config

  3. Install and configure Nacos. Many are now containerized using Docker. Try using Docker to install NacOS, and then do everything else on nacOS

  4. Start learning according to the documentation on the website.

Nacos. IO /en-us/docs/…

Github address: github.com/alibaba/nac…


One. What is nacos?

Breaking it down, in the box is what NACOS does. Here’s the explanation

Nacos is dedicated to registering, discovering, configuring, and managing microservicesCopy the code

Two key points: service registration discovery, service configuration, service management three aspects

It provides a simple and useful set of capabilities that enable you to implement dynamic service discovery, service configuration, service metadata, and traffic management.Copy the code

Dynamic service discovery: What is dynamic. One aspect of dynamic, as I discussed with my colleagues earlier, is what it means to be hot. For example, if the server is registered, it can be found without rebooting. The service configuration is modified. The service can automatically identify the configuration modification without restarting the service.

So service metadata and traffic management: this should be related to load balancing. How is traffic allocated and managed according to metadata Settings

Nacos makes it easier and faster to build, deliver and manage microservices platformsCopy the code

How can it be easier and faster to build, deliver, and manage microservices platforms? Came up with the idea of automated deployment. There’s an interface, click a button, and you start operating. Not one server, one server to process.

The above is the introduction given by the official website: after my understanding, into plain English. Ha, ha, ha

What is Nacos?

Service is a first-class citizen of Nacos

The channel function is a first-class citizen. It says here nacos is a first-class citizen. What is a first-class citizen? Just like the customer is god, it is all about the customer. Nacos is all about service

Nacos supports the discovery, configuration and management of almost all types of services Kubernetes services gRPC and Dubbo RPC services Spring Cloud RESTful servicesCopy the code

Without further ado, we are now using Spring Cloud RESTful services

Key features of Nacos:

Service discovery and Service Health Checking Nacos supports service discovery based on DNS and RPC (Dubbo/gRPC). After the service provider registers the service with the native, OpenAPI, or dedicated proxy, the consumer can use DNS or HTTP to look up the service. Nacos provides real-time health checks to prevent services from sending requests to malfunctioning hosts or service instances. Nacos supports transport layer (PING or TCP) health checks and application layer (e.g. HTTP, Redis, MySQL, and user-defined protocols) health checks. Nacos provides proxy mode and server mode health checks for complex cloud and network topologies (e.g., VPCS, edge services, etc.). Nacos also provides a unified service health dashboard to help you manage the availability and traffic of your services.Copy the code
Dynamic Configuration Management Dynamically configuring services enables you to manage the configuration of all applications and services in a centralized, external, and dynamic manner in all environments. Dynamic configuration eliminates the need to redeploy applications and services when the configuration is updated. Centralized management of configuration makes it easier for you to implement stateless services and resiliently extend service instances on demand. Nacos provides an easy-to-use UI TODO that helps you manage the configuration of all your applications or services. It provides several off-the-shelf features, including configuration version tracking, Canary/beta version, configuration rollback, and client configuration update status tracking to ensure security and control the risk of configuration changes.Copy the code
Dynamic DNS Service The dynamic DNS service that supports weighted routing makes it easier to implement mid-tier load balancing, flexible routing policies, traffic control, and simple DNS resolution services in production environments within data centers. Dynamic DNS services make it easier for you to implement DNS-BASED service discovery. Nacos provides some simple DNS API TODO for you to manage DNS domain names and IP.Copy the code
Service Governance and Metadata Management Nacos allows you to manage all services and metadata from a microservices platform builder's perspective. This includes managing service descriptions, life cycle, service static dependency analysis, service health, service traffic management, routing and security rules, service SLAs and front-line metrics.Copy the code

The following figure illustrates the nacOS functionality in detailThe picture above is from the official website. Just take a look. This is a summary of the above contents. What are the functions, functions and advantages of NACOS?

The following diagram shows the structure and components of NACOS:

  • 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 (especially to avoid conflicts), log format, exception code + 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, need to be extensible
  • Push channel: Solve the performance problems of push between server and storage, between servers, and between server and 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: Start different programs +UI 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: to solve the data persistent, non-persistent storage, solve the problem of data fragmentation
  • Nameserver: Routes the namespace to clusterID and maps the user environment to the nacOS physical environment
  • CMDB: solve metadata storage, docking problems with the three-party CMDB system, and solve the relationship between applications, people and resources
  • 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, log whiteness, track push and other capabilities, and can be connected with metering and billing system
  • Access management: it 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
  • Authority management: solve identity identification, access control, role management and other problems
  • Audit system: Extended interface to facilitate access to audit systems of different companies
  • Notification system: core data change, or operation, convenient through SMS system, notification to the corresponding person data change
  • OpenAPI: Expose standard Rest style HTTP interface, easy to use, convenient integration of multiple languages
  • Console: Users can use the Console to manage services and configurations
  • SDK: Multilingual SDK
  • Agent: the DNS -f mode is similar, or it can be integrated with solutions such as mesh
  • CLI: Command line lightweight product management, as easy to use as Git

This is the function of NACOS, which can be studied in detail according to this figure in the future research.

Build, deploy, and Startup modes:

  • Two delivery methods

Nacos supports standard Docker images (supported starting with TODO: 0.2) and zip(tar.gz) zip packages.

  • Boot mode

Nacos supports two modes of combining the Service Registry and Config Center in one process or separating them.

  • Free public cloud service mode

In addition to deploying and starting Nacos services yourself, in the era of cloud computing, Nacos also supports the public cloud model, and will provide free public cloud services of Nacos in the commercial products of Ali Cloud public cloud (such as ACM, EDAS). The public cloud service of Nacos can also be provided by ali Cloud public cloud provider.

The advantages and disadvantages of NacOS and Eureka are compared

Spring Cloud Nacos

Advantages:

1) Out of the box, suitable for Dubbo, Spring Cloud, etc

2) AP model, data final consistency

3) Registry, configuration center two-in-one (two-in-one is not necessarily an advantage), provide console management

4) Pure domestic, all kinds of Chinese documents, after the double eleven test

Disadvantages:

1) Just open source, the community is not popular enough, there are still bugs

Spring Cloud had:

Advantages:

1) Spring Cloud official recommendation

2) AP model, data final consistency

3) Out of the box, with console management

Disadvantages:

1) The client registers the service and reports all information. In the case of many nodes, the network and the server are under too much pressure and the memory is wasted

2) The client updates the service information through a simple polling mechanism. When the number of services is huge, the server is under too much pressure.

3) Cluster scalability is not strong, the server cluster through broadcast replication, increasing server pressure

4) Eureka2.0 closed source (the latest version of Spring Cloud still uses 1.x Eureka)

In my opinion, the final reason why I had to abandon Eureka is that eureka2.0 is closed. That is to say, if you want to continue using eureka, SORRY, please pay……… Then, Nacos is good enough at home…. so… Nacos has been vigorously developed

So: to get a chance at some point…. Well, be prepared and good enough

Nacos is installed on docer

I have installed docker locally.

Step 1: Download the image

docker pull nacos/nacos-server

This is to download the latest version of the NacOS image

Step 2: View the image you have downloaded: Docker Images

Step 3: Start NACOS

docker run –env MODE=standalone –name nacos -d -p 8848:8848 nacos/nacos-server

Parameter analysis:

  • Run starts the run container
  • –env Configuration MODE=standalong Single node
  • –name nacos The image name is nacos
  • -d Daemon container
  • -p 8848:8848 Port mapping

Step 4: Access the IP address of the browser :8848/nacos. The default login password is nacos/nacos

See the following interface, success!!

Step 5: Check whether NACOS works properly

1. Advertise the configuration to the configuration center

Nacos is a service that also provides a number of interfaces, including one for adding configurations. We simulate this interface for configuration:

curl -X POST “http://localhost:8848/nacos/v1/cs/configs? dataId=nacos.cfg.dataId&group=test&content=HelloWorld”

See that the return result is true. Then refresh the console and see the following

2. Obtain the configuration from the configuration center

curl -X GET “http://localhost:8848/nacos/v1/cs/configs? dataId=nacos.cfg.dataId&group=test”

This command is to get the configuration

Get the HelloWorld content


References:

  1. IO /en-us/docs/…

  2. Making: github.com/alibaba/nac…

  3. The difference between nacos and Eureka: www.pianshen.com/article/864…