Ribbon:结合restTemplet实现轮训调用(负载均衡)
负载均衡就是往注册中心注册相同的东西?
当向注册中心注册时候
服务端
server:
port: 8761
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/
registerWithEureka: false
fetchRegistry: false
server:
enable-self-preservation: false
Spring:
application:
name: eureka
注册端1号
server:
port: 8081
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/
Spring:
application:
name: client #名字要注意
注册端2号
server:
port: 8082
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/
Spring:
application:
name: client #名字要注意
发现端口不同但是以同一个名字注册进去了:
于是启用远程调用的时候:
ribbon被触发了
ribbon是轮训算法会来回交替使用具有相同名称的服务
结合第三种restTemplet远程调用实现了:负载均衡