SpringCloud zuul的负载均衡策略实现


application.yml

如果是多台服务器

spring:
  application:
    name: api-gateway

server:
  port: 8007
zuul:
  routes:
   user-service:
      path: /user-service/**
      serviceId: user-service2
ribbon:
  eureka:
    enabled: true
user-service2:
  ribbon:
    listOfServers: http://localhost:8003/,http://localhost:8004/

eureka:
  client:
      serviceUrl:
        defaultZone: http://localhost:8002/eureka/

在Spring Cloud Zuul中使用Ribbon 作为负载均衡器,

如果是单台机器,不使用负载均衡,配置就简单了:

spring:
  application:
    name: api-gateway

server:
  port: 8007
zuul:
  routes:
    user-service:
      path:  /user-service/**
      url:  http://localhost:8003
eureka:
  client:
      serviceUrl:
        defaultZone: http://localhost:8002/eureka/


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM