当前位置:网站首页>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 🤩🤩🤩
边栏推荐
- Memory layout of JVM objects
- 任务调度器之Azkaban的使用
- 山科 的C语言2018练习题(电信)
- 信号作品:时变和时不变
- 自定义控件之侧滑关闭 Activity 控件
- A 2.5D Cancer Segmentation for MRI Images Based on U-Net
- leetcode MYSQL数据库题目177
- Setinterval, setTimeout and requestanimationframe
- Alternative implementation of Scrollview pull-down header amplification
- Minorgc, majorgc, fullgc
猜你喜欢

Perfect binary tree, complete binary tree, perfect binary tree

520 钻石争霸赛 2021

GridView of basic component of shutter

Dynamic linking of virtual machine stack of JVM

HDU 6778 Car (分组枚举-->状压 dp)

Gmail: how to quickly read all messages

另类实现 ScrollView 下拉头部放大

自定义控件之下载控件1(DownloadView1)

The Stones Game【取石子博弈 & 思维】

弧形 View 和弧形 ViewPager
随机推荐
2021年团体程序设计天梯赛-模拟赛
Sublime Text3 set to run your own makefile
If I were in Beijing, where would it be better to open an account? In addition, is it safe to open an account online now?
sympy的dsolve函数
Reverse thinking - short story
Memory layout of JVM objects
leetcode MYSQL数据库题目178
1098 Insertion or Heap Sort (25 分)
PHP内存马技术研究与查杀方法总结
FreeRTOS (VIII) - time management
GSOAP example - calc
分布式和集群分不清,我们讲讲两个厨子炒菜的故事
Codeforces Round #652 (Div. 2)
同花顺炒股软件可靠吗,安全吗?
如果我在北京,到哪里开户比较好?另外想问,现在在线开户安全么?
阿里云防火墙配置,多种设置方式(iptables和fireward)
十六制计数器和流水灯
Dsolve function of sympy
2019.10.6训练总结
Using rancher to build kubernetes cluster