简体   繁体   English

spring云网关如何实现Redis限速?

[英]How to implement the Redis Rate Limiting in spring cloud gateway?

I am trying to set up the rate-limiting in a spring cloud gateway.我正在尝试在 spring 云网关中设置速率限制。

I tried to configure the filter in the application.yaml as below我尝试在 application.yaml 中配置过滤器,如下所示

filters:
    - name: RequestRateLimiter
      args:
         redis-rate-limiter.replenishRate: 1
         redis-rate-limiter.burstCapacity: 5

I am getting the below error我收到以下错误

java.lang.IllegalArgumentException: Unable to find GatewayFilterFactory with name RequestRateLimiter

How to implement the rate limit in the spring cloud gateway? spring云网关如何实现限速?

One of the possibilities is not including the following dependency (the mistake which I did first time)一种可能性是不包括以下依赖项(我第一次犯的错误)

org.springframework.boot:spring-boot-starter-data-redis-reactive

Since the args contain redis-rate-limiter this dependency is must.由于args包含redis-rate-limiter这个依赖是必须的。

Below is a screenshot from the IDE showing RequestRateLimiterGatewayFilterFactory getting added when the above dependency is included.下面是 IDE 的屏幕截图,显示在包含上述依赖项时添加了RequestRateLimiterGatewayFilterFactory

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM