当前位置:网站首页>Nacos registry cluster
Nacos registry cluster
2022-06-29 10:10:00 【Xiao Wei wants to learn from all the guys】
Preface : This article will introduce nacos Cluster deployment of , I look forward to your review and help
List of articles
nacos colony

SpringBoot Integrate Spring Cloud Alibaba Nacos Registry Center . In most cases, an application system has only one registry , However, due to the distributed deployment of micro service architecture system across regions, there may be network delay problems , Therefore, we need to consider the multi registry scheme .
Due to the existence of the old based on Spring Cloud The migration of the microservice system to the new registry , Similar to grayscale publishing , Need new and old Nacos Registration Center coexists , It can be through some SpringBoot The project configures multiple registries at the same time to solve .
First configuration yml file
modify user-service Of application.yml file , Add cluster configuration :
spring:
cloud:
nacos:
server-addr: localhost:8848
discovery:
cluster-name: HZ
Restart both user-service After the instance , We can do it in nacos The console sees the following results :

Copy one again user-service A launch configuration , Add attribute :
-Dserver.port=8083 -Dspring.cloud.nacos.discovery.cluster-name=SH

spring:
application:
name: userservice
profiles:
active: dev
cloud:
nacos:
server-addr: nacos:8848
config:
file-extension: yaml
start-up UserApplication3 Check again later nacos Console :

Load balancing
default ZoneAvoidanceRule It is not possible to achieve load balancing according to the same cluster priority .
therefore Nacos One is provided in NacosRule The implementation of the , You can preferentially select instances from the same cluster .
First of all order-service Configure cluster information
modify order-service Of application.yml file , Add cluster configuration :
spring:
cloud:
nacos:
server-addr: localhost:8848
discovery:
cluster-name: HZ
modify order-service Of application.yml file , Modify load balancing rules :
userservice:
ribbon:
NFLoadBalancerRuleClassName: com.alibaba.cloud.nacos.ribbon.NacosRule
Weight configuration
This scenario will appear in the actual deployment :
There are differences in the performance of server devices , The machine where some examples are located has good performance , Others are poor , We want better machines to take on more user requests .
But by default NacosRule It is randomly selected in the same cluster , The performance of the machine will not be considered .
therefore ,Nacos Weight configuration is provided to control access frequency , The greater the weight, the higher the access frequency .
stay nacos Console , find user-service List of instances of , Click edit , You can modify the weight :
In the pop-up edit window , Modify the weight :
Be careful : If the weight is changed to 0, Then the instance will never be accessed
This article introduces here , Thank you for your support 🤩🤩🤩
边栏推荐
猜你喜欢
随机推荐
时变和非时变
Power Strings【KMP循环节】
ImageView picture fill problem
The collapsing "2.3 * 10 = 22" produced by multiplying float and int
2020-09-29 非商品模板化代码层次 rapidjson库
同花顺炒股软件可靠吗,安全吗?
Nacos环境隔离
【51nod 1215】数组的宽度
PHP内存马技术研究与查杀方法总结
Force deduction 85 question maximum rectangle
The Stones Game【取石子博弈 & 思维】
2020-09-17 gateway业务流程 两个任务:referer认证和非商品模板化
Is flush stock trading software reliable and safe?
2020-09-18 referer认证 url转义
Middle order traversal of Li Kou 94 binary tree
JVM instructions for four call methods
RecyclerView 通用适配器封装
container
2020-9-14 广告系统入门
完美二叉树、完全二叉树、完满二叉树









