当前位置:网站首页>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服务实例的权重设置
边栏推荐
猜你喜欢
随机推荐
2022 IDEA (学生邮箱认证)安装使用教程以及基础配置教程
TiDB 操作实践 -- 备份与恢复
Container is changed | deploy MySQL cluster in the Rancher
Scala 简介一
Chapter ten find and record the REST API
Interceptors and filters (3) @interface custom annotation interception
【微信小程序】一文解决button、input、image组件
[Mysql] LENGTH函数
3D激光SLAM:LeGO-LOAM论文解读---硬件系统部分
一文带你搞懂JSON和TCP/IP
Error EPERM operation not permitted, mkdir ‘Dsoftwarenodejsnode_cache_cacach两种解决办法
es6箭头函数讲解
关于栈迁移的那些事儿
Bika LIMS 开源LIMS集—— SENAITE的使用(用户、角色、部门)
金仓数据库KingbaseES客户端编程接口指南-ODBC(6. KingbaseES ODBC 的扩展属性)
投资127亿!深圳,再添一所985
mysql根据多字段分组——group by带两个或多个参数
什么是BOM
The IDEA of Database plug-in Database Navigator plug-in
torch使用总结



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





