Quota Counter Not consistent

ateebshaik
Participant III

I have a quota policy to limit the count of users set for 5 every hour with an identifier set as hour . The counter sometimes allows more that 5 requests and sometimes it limits to 5 . I have already set the distributed and sync to true. Any suggestions why this behaviour . My policy config is below

9656-screen-shot-2020-02-12-at-124237-pm.png

Note:Counter values are fetched from KVM and currently set to 5.

0 4 345
4 REPLIES 4

ateebshaik
Participant III

@Anil Sagar @ Google Any suggestions

Yes. the reason is: The Quota is eventually consistent. The "Distributed" quota is working as expected. While "Synchronous" is present, I believe that option may be disabled. The problem is, a synchronous quota is very heavy for the quota bucket storage system. Instead of synchronous, transactional updates, the quota counts are "eventually consistent." I believe the synch interval is something like "every 10 seconds", but that a large number of requests may accelerate the synch.

So if your clients send 4 requests in the first 59 minutes, then 10 requests in the next 10 seconds, the quota policy may allow 5, 6, 7, or 8 requests. Eventually it will stop the inbound requests.

You should not think of the Quota as a transactional, fully synchronous policy. That's not what it is intended to do. If you need that, you may need to build your own quota backend.

Hi Dino , Thanks for the answer, i wonder if the above explanation works it should work on every hour/identifier (i.e in my case hour ex 10,11,12) .But my quota policy works absolutely fine all the hours except at 2:00 it resets the quota (Which is expected as identifier has changed from 1:00 to 2:00) but every day at 2:05 the quota resets and i get 5 more requests allowed. The same behaviour is found at 4:00 and 4:05 as well .

Not applicable

You have used quota type flexi.

This works in a separate way. You cannot calculate this with your clock time 1pm or 2pm or 4pm.

In the case of flexi the count of 1hour starts at the first request. So, one hour is calculated from the first request to 1 hour.

For example, if your first request served ar 2.05pmm then the quota reset will happen at 3.05pm not at 3pm.

That is the reason you are seeing sometimes more or less counts in the clock hours. I would suggest if you want to calculate as per clock hours just remove the type parameter. The default type will wokr with clock hour.