Rate Limiting
server/rate_limiting
Specifies the global configuration related to rate limiting. Rate limiting policies are defined using the policies/rate_limiting[] entry.
Additional rate limiting headers can also be enabled. The rate limiting response headers include:
header | value |
---|---|
X-Rate-Limit-Policy | The name of the rate limiting policy which is closest to being hit. |
X-Rate-Limit-Remaining | The number of requests left for the rate limiting policy in the current rate limit window. |
X-Rate-Limit-Reset | The time (UTC Epoch time) at which the rate limiting policy resets. |
Properties
Name | Type | Constraints | Description |
---|---|---|---|
cache_size | number | Minimum: 1 Maximum: unlimited Default value: 16384 | The number of unique records to cache locally for the rate limiting capability. When this cache is exhausted, the oldest cached records are ejected. This effectively resets the rate limiting counters for this client(s). This number needs to be higher than the number of requests being rate limited across a refresh interval. |
redis | redis | ||
response_headers | boolean | Values: true or false Default value: false | Specifies whether or not the gateway will insert the rate limiting headers into responses. By default, the rate limiting response headers are disabled. |
server/rate_limiting/redis
These entries control whether or not rate limiting data will be stored in a Redis database. When stored in a Redis database, rate limiting data can be shared across multiple gateway instances.
Properties
Name | Type | Constraints | Description |
---|---|---|---|
collection_name | string | Specify the name of a Redis collection which will be used for maintaining rate limiting data. Redis collections are defined using the services/redis[] entry. | |
sync_window | number | Minimum: 0 Maximum: unlimited Default value: 5 | The length of time (in seconds) a record from Redis will be cached locally by this instance. Records will only be synchronized with Redis after this window has elapsed. |
Example
server:
rate_limiting:
cache_size: 16384
response_headers: false
redis:
collection_name: test-collection
sync_window: 10
Updated 5 months ago