I configured the quota policy and attached proxy request flow for limiting the request to the proxy url
But the request which are exceeds the count in quota policy it will not throwing any error. It just
accepting the request.
<Quota name="quotaDetermination"> <DisplayName>quotaDetermination</DisplayName> <Properties/> <Interval>1</Interval> <TimeUnit>minute</TimeUnit> <Allow count="8"/> </Quota>
Solved! Go to Solution.
Hi Rajesh
According to the documentation for the Quota policy, the default settings are "non distributed" and "asynchronous".
Non-distributed means you will get one quota counter for each message processor virtual machine. Typically there are two. So you would see a maximum of 16 per minute using the setting you provided.
Asynchronous applies if Distributed = true. It means that the count is not computed synchronously amongst all the cooperating message processors. In this case, again, your Quota policy may allow more calls than configured. For example, suppose you have configured a distributed quota policy, with a limit of 10 calls. Your app has sent in, already, 8 calls. Theoretically there are two remaining. Suppose three calls arrive, all about at the same time. Two calls arrive at one message processor, which updates its own local count from 8 to 10. The MP allows both calls. One of the 3 calls arrives at the other MP. It updates its own local count from 8 to 9. It allows the call. Then, the two MPs synchronize. They then agree that in aggregate, they have allowed 11 calls. The next call that arrives will be rejected.
Both of these effects are described in the documentation. See the docs for complete details.
To get Strict enforcement, you can use Distributed=true and Synchronous = true.
This is not good for performance, though!
The best practice is to use Distributed=true and Synchronous=false, and be prepared for some "leakage" of calls at the limit.
Hi Rajesh
According to the documentation for the Quota policy, the default settings are "non distributed" and "asynchronous".
Non-distributed means you will get one quota counter for each message processor virtual machine. Typically there are two. So you would see a maximum of 16 per minute using the setting you provided.
Asynchronous applies if Distributed = true. It means that the count is not computed synchronously amongst all the cooperating message processors. In this case, again, your Quota policy may allow more calls than configured. For example, suppose you have configured a distributed quota policy, with a limit of 10 calls. Your app has sent in, already, 8 calls. Theoretically there are two remaining. Suppose three calls arrive, all about at the same time. Two calls arrive at one message processor, which updates its own local count from 8 to 10. The MP allows both calls. One of the 3 calls arrives at the other MP. It updates its own local count from 8 to 9. It allows the call. Then, the two MPs synchronize. They then agree that in aggregate, they have allowed 11 calls. The next call that arrives will be rejected.
Both of these effects are described in the documentation. See the docs for complete details.
To get Strict enforcement, you can use Distributed=true and Synchronous = true.
This is not good for performance, though!
The best practice is to use Distributed=true and Synchronous=false, and be prepared for some "leakage" of calls at the limit.
I observed one thing by default it allows 18 request per minute but what I am trying to fix it for one
request per one minute(is it possible).
yes. it is possible. did you configure it the way I described?
What have you tried? Can you show what you've done?
wish you happy new year @Dino
Yes I tried to restrict the no of requests for one are two or what ever the number we want for a particular service , Below is the code for that scenario.
<Quota name="quotaDetermination"> <DisplayName>quotaDetermination</DisplayName> <Properties/> <Interval>1</Interval> <Distributed>true</Distributed> <Synchronous>true</Synchronous> <TimeUnit>hour</TimeUnit> <Allow count="10"/> <Allow> <Class ref="request.header.sample"> <Allow class="platinum" count="10"/> <Allow class="silver" count="10"/> <Allow class="gold" count="2"/> </Class> </Allow> </Quota>
By using class type in quota policy we can configure different type of counts in one policy by using the
class name identifier we can allow the particular count.
@Rajesh Nimmada: I tried the same policy configuration which you provided and it is working as expected.
Could you please elaborate more on your requirement?
Hello @Vipul Agarwal
My requirement is that to restrict the no.of requests to a particular service. So that, I implemented the
class type in quota policy. I given name as "gold" and count="2" but one more thing we have to set the
both distributed and synchronous tags should be true for synchronizing with the next requests.
and referred the particular class as <Class ref="request.header.sample">.
Finally it accepts only 2 requests for one hour.
I don't know what happens when you specify two Allow elements. Perhaps it's undefined behavior. I think you want to use just one of them.
But you have it working now?
Please try below code and see if it is giving your expected results.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Quota async="false" continueOnError="false" enabled="true" name="quotaDetermination"> <DisplayName>quotaDetermination</DisplayName> <Properties/> <Interval>1</Interval> <Distributed>true</Distributed> <Synchronous>true</Synchronous> <TimeUnit>hour</TimeUnit> <Allow> <Class ref="request.header.sample"> <Allow count="10"/> <Allow count="5"/> <Allow count="2"/> </Class> </Allow> </Quota>
I have removed one Allow element.
Start the trace session and analyze the counter in trace sessions. Please let me know if it works.
missed some content in the above code.
please find the below code contains multiple allow statements and it corresponding count.So what ever the count you want to apply to your service you should give the class name in the header part.Here my header name is "sample"
Add Headers
and give sample ="class name(abc)".
<Quota name="quotaDetermination"> <DisplayName>quotaDetermination</DisplayName> <Properties/> <Interval>1</Interval> <Distributed>true</Distributed> <Synchronous>true</Synchronous> <TimeUnit>hour</TimeUnit> <Allow count="10"/> <Allow> <Class ref="request.header.sample"> <Allow class="xyz" count="10"/> <Allow class="abc" count="10"/> <Allow class="def" count="2"/> </Class> </Allow> </Quota>
@Dino
For testing various counts I configured multiple Allow statements. But those will be identified by the class
name. By giving the class name of the particular allow statements at the header part, based on that
corresponding count attribute the requests will be restricted.
Add Headers
and give headerName ="class name(abc)" and give request to the service
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |