Skip to content

Key-based Local Rate Limiting

Functional Description

The key-rate-limit plugin implements rate limiting based on specific key values, which can originate from URL parameters or HTTP request headers.

Running Properties

Plugin execution phase: default phase Plugin execution priority: 10

Configuration Fields

NameData TypeRequiredDefault ValueDescription
limit_by_headerstringOptional, choose one from limit_by_header, limit_by_param-Configuration for the source of the rate limiting key value (HTTP request header name)
limit_by_paramstringOptional, choose one from limit_by_header, limit_by_param-Configuration for the source of the rate limiting key value (URL parameter name)
limit_keysarray of objectRequired-Configuration for the rate limiting frequency based on matched key values

Explanation of each configuration field in limit_keys

NameData TypeRequiredDefault ValueDescription
keystringRequired-Matched key value
query_per_secondnumberOptional, choose one from query_per_second, query_per_minute, query_per_hour, query_per_day-Allowed number of requests per second
query_per_minutenumberOptional, choose one from query_per_second, query_per_minute, query_per_hour, query_per_day-Allowed number of requests per minute
query_per_hournumberOptional, choose one from query_per_second, query_per_minute, query_per_hour, query_per_day-Allowed number of requests per hour
query_per_daynumberOptional, choose one from query_per_second, query_per_minute, query_per_hour, query_per_day-Allowed number of requests per day

Configuration Examples

Identify request parameter apikey for differentiated rate limiting

limit_by_param: apikey
limit_keys:
- key: 9a342114-ba8a-11ec-b1bf-00163e1250b5
query_per_second: 10
- key: a6a6d7f2-ba8a-11ec-bec2-00163e1250b5
query_per_minute: 100

Identify request header x-ca-key for differentiated rate limiting

limit_by_header: x-ca-key
limit_keys:
- key: 102234
query_per_second: 10
- key: 308239
query_per_hour: 10