一、定义

  1. Ribbon是请求的负载均衡器,它为我们提供了几种负载均衡算法:轮询、随机等。

二、配置  

spring:
  cloud:
    loadbalancer:
      retry:
        enabled: true # 开启Spring Cloud的重试功能
user-service:  #单个服务,增加服务名,全局配置,不需要服务名
  ribbon:
    ConnectTimeout: 250 # 连接超时时间
    ReadTimeout: 1000 # 数据读取超时时间
    OkToRetryOnAllOperations: true # 是否对所有操作都进行重试
    MaxAutoRetriesNextServer: 1 # 切换实例的重试次数
    MaxAutoRetries: 1 # 对当前实例的重试次数
NFLoadBalancerRuleClassName: com.netflix.loadbalancer.RandomRule #负载均衡策略,随机策略

三、参考链接

相关文章:

  • 2021-11-01
  • 2021-08-11
  • 2021-12-14
  • 2022-01-16
  • 2021-04-06
  • 2021-09-27
  • 2021-07-26
猜你喜欢
  • 2021-11-06
  • 2021-05-25
  • 2022-12-23
  • 2022-01-05
  • 2021-12-09
  • 2021-05-10
  • 2021-12-30
相关资源
相似解决方案