dream11 / kong-scalable-rate-limiter

Kong plugin for Rate Limiting at high throughputs.
https://dream11.github.io/kong-scalable-rate-limiter/
MIT License
40 stars 10 forks source link

Questions on batch-redis plugin setup with redis cluster #15

Open chaitanya14 opened 1 year ago

chaitanya14 commented 1 year ago

Hi Team,

Firstly, Thanks for the plugin. Can you please help me in answering below questions ?

1) Doesn't this plugin work with password authenticated redis-cluster ? As i am getting below errors related to auth failure.

2022/12/09 22:43:54 [error] 2090#0: 8567 [lua] rediscluster.lua:238: fetch_slots(): failed to fetch slots: NOAUTH Authentication required.;NOAUTH Authentication required., context: ngx.timer, client: 10.240.1.209, server: 0.0.0.0:8443 2022/12/09 22:43:54 [error] 2090#0: 8567 [kong] connection.lua:96 failed to connect to Redis: nil, context: ngx.timer, client: 10.240.1.209, server: 0.0.0.0:8443

2) How to verify if this plugin is actually using redis-cluster instead of local cache ?

Plugin Config: {"name":"scalable-rate-limiter","config":{"redis_keepalive_timeout":60000,"redis_pool_size":4,"second":null,"redis_send_timeout":100,"hour":null,"redis_max_redirection":2,"redis_max_connection_attempts":2,"redis_backlog":1,"policy":"batch-redis","redis_port":6379,"redis_host":"redis-cluster-0.redis-cluster-headless.redis-cluster.svc.cluster.local","day":null,"batch_size":2,"limit_by":"service","redis_connect_timeout":200,"minute":5,"redis_read_timeout":100,"error_message":"API rate limit exceeded","header_name":null},"created_at":1670625790,"service":null,"route":{"id":"0abbce6b-f987-494b-96bb-38f9ae43dde2"},"protocols":["grpc","grpcs","http","https"],"consumer":null,"id":"ed409aa0-27b1-42b1-8359-9e59ac4c44ac","tags":null,"enabled":true}

Kong Version: 2.8.1

chirag-manwani commented 1 year ago

Hi @chaitanya14 ,

  1. You are right, the plugin does not support authentication with Redis yet. But on a closer look, it looks like the client we use does provide support for the same.
  2. To verify you can check for the keys in Redis cache and its value. Also if you have multiple nodes, your actual rate limit would be limit * number of nodes, since the policy is local so the counter is not shared.

I see that you have already raised a PR for 1. I'll verify the change once and let you know.

jeremyjpj0916 commented 1 year ago

I also added an enhancement that should allow us to resolve hostnames if IP is not specified similar to how Kong deals in DNS: https://github.com/dream11/kong-scalable-rate-limiter/pull/17

cc @chaitanya14 @chirag-manwani