Protects against traffic spikes by throttling the number of requests processed by an API proxy and is sent to a backend, 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 app or client. Use Identifier logically with the attribute 'Weight' to throttle requests by specific clients or apps. |
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 and then use it in the subsequent parts of the flow.
Configure the Spike Arrest policy as per the below configuration:
- Rate: 10/minute
Quota Identifier:
- Type: CONTEXT_VARIABLE
- Variable Name: api.developer.id (The ID of the consumer making the request)
- Default Value: default (can be 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.