Thapld
Thapld

Reputation: 37

Spring cloud gateway redis rate limiter don't work

I cannot play with ratelimiter of spring cloud gateway. Here I config gateway:

spring:
  cloud:
    gateway:
      discovery:
        locator:
          enabled: true
      routes:
      #Admin
      - id: haft-upms-admin
        uri: lb://haft-upms-admin
        predicates:
        - Path=/admin/**
        filters:
        - name: RequestRateLimiter
          args:
            key-resolver: '#{@remoteAddrKeyResolver}'
            redis-rate-limiter.replenishRate: 1
            redis-rate-limiter.burstCapacity: 1
        - name: Hystrix
          args:
            name: default
            fallbackUri: 'forward:/fallback'

I use JMeter to call API loop 1000 times but gateway not response 429 too many request in response. Where I wrong?

Upvotes: 0

Views: 1436

Answers (1)

JIANPO LI
JIANPO LI

Reputation: 1

Firstly, your access url are wrong, which can not match route id:haft-upms-admin, so can not invoke redis RequestRateLimiter. You can see debug log like: enter image description here, you can check if match route id.

Secondly, you can read my config file: enter image description here

Path is:localhost:xxxx/eureka-client/XXXX will forward to my service eureka-client and match route id my_coute1, so you can refer to my sample all in all, you must match you route id.

Upvotes: -2

Related Questions