spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

RequestRateLimiter filter run unnormal

Open wzwdev opened this issue 8 years ago • 4 comments

I request http://../demo/1,the console ouput normal,but redis monitor not generates key,the rate limiter run unnormal??

#http请求为lb://前缀 + 服务id;ws请求为lb:ws://前缀 + 服务id;表示将请求负载到哪一个服务上
spring.cloud.gateway.routes[0].uri=lb://bizservice-demo
#断点表达式匹配:数组形式
spring.cloud.gateway.routes[0].predicates[0]=Path=/demo/**
#第1个过滤器:限流过滤器
spring.cloud.gateway.routes[0].filters[0].name=RequestRateLimiter
# 令牌桶的容量,允许在一秒钟内完成的最大请求数
spring.cloud.gateway.routes[0].filters[0].args.redis-rate-limiter.burstCapacity=10
# 允许每秒处理多少个请求(按照key-resolver的规则生成请求限制)
spring.cloud.gateway.routes[0].filters[0].args.redis-rate-limiter.replenishRate=10
spring.cloud.gateway.routes[0].filters[0].args.key-resolver=#{@ipKeyResolver}

#限流
spring.redis.host=127.0.0.1
spring.redis.port=6379


<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis-reactive</artifactId>
        </dependency>
  /**
     * ip限流
     * @return
     */
    @Bean
    public KeyResolver ipKeyResolver() {
        return exchange -> Mono.just(exchange.getRequest().getRemoteAddress().getHostName());
    }

wzwdev avatar Aug 13 '18 02:08 wzwdev

I change the redis version to 3.2.100,it run normal,The the rate limiter support which version of redis?

wzwdev avatar Aug 13 '18 05:08 wzwdev

What version were you using originally?

spencergibb avatar Jan 28 '19 17:01 spencergibb

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-projects-issues avatar Feb 04 '19 17:02 spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

spring-projects-issues avatar Feb 11 '19 17:02 spring-projects-issues