Throttling
Use the Throttling policy to smooth the rate of requests or to arrest any
spikes in the number of requests that may occur.
Example
In this example, Rate Smoothing is used to delay requests by one second after 5 requests in a minute have arrived. Also the Spike Arrest is set to reject, with a 429 status code, the 21st and greater requests in the same minute.
<throttling
name="throttling-example" displayName="throttling-example" enabled="true" version="1.0"
xmlns="http://www.infor.com/ion/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.infor.com/ion/api throttling.xsd">
<timePeriodInMilliseconds>60000</timePeriodInMilliseconds> <!-- one minute -->
<rateSmoothing>
<delayAfterCount>5</delayAfterCount>
<!-- start delaying requests after more then 5 have arrived during the same minute
-->
<delayFactorInMilliseconds>1000</delayFactorInMilliseconds> <!-- delay by a factor of 1 second -->
</rateSmoothing>
<spikeArrest>
<maxRequestsPerPeriod>20</maxRequestsPerPeriod>
<!-- Start rejecting with a 429 status requests 21, 22, etc. arriving during the same minute →
</spikeArrest>
</throttling>
Configuration
Element name | Deault | Presence | Type | Multiplicity |
---|---|---|---|---|
timePeriodInMilliseconds | n/a | Required | Positive integer | 1 |
rateSmoothing | n/a | Optional | Complex | 0..1 |
rateSmoothing.delayAfterCount | n/a | Required | Positive integer | 1 |
rateSmoothing.delayFactorInMilliseconds | n/a | Required | Positive integer | 1 |
spikeArrest | n/a | Optional | Complex | 0..1 |
spikeArrest.maxRequestsPerPeriod | n/a | Required | Positive integer | 1 |
<throttling> attributes
<throttling name="throttling-example" displayName="throttling-example" enabled="true" version="1.0”>
File name | Description | Default | Presence |
---|---|---|---|
Name | Name of this policy instance. | N/A | Required |
displayName | Optional | ||
enabled | Indicates if a policy is enforced or not. If set to false, a policy is turned off, and not enforced. | true | Optional |
Version |
Policy version. | N/A | Required |
<timePeriodInMilliseconds> element
This is the time period within which to smooth the rate or arrest the spike.
<timePeriodInMilliseconds>60000</timePeriodInMilliseconds> <!-- one minute -->
<rateSmoothing> element
Specify this element to perform rate smoothing.
<rateSmoothing>
<delayAfterCount>5</delayAfterCount>
<!-- start delaying requests after 5 have arrived during the same minute -->
<delayFactorInMilliseconds>1000</delayFactorInMilliseconds> <!-- delay by a factor of 1 second -->
</rateSmoothing>
<rateSmoothing.delayAfterCount> element
Sets the number of requests to accept in the time period before delaying any additional requests.
<delayAfterCount>5</delayAfterCount>
<rateSmoothing.delayFactorInMilliseconds> element
Sets the time (in ms) to delay any additional requests.
<delayFactorInMilliseconds>1000</delayFactorInMilliseconds>
<spikeArrest> element
Specify this element to perform Spike Arrest.
<spikeArrest>
<maxRequestsPerPeriod>20</maxRequestsPerPeriod>
<!-- Start rejecting with a 429 status requests 21, 22, etc. arriving during the same minute -->
</spikeArrest>
<spikeArrest.maxRequestsPerPeriod> element
Sets the number of allowed requests in the time period before rejecting the next request with a 429 status code.
<maxRequestsPerPeriod>20</maxRequestsPerPeriod>