Protects against traffic spikes by throttling the number of requests processed by an API proxy. The requests are sent to the backend, thereby protecting against performance lags and downtime.
Configuration
The properties that have to be configured to use the policy are described below.
Figure 1: Spike Arrest Policy Configuration attributes
Property | Description |
---|---|
Rate | Specifies the number of requests that are allowed per second/minute/hour (select from the drop-down) intervals. |
Identifier | Variable used for uniquely identifying the application or client. Use Identifier logically with the attribute 'Weight' to throttle requests by specific clients or applications. |
Weight | Specifies the weighting defined for each message. Message weight is used to modify the impact of a single request on the calculation of the Spike Arrest limit. Message weight can be set by variables based on HTTP Headers, Query Parameters, or Message Body content. |
Example
Context Variables provide a way to store temporary data inside a flow so as to use in the subsequent parts of the flow.
Configure the Spike Arrest policy as per the configuration below:
- Rate: 10/minute
Quota Identifier:
- Type: CONTEXT_VARIABLE
- Variable Name: api.developer.id (ID of the consumer making the request)
- Default Value: default (any value)
- Weight:
- Type: PARAMETER
- Name: weight (The name of the query parameter which needs to be used as the identifier)
- Default Value: 2
Figure 3: Spike Arrest policy configured with values as provided in the Example
This Policy configuration works in the following ways:
- Allows only 5 (Rate/Weight) requests to be processed per minute. If 5 requests are sent in a second, they are divided in the time interval (1 minute) specified. 1 request is processed in every 12 seconds (60 Seconds/5 requests).
- If more than 5 requests are sent within the time interval specified (1 minute), only 5 requests will be processed in a minute and the extra set of requests (maximum 5 requests) will be processed in the next minute and so on.