Rate Limiter
This policy limits the number of API invocations during a specified time interval, and sends alerts to a specified destination when the performance conditions are violated. You can use this policy to avoid overloading the back-end services and their infrastructure, to limit specific clients in terms of resource usage, and so on.
The Throttling policy generates two types of events when the specified limit is breached:
- Policy violation event. Indicates the violations that occur for an API. If there are 100 violations, then 100 policy violation events are generated.
- Monitor event. Controlled by the alert frequency configuration specified in the policy.
In API Studio, this policy is identified by the kind RateLimiter
.
Here is a sample code for the Throttling policy.
kind: RateLimiter
apiVersion: api.webmethods.io/beta
metadata:
name: rate-limiter
version: 1.0
namespace: sample
tags:
- traffic_optimization
spec:
enabled: true
maxLimit: 20
applications:
- "Each-applications"
applicationSpecific: true
alert-configuration:
interval: 2m # m,h,d,w,cw, cm are possible values
frequency: always # Other possible value is 'once'
message: 'Throtting reached!'
destinations:
- self
- dev_portals :
- portal 1
- portal 2
- email:
- nas@sag.com
- daso@sag.com
- snmp
- jdbc
- log-file:
level: info
The structure in the code view and what it denotes is as follows.
Type | Description |
---|---|
kind | RateLimiter. This denotes the asset type, Throttling policy. |
apiVersion | This denotes the API version of the API on which this policy is enforced. |
metadata | This denotes the metadata or details of the asset type. It covers the following metadata:
|
spec | This denotes various policy properties you can configure for the policy. You can
configure the following policy properties:
|