当前位置:网站首页>Nacos hierarchical storage model - the cluster configuration and NacosRule load balance
Nacos hierarchical storage model - the cluster configuration and NacosRule load balance
2022-07-29 13:03:00 【Maosan】
As our services grow,More and more service instance(比如说userservice,有8081、8082、8083Three instances of ports),It's not safe for us to deploy all services in the same room,When dealing with emergencies,like eggs in one basket;很不安全,很不友好,All we need to deploy the computer room and the server separately;
A service can be deployed in multiple clusters,A server can deploy multiple services(但是一般不会这么做,Generally one server only deploy a service instance),一个集群可以有多个实例;
So how do we configure the cluster??
服务启动前,Configure the cluster properties,再进行启动:
例如:
给userservice配置集群HZ(杭州),启动两个userservice实例:8081、8082,At this point both instances are deployed inHZ集群上

此时,Change the cluster name again,启动一个userservice3,This instance is deployed inSH(上海)集群上了
可以再NacosSee the deployed service instance in:
点击“详情”:Can see clusters and deployed instances
总结:
NacosRule负载均衡
Above we putuserservice1(服务提供者)和userservice2(服务提供者)配置在了HZ(杭州)集群,userservice3(服务提供者)配置在了SH(上海)集群.
操作:把orderservice(服务消费者)也部署在HZ集群:
此时我们的orderservice(服务消费者)also configured toHZ集群,再调用userservice(服务提供者)时,Will use the default polling algorithm;regardless of cluster(userservice1、2、3will poll calls);
这是很不明智的,because in reality,When our service in Hangzhouorderservice(服务消费者),To call a remote service in Shanghaiuserservice13,Certainly more than the same clusteruserservice1、2更加慢,increased time loss,舍近而求远
So how do we set theorderservice(服务消费者)What about setting default access to services on the same cluster as yourself??
这就引出了我们的NacosRule负载均衡:
配置NacosRule负载均衡之后,Will give priority to service providers in the same cluster

注意:配置NacosRule之后,Please put the originalRibbonload balancing configuration replacement、注释或删除,不然NacosThe load balancing configuration does not take effect
在orderservice(服务消费者)配置好NacosRule负载均衡之后,It will automatically call services in the same cluster as itself,也就是userservice1和2,will not call the remote clusteruserservice3
在orderservice(服务消费者)multiple calls to the same clusteruserservice服务实例时,Random access service instance will be performed;也就是说这里的userservice1和2,会被orderservice随机访问,而3Because they are not in the same cluster,will not be given priority access.
那如果此时,同一个集群的userservice1、2服务宕机了,orderservice在调用时,When there is no service tunable in this cluster,orderservicewill call different clustersuserservice3吗?
会!但是会有警告:originally visitedHZ集群,But at this time there is a cross-cluster access,访问了SH集群的userservice3
总结:
Nacos服务实例的权重设置
边栏推荐
- The IDEA of Database plug-in Database Navigator plug-in
- TiCDC迁移-TiDB到MySQL测试
- html+css+php+mysql实现注册+登录+修改密码(附完整代码)
- es6箭头函数讲解
- MySQL database installation (detailed)
- 我和 TiDB 的故事 | 缘份在,那就终是能相遇的
- 金仓数据库 KingbaseES 客户端编程接口指南 - ODBC 驱动使用
- WordPress 编辑用户
- 金仓数据库KingbaseES客户端编程接口指南-ODBC(6. KingbaseES ODBC 的扩展属性)
- [based] GO language. Why do I have to learn Golang and introduction to the language universal
猜你喜欢
随机推荐
【云原生】微服务之Feign的介绍与使用
Container is changed | deploy MySQL cluster in the Rancher
38.【string下章】
IO流:节点流和处理流详细归纳。
BGP简单实验
[网鼎杯 2020 半决赛]AliceWebsite
3D激光SLAM:LeGO-LOAM论文解读---硬件系统部分
DVWA全级别通关教程
框架常用注解解释
TiCDC同步延迟问题处理
JS_删除数组里的无效数据 0 undefined ‘‘ null false NaN
金仓数据库KingbaseES安全指南--6.7. GSSAPI身份验证
获取list集合中重复的元素
MySQL如何对SQL做prepare预处理(解决IN查询SQL预处理仅能查询出一条记录的问题)
Navicat如何连接MySQL
Mysql stored procedures, rounding
【多线程】——深入理解线程中断方式(interrupt)
【c ++ primer 笔记】第6章 函数
金仓数据库KingbaseES安全指南--6.6. SSL客户端证书认证
网页被劫持跳转怎么办?发布网修复方法

![[Cloud native] Introduction and use of Feign of microservices](/img/39/05cf7673155954c90e75a8a2eecd96.jpg)


![[纯理论] YOLOv5](/img/c2/6569926228ce763381ab75ef8498fb.png)



