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/
人生若只如初见,浮沉繁华,慕然回首,不过过眼云烟。
我只在红尘中争渡,即便是一朵浪花,亦奋勇向前。