Kong: Kong rate-limtiing plugin is not setting ttl to some keys when using redis

Created on 8 Apr 2020  路  4Comments  路  Source: Kong/kong

Summary

When tested Kong's rate-limiting plugin with redis config, found Kong is not setting TTLs for all the keys, some of the keys are having -1 ttl which is increasing the data in redis and slowing the repsonse from redis server.

Why the issue is happening:
During the increment we are checking whether the key exists in the redis or not and only setting the ttl if the key is not present in the redis.
https://github.com/Kong/kong/blob/master/kong/plugins/rate-limiting/policies/init.lua#L177

Screen Shot 2020-04-03 at 10 21 31

Steps To Reproduce

  1. Start Kong with 16 worker threads
  2. Configure rate-limiting plugin redis
  3. Make parallel calls ( I have tested using apache bench mark ab -n 10000 -c 20 http://127.0.0.1:8000/testapi

Additional Details & Logs

  • Kong version 1.2.2 ( but the plugin logic is same for 2.0.2 also)
tasbug

Most helpful comment

We can create a pr to fix this issue along with redis sentinel support in rate-limiting. Our team has ran performance tests with different configurations on rate-limiting plugin, we can also share those results along with PR.

All 4 comments

Yes, we should make that a redis function.

We can create a pr to fix this issue along with redis sentinel support in rate-limiting. Our team has ran performance tests with different configurations on rate-limiting plugin, we can also share those results along with PR.

@vasuharish, sound like a plan! I am glad to review such PR! Bring it on ;-)!

Hi @bungle , created PR for the fix, can you please take a look at the PR. thank you

Was this page helpful?
0 / 5 - 0 ratings