Syvizo

Set Quota



When to use

Use this policy when you want to limit the maximum number of requests. 



Details

There are situations when you want to limit the maximum number of requests for an endpoint. This may due to various reasons including the processing capacity of the backend API, assigned quota to a set of users based on their privileges, business requirements to set such limits etc.


Quota defines the maximum number of requests that will be accepted over a period of time. 

You can set the time window in units of minutes, hour, day, week or month and specify the count. The other field to set is the “Allow Count” that defines the maximum number of requests.


For example, if you set 10 in field “Interval”, “minute” in “Time Unit” and 50 in “Allow Count”, then a maximum of 50 requests will be accepted over a period of 10 minutes. If 51st request is received in the time interval, in this case in 10 minutes, it will be rejected with a response status code 429 and message “Too Many Requests”.



Configuration

The configuration fields for the policy are:

[* Indicates a mandatory field]

Name *: Display name of the policy

Description: Description of policy

Enabled: Flag to indicate if the policy is enabled. If this field is not checked, the policy will be ignored at runtime and any fields from its output will contain a default initial value

Continue on Error: Flag to indicate that the flow should continue even if this policy throws an error

Interval*: Specifies the time duration of keeping the count of requests 

Time Unit*: Unit of time. The options are minutes, hours, days, weeks, months

Allow Count*: Maximum requests that are allowed

Request Weightage: Specifies the number by which the counter will increase. This is used when you want to count requests based on any parameter of request for example method type or a parameter value. By default the value is 1

Start Date: Specifies the date when the policy should start. The date format is dd/mm/yyyy.

Start Time: Specifies the time when the policy should start .Time format is HH:mm:ss



Input fields

inputIdentifier: This field can be used to classify requests based on any parameter. For example, if you want to allow a different quota for a user, you can set the username as inputIdentifier.  

groups: Groups is repeating field and contains two sub-fields. 

groups/identifier: These field matches the inputIdentifier 

groups/quota: This quota is applied to the request that contains field inputIdentifier and matches with corresponding identifier field. To understand this, suppose the group is set with 3 set of values: {identifier: id1, quota: 10}, {identifier: id2, quota: 20} and {identifier: id3, quota: 50} and a request field “reqField” mapped to input field “inputIdentifier”.

If a request has value “id3” in the field that is mapped to “inputIdentifier”, a quota of 50 will be applied. If the request field “reqField” contains value “id1”, the the quota of 10 will be applied. If the field does not match to any of the identifier elements set, then the quota will be applied from the value specified in policy configuration.



Output fields

quotaUsed: The count of requests received so far

resetTime: The date and time when the counter will reset


The output values are given for the group based on the input. In above example, if the request received maps to setting with identifier “id2”, then the output values will be for the data corresponding to this identifier.