Reset quota is not working as expected in apigee

267 views Asked by At

I have applied a quota policy by using the following code

<Quota async="false" continueOnError="false" enabled="true" name="Quota-1">
    <DisplayName>Quota 1</DisplayName>
    <Allow count="2"/>
    <Interval>1</Interval>
    <Distributed>true</Distributed>
    <Synchronous>false</Synchronous>
    <TimeUnit>minute</TimeUnit>
    <Identifier ref="request.queryparam.id"/> 

    <AsynchronousConfiguration>
        <SyncIntervalInSeconds>1</SyncIntervalInSeconds>
        <SyncMessageCount>5</SyncMessageCount>
    </AsynchronousConfiguration>
</Quota>

And then i am resetting the count by using reset count policy with following code

<ResetQuota async="false" continueOnError="false" enabled="true" name="Reset-Quota-1">
    <DisplayName>Reset Quota 1</DisplayName>
    <Quota name="Quota-1">
        <Identifier ref="request.queryparam.id">
            <Allow>6</Allow>
        </Identifier>
    </Quota>
</ResetQuota>

As per my knowledge when i am giving requests the available count needs to be 6,5,4,3,2,1,0 But it is showing 1,6,11,16,21,.....

In this scenario there is no chance to count come down to 0.

What might be the wrong.

Thanks in advance....

1

There are 1 answers

0
Argo On

I see that you are using asynchronous quota by setting the to false. You also have an incorrect AsynchronousConfiguration because your SyncMessageCount (5) is greater than your Allow count (2).

What the Asynchronous Configuration really means is that the quota counters would not be updated to the backend for every request, but only at intervals of every 5 seconds, which is anyways higher than the allow count. That's the problem you are running into, and that's why you see the count increasing by a factor of 5 - 1,6,11,16,21 etc.

You need to set the sync interval to be smaller than the allow count. Also note that Async quota would not give you 100% accuracy since it only synchs the counters across multiple servers at regular intervals and not for every request.