nacos service classification, load balancing, weight, environment isolation

Divide the cluster configuration

step


spring:  
  application:  
    # user服务的服务名称  
    name: userService    
  cloud:  
    nacos:  
      server-addr: localhost:8848 # nacos服务地址  
      discovery:  
	    # 配置集群名称 自定义
        cluster-name: SH

After the default setup, the load balancing strategy is adopted. If you want to set priority access in the same cluster, configure the code in the service caller as follows


userservice:  
  ribbon:  
    NFLoadBalancerRuleClassName: com.alibaba.cloud.nacos.ribbon.NacosRule # 指定Nacos策略

Service instance weight setting

Instance Weight Control

  1. The Nacos console can set the weight value of the instance, between 0 and 1
  2. For multiple instances in the same cluster, the higher the weight, the higher the frequency of access
  3. If the weight is set to 0, it will not be accessed at all

environmental isolation

  1. You can create a namespace in the Nacos console to isolate different environments

Guess you like

Origin blog.csdn.net/Quiet_tomcat/article/details/124267626