context_limiter

context_limiter #

Description #

The context_limiter filter is used to control the traffic based on request context.

Configuration Example #

A configuration example is as follows:

flow:
  - name: default_flow
    filter:
      - context_limiter:
          max_requests: 1
          action: drop
          context:
            - _ctx.request.path
            - _ctx.request.header.Host
            - _ctx.request.header.Env

The above configuration combines three context variables (_ctx.request.path, _ctx.request.header.Host, and _ctx.request.header.Env) into a bucket for traffic control. The allowable maximum queries per second (QPS) is 1 per second. Subsequent requests out of the traffic control range are directly denied.

Parameter Description #

NameTypeDescription
contextarrayContext variables, which form a bucket key
intervalstringInterval for evaluating whether traffic control conditions are met. The default value is 1s.
max_requestsintMaximum request count limit in the interval
max_bytesintMaximum request traffic limit in the interval
actionstringProcessing action after traffic control is triggered. The value can be set as retry or drop and the default value is retry.
statusstringStatus code returned after traffic control conditions are met. The default value is 429.
messagestringRejection message returned for a request, for which traffic control conditions are met
retry_intervalintInterval for traffic control retry, in milliseconds. The default value is 10.
max_retry_timesintMaximum retry count in the case of traffic control retries. The default value is 1000.
failed_retry_messagestringRejection message returned for a request, for which the maximum retry count has been reached