Reset Quota not working

I have a quota policy of 2 requests per minute per clientId

and i have IncreaseQuota in FaultRules that executes on QuotaViolation error

<FaultRules>

<FaultRule name="quota-violation">

<Step> <Name>IncreaseQuota</Name> </Step>

<Condition>(fault.name == "QuotaViolation")</Condition>

</FaultRule>

</FaultRules>

but as you can in image attached

IncreaseQuota is not at all working and i get 429 error on 3rd request.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<ResetQuota async="false" continueOnError="false" enabled="true" name="IncreaseQuota"> <DisplayName>IncreaseQuota</DisplayName>

<Properties/>

<Quota name="Quota-1">

<Identifier ref="request.header.clientId">

<Allow>2</Allow>

</Identifier> </Quota>

</ResetQuota>

Solved Solved
0 3 211
1 ACCEPTED SOLUTION

@Pooja Kakani I believe your api proxy is behaving exactly how you have "coded" it but not as you "expect" it to work.

Your Quota policy is rightly triggering a fault for the 3rd request (according to your rules) and your ResetQuota policy is also getting executed (there is no skip icon in trace for that policy). However, your expectation is that since you have reset the quota the call should be successful.

However, the 3rd call has already failed. "After the failure" you have reset the quota. Now according to me, the 4th call should be successful.

I'm guessing this is not the behavior that you desire. In that case suppress the failure of the Quota policy by adding this flag

continueOnError="false" 

This will ensure that the fault is not raised immediately once the quota limit has been exceeded. Post that you can add your logic to either conditionally reset the quota and eat up the fault OR to honor the quota limit and throw a custom 429 fault.

Makes sense?

View solution in original post

3 REPLIES 3

my trace session

8389-capture.png

From the trace screenshot, I can see a red Exclamation mark on the prior policy.

Something went wrong there.

Investigate that.

@Pooja Kakani I believe your api proxy is behaving exactly how you have "coded" it but not as you "expect" it to work.

Your Quota policy is rightly triggering a fault for the 3rd request (according to your rules) and your ResetQuota policy is also getting executed (there is no skip icon in trace for that policy). However, your expectation is that since you have reset the quota the call should be successful.

However, the 3rd call has already failed. "After the failure" you have reset the quota. Now according to me, the 4th call should be successful.

I'm guessing this is not the behavior that you desire. In that case suppress the failure of the Quota policy by adding this flag

continueOnError="false" 

This will ensure that the fault is not raised immediately once the quota limit has been exceeded. Post that you can add your logic to either conditionally reset the quota and eat up the fault OR to honor the quota limit and throw a custom 429 fault.

Makes sense?