当前位置:网站首页>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 🤩🤩🤩
边栏推荐
猜你喜欢
随机推荐
JVM之 MinorGC、 MajorGC、 FullGC、
Sublime Text3 set to run your own makefile
分布式和集群分不清,我们讲讲两个厨子炒菜的故事
点在多边形内外的判断
JVM之虚拟机栈之动态链接
力扣85题最大矩形
Leetcode MySQL database topic 177
Caused by: org. apache. xerces. impl. io. MalformedByteSequenceException: Invalid byte 3 of 3-byte UTF-8
Signal works: time varying and time invariant
自定义控件之下载控件1(DownloadView1)
JVM之方法返回地址
Gross Tumor Volume Segmentation for Head and Neck Cancer Radiotherapy using Deep Dense Multi-modalit
GridView of basic component of shutter
图片验证码控件
SeaweedFS安全配置(Security Configuration)
Application of keil5 integrated development environment for single chip microcomputer
Codeforces Round #645 (Div. 2)
时变和非时变
Language characteristics
Minorgc, majorgc, fullgc








