We have multiple proxy endpoints
https://slot1.org009.t-dev.xyz.com/v1/data-ingestion/hack
https://slot1.org009.t-dev.xyz.com/v1/data-ingestion/abc
Basically for each proxy endpoint we have different time unit like hour, minute and day
Now we have a requirement to set quota policy for hack 100 request/hour and for abc 50 request/minute.
How we can set different time unit in single quota policy.?
I tried following but it didn't work for hour it is calculating based on minute only
<Quota async="false" continueOnError="false" enabled="true" name="validate_quota" type="rollingwindow"> <DisplayName>validate_quota</DisplayName> <Properties/> <Interval>1</Interval> <TimeUnit>minute</TimeUnit> <Allow> <Class ref="request.uri"> <Allow class="/v1/data-ingestion/hack" count="3500" interval="1" timeunit="hour"/> <Allow class/v1/data-ingestion/abc" count="370" interval="1" timeunit="minute"/> </Class> </Allow> <Distributed>true</Distributed> <Synchronous>true</Synchronous> </Quota>
Is there any way to set different time unit in single quota policy?
No,. you cannot set a distinct timeunit per Class.
But if you are really using the request.uri as the way to vary the quotas, then... just include the quota inside a conditional flow.
<Flow name="f1"> <Request> <Step> <Condition>request.uri = "/v1/hack"</Condition> <Name>QuotaHack-1</Name> </Step> <Step> <Condition>request.uri = "/v1/abc"</Condition> <Name>QuotaNormal-1</Name> </Step> </Request>
...and then in the distinct Quota policies, specify the limits you want, 100/hr or 50/minute or etc.
you can also set the variables in a javascript policy using the path conditions and later in a quota policy use the variables as reference.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |