Configuration reference
The Traffic Policy configuration reference for this action.Supported phases
on_http_request
Type
rate-limit
Configuration fields
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 thebucket_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.
Multiple buckets
If multiplebucket_key values are specified, the action will create a
unique rate limit bucket for each combination of the specified keys. For
example, if you have two bucket_key values, such as req.host and conn.client_ip,
all incoming requests that have the exact same combination of Host header and client IP
will be grouped into the same rate limit bucket. To rate limit separately with two different
buckets, you can create multiple rate-limit actions instead.
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 Requestsstatus code. - The
retry-afterheader is included in the response, indicating the number of seconds after which the request may be retried.
Capacity per ingress server
Currently, thecapacity 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.
Non-terminating action
This is a Non-terminating action. It does not return a response, and will allow Traffic Policy processing to continue to the next Action in the chain. All Cloud Endpoint Traffic Policies must end with a terminating action. This requirement does not apply to Agent Endpoints.Examples
Rate limit by host header
The following Traffic Policy configuration demonstrates how to use therate-limit action to rate limit
all incoming requests by the Host header.
Example Traffic Policy document
Example request
httpbin.ngrok.app using the curl
command returns a 429 status code with a retry-after header indicating
the number of seconds to wait before retrying the request.