Rate Limit
Overview
The Rate Limit Traffic Policy action enables you to configure thresholds that restrict the throughput of traffic that successfully reaches your endpoint.
Traffic may be limited overall or by attributes of the incoming requests.
Configuration Reference
The Traffic Policy configuration reference for this action.
Supported Phases
on_http_request
, on_http_response
Type
rate-limit
Configuration Fields
namestringRequired
A name for this rate limit configuration. Must be less than
1024
characters.algorithmenumRequired
The rate limit algorithm to be used.
- Supported values
sliding_window
capacityintegerRequired
The maximum number of requests allowed to reach your upstream server.
The minimum capacity is
1
and the maximum capacity is2,000,000,000
.ratestringRequired
The duration in which events may be limited based on the current capacity. Must be specified as a time duration that is a multiple of ten seconds (e.g.,
"90s"
,"10m"
).The minimum value is
"60s"
and the maximum value is"24h"
.bucket_keyarray of stringsRequired
The elements of this collection define the unique key of a request to track the rate at which the capacity is being met.
- Supported values
req.host
- The Host of the request.conn.client_ip
- The client IP address.req.headers['x-example-header-name']
- The value for the specified header key, if it exists.getReqHeader('X-Example-Header-Name')
- The value for the specified header key, if it exists.
Up to ten bucket keys can be specified.
Behavior
Determining the Rate Limit Bucket
When this action is executed, information from the incoming HTTP request is
used to determine which rate limit bucket the request falls into. Each bucket
is defined by specific criteria through the bucket_key
configuration field
such as client IP, request host, or a header value.
If the bucket has not exceeded its capacity, the request proceeds to the next action in your policy configuration.
Rate Limit Exceeded
If the identified bucket has received more events than its capacity over the specified duration:
- The request is rejected with an
HTTP 429 — Too Many Requests
status code. - The
retry-after
header is included in the response, indicating the number of seconds after which the request may be retried.
Capacity per Ingress Server
Currently, the capacity
for each rate limit bucket is applied per ingress
server. This means that each server independently tracks the number of requests
and enforces the rate limits accordingly.
Examples
Rate Limit by Host Header
The following Traffic Policy
configuration demonstrates how to use the rate-limit
action to rate limit
all incoming requests by the Host
header.