当前位置:网站首页>Alibaba cloud microservices (II) distributed service configuration center and Nacos usage scenarios and implementation introduction
Alibaba cloud microservices (II) distributed service configuration center and Nacos usage scenarios and implementation introduction
2022-07-06 13:09:00 【Geometer】
If the registry is used for addressing in microservices , Help one service call another service , The function of service configuration is to modify the configuration of each service more conveniently , for instance , If we use a configuration file to configure information , If you want to modify a configuration item , We need to repackage , Release , But if you use the configuration center , Then you only need to modify
About using the configuration center for Shenma , I think there are mainly the following reasons :
1. Separate multi-environment configuration
2. More flexible management permissions
3. Higher security
About 1. Separate multi-environment configuration
In the same case, different configuration environments may be required
as follows , We are in the configuration center nacos Add a configuration information
Test in the service to see whether the configuration information can be read
You can see from the figure below that the configuration information is read successfully
The configuration information just now is in properties Configured in , If you change the configuration file to yaml What will be done ?
You can see the read yaml File information
After that, you can start from Nacos Two configuration files were observed in time , It is more convenient to manage files
For configuration information, it is common that the same code may be in different scenarios profile and namespace There are different configurations on
profile It's in different profile You can have the same configuration item but different values
As follows, in the environment profile Change to develop
Use the app name +profile To create
About namespace Different
Create a new one namespace training
Record his namespace id
Add to configuration
You can see the read namespace Configuration information of succeeded
About Nacos
Nacos There are mainly service registration and discovery , Health check and access policy
The picture below is nacos and zookeeper as well as Eureka Comparison of
You can see Nacos You can freely choose a consistency agreement , How to choose a consistency protocol , It can be understood as
If the success or failure of a single write request is important , Should guarantee cp The consistency of , because cp The consistency of services sacrifices the overall availability of services in exchange for data consistency
If the success or failure of a single request is not very important , Instead, data consistency can be maintained through subsequent data compensation mechanisms , Should guarantee ap The consistency of
besides ,Nacos It also has its own advantages in access strategy
The access strategy of the server is more flexible , Because there is no need to modify the client and it can be adjusted more flexibly in the process of use
In the data service model , Services and clusters can store different service configurations for service management , Like some specific information, such as ip And ports can be managed by the instance
Nacos The implementation of is mainly divided into the following modules
Preliminary permission verification is defined in the user interface module , Parameter verification and data conversion
The push module manages all subscribers , And push trigger , Aggregation and weight removal
The health check module supports server-side detection and client-side reporting
Access policies filter the server through different access policies , Currently, the supported access policies are tag based access policies
Store data and server Synchronization between to ensure data consistency
边栏推荐
猜你喜欢
系统设计学习(一)Design Pastebin.com (or Bit.ly)
Fgui project packaging and Publishing & importing unity & the way to display the UI
2-year experience summary, tell you how to do a good job in project management
Several high-frequency JVM interview questions
Fundamentals of UD decomposition of KF UD decomposition [1]
染色法判定二分图
[algorithm] sword finger offer2 golang interview question 4: numbers that appear only once
Code example of MATLAB reading GNSS observation value o file
阿里云微服务(四) Service Mesh综述以及实例Istio
面试必备:聊聊分布式锁的多种实现!
随机推荐
Fundamentals of UD decomposition of KF UD decomposition [1]
阿里云微服务(三)Sentinel开源流控熔断降级组件
Several high-frequency JVM interview questions
[algorithm] sword finger offer2 golang interview question 3: the number of 1 in the binary form of the first n numbers
面渣逆袭:Redis连环五十二问,三万字+八十图详解。
[algorithm] sword finger offer2 golang interview question 9: subarray with product less than k
TYUT太原理工大学2022数据库大题之数据库操作
[算法] 剑指offer2 golang 面试题4:只出现一次的数字
Comparative analysis of the execution efficiency of MySQL 5.7 statistical table records
TYUT太原理工大学2022数据库大题之分解关系模式
TYUT太原理工大学2022数据库大题之E-R图转关系模式
[算法] 劍指offer2 golang 面試題2:二進制加法
On March 15, the official version of go 1.18 was released to learn about the latest features and usage
编辑距离(多源BFS)
记录:下一不小心写了个递归
Record: newinstance() obsolete replacement method
All in one 1405: sum and product of prime numbers
【GNSS】抗差估计(稳健估计)原理及程序实现
Excel导入,导出功能实现
抽象类和接口