request.rate_limit()
method to implement rate limiting:
request.limit_rate
instead:
true
if the count of requests (4) under the granularity (8) with the filters (1, 2, 5, 6, 7, 9) exceeds the limit for a given time (3).
Parameter name | Required | Description | |
---|---|---|---|
1 | ip | False | List of IP addresses that the rule applies to. If there are no IPs in the list, counting will be done for all IPs. |
2 | url | True | A regex pattern used to match the request’s URI (URL + query_params). |
3 | time | True | The time limit, in seconds, within which we only allow n number of requests to URI matching the pattern. |
4 | requests | True | The maximum number of requests accepted within the given period before an action is taken (minimum value is 20 requests). |
5 | method | False | List of method types the request aggregation will be applied to. |
6 | status_code | False | List of status codes the request aggregation will be applied to. |
7 | content_type | False | Regex pattern to match request content_types against. |
8 | scope (granularity) | False If the granularity isn’t set to cluster , the default aggregation will be set to cluster . | The cluster scope counts all the traffic of a POP:- Interval counting is made on each POP separately. This can cause unsynchronized counting. - IP counting can be counted separately on different POPs (each request individually, not overlapped). - POPs could be related to certain locations, which means that some clients may never be addressed to certain POPs - The cluster scope counts traffic per given IP. |
9 | tag | False | Aggregation of tagged (user-defined tags) requests will be applied for each IP. |
request.ip in ['1.2.3.4']
and request.rate_limit([], '', 5, 200, [], [], '', 'ip')
, the rate limit will count requests per interval for every IP. However, it will set an action only when 1.2.3.4 exceeds the number of requests.
This behavior is linked to the rule you are creating, not the rate limit condition. Thus, even with a blank IP list and an embedded IP condition, the rate limit will still count requests for all IPs.