Rate limit to half when using to tyk-gateways in cluster

Hi, I’m using 2 tyk-gateway with a Redis cluster and I have a rate limit in a policy with 30 requests per second. In practice, I’m only getting 15 requests per second and I’m getting 429 when I do more. The question is because I have 2 gateways the requests per second are cut in half? Therefore in that case I should set 60 req/sec?

Hi @javiertc,

This depends on your Gateway config. As a quick response/fix, I would suggest setting "enable_redis_rolling_limiter": true in your gateway config. This provides 100% rate limiting accuracy, but at a cost.

There’s generally two approaches to implementing rate limit see a post on it here. Rate limit issue - #3 by taby

I saw that one before but I’m not clear about the tradeoffs

We rely on the quota therefore we have to guarantee that quotas are accurate but we would like to have accurate rate limit as well.

enable_redis_rolling_limiter": true will make 2 calls to Redis, therefore more memomry consumption on Redis but it will also reduce performance on the gateway?

What about enable_non_transactional_rate_limiter: true ? Does this one works when you are using multiple gateways and a redis cluster ?

No, "enable_redis_rolling_limiter":true will not reduce the performance of the gateway. The impact is on Redis as it will have to do additional processing per request.

enable_non_transactional_rate_limiter: true works regardless of the number of Gateways and Redis setup. It improves the performance of the rate limit algorithm (rolling_limiter in this case) by using Redis Pipelining.

You can have a read on it at Redis Documentation. It also talks about Round Trip Time, relevant to the tradeoff discussion.

Can I have a recommendation for my case?

Multiple gateways and a Redis cluster and I need to limit the request per second to 10. Doesn’t matter is Redis consumes a bit more.

In this case enable_non_transactional_rate_limiter: true is the way to go?

Yep.
Together with "enable_redis_rolling_limiter":true

So I have to enable both?

enable_redis_rolling_limiter":true
enable_non_transactional_rate_limiter: true

Yes, both.

enable_redis_rolling_limiter:true for 100% rate limiting accuracy
enable_non_transactional_rate_limiter:true to optimize the performance

I think this should be added to the official documentation, probably a lot of people have the same setup.

Thanks @Ubong

Btw @Ubong I’m getting this in the logs

time=“Nov 01 14:42:34” level=warning msg=“SentinelRateLimiter & RedisRollingLimiter are deprecated” prefix=checkup

enable_redis_rolling_limiter: true is deprecated?

Hi @Ubong it seems that the parameter that works is

enable_redis_rolling_limiter:true

If I remove that one it doesn’t work.

The bad part is that the parameter seems to be deprecated in version 3.2.2. Could you help me with this ?

Hi @javiertc ,

Did you have this clarified on What version of Tyk should I use, 3.x.x or 4.x.x?

enable_non_transactional_rate_limiter:true is the setting to use

Yes, I need 3.x.x. I don’t need 4.x.x because mostly it has features for the dashboard and GraphQL and I’m using the open-source version because I don’t need GraphQL.

With enable_non_transactional_rate_limiter:true doesn’t work. When I add enable_redis_rolling_limiter: true it works but I’m worried because the log says that the parameter is deprecated and I don’t want to use a feature that works but Is not supposed to work.

@javiertc I agree with your concern. I started a discussion internally to confirm the information here and will create a ticket for this to be changed. I will reply here once I have something.

Hi @zaid I hope you are well.

Any update on this?

Regards

Hi @javiertc,

Please see this PR. The deprecation warnings are being removed.