Sharing Routes between multiple Gateway instances

Spring Cloud Gateway 提供了两种 RouteDefinitionRepository 实现。第一个是 InMemoryRouteDefinitionRepository,它只存在于一个 Gateway 实例的内存中。这种类型的仓库不适合用于跨多个 Gateway 实例填充路由。

Spring Cloud Gateway offers two RouteDefinitionRepository implementations. The first one is the InMemoryRouteDefinitionRepository which only lives within the memory of one Gateway instance. This type of Repository is not suited to populate Routes across multiple Gateway instances.

为了跨 Spring Cloud Gateway 实例集群共享路由,可以使用 RedisRouteDefinitionRepository。要启用这种类型的仓库,必须将以下属性设置为 true:spring.cloud.gateway.redis-route-definition-repository.enabled。与 RedisRateLimiter Filter Factory 类似,它需要使用 spring-boot-starter-data-redis-reactive Spring Boot Starter。

In order to share Routes across a cluster of Spring Cloud Gateway instances, RedisRouteDefinitionRepository can be used. To enable this kind of repository, the following property has to set to true: spring.cloud.gateway.redis-route-definition-repository.enabled Likewise to the RedisRateLimiter Filter Factory it requires the use of the spring-boot-starter-data-redis-reactive Spring Boot starter.