Spring Cloud Gateway 5 权重路由

Spring Cloud Gateway 权重路由

使用场景:需要多版本服务控制的时候,需要对服务进行权重路由,最常见的场景就是一个服务有两个版本V1,V2,在线上灰度的时候,需要忘光动态实时推送路由的权重信息,如95的流量到V1,5的流量到V2.

spring:
  cloud:
    gateway:
      routes:
      - id: service1_v1
        uri: http://localhost:8081/v1
        predicates:
        - Path=/test
        - Weight=service1, 95
      - id: service1_v2
        uri: http://localhost:8081/v2
        predicates:
        - Path=/test
        - Weight=service1, 5

Weight=service1, 5 是权重设置

posted @ 2020-06-16 14:11  路迢迢  阅读(1457)  评论(0编辑  收藏  举报