API Based Quota Implementation - Fixed Time Intervals
In this scenario, the application of API Based Quota policy to the Mock API created on Apinizer will be tested.
A quota policy limits the total number of requests that can be made in a given time period. This policy is often used to provide longer term usage control (for example,allowing 1000 requests to a specific user in a day or a month).
In the scenario, we can limit incoming requests to 100 requests in a 1 day period.
Create a mock api instance and add the policy.
We add API Based Quota as a policy.
In the scenario, let's limit the incoming requests to 100 requests for 1 day using the Fixed Window method.
If the period is set to 1 and the day is selected:
For example, if the policy is saved at 12:00:00:00, it will be valid from 00:00:00 to 23:59:59 on the current day.
The next day at 00:00:00 a new window will start and the counter will be reset.
Field
Description
Message Count
The number of requests allowed. In this scenario we set it to 100.
Interval Time Amount
It is the period determined according to the selected time unit. In this scenario, we set it as 1.
Interval Time Unit
Unit of time. In this scenario we set it as a day.
Interval Window Type
Method used to implement the time interval. Time periods of 1 day of type Fixed.
Cache Connection Timeout (Second)
Specify the connection timeout value for the connection between the policy and the cache.
If there is a connection problem with the cache, return an error (select Fail ) or continue without applying the request constraint (select Continue ).
When we make a sample request from the test console, the message is blocked because the constraint limit is reached after the 100th request in the time range 00:00:00 and 23:59:59 on the current day.