All Products
Search
Document Center

Alibaba Cloud Service Mesh:ASMLocalRateLimiter CRD fields

Last Updated:Mar 11, 2026

ASMLocalRateLimiter is a CustomResourceDefinition (CRD) that you can use to declaratively define local rate limiting configurations in Service Mesh (ASM).

How it works

ASMLocalRateLimiter uses a token bucket algorithm to control request rates:

  1. Each Envoy proxy maintains a token bucket with a configured number of tokens (quota).

  2. Tokens are replenished at a regular interval (fill_interval).

  3. If no tokens are available, the request is rejected with HTTP status 429 (configurable).

By default, all worker threads within a single Envoy process share one token bucket. Set per_downstream_connection to true to allocate a separate bucket per connection.

Important

The quota value applies to a single Envoy instance. If you have *n* gateway instances, the effective rate limit for backend services is *n* x quota. Recalculate quotas whenever you scale the number of instances.

CRD structure overview

This skeleton shows how fields nest within the CRD:

apiVersion: istio.alibabacloud.com/v1beta1   # or v1
kind: ASMLocalRateLimiter
metadata:
  name: <rule-name>
  namespace: <namespace>
spec:
  workloadSelector:
    labels:
      <label-key>: <label-value>
  isGateway: true | false
  configs:
    - name: <config-name>
      match:
        vhost:
          name: <virtual-host-name>
          port: <port>
          route:
            name_match: <route-name>
      limit:
        status: <http-status-code>
        fill_interval:
          seconds: <int>
          nanos: <int>
        quota: <int>
        per_downstream_connection: true | false
        custom_response_body: <string>
        response_header_to_add:
          <header-name>: <header-value>
      limit_overrides:
        - request_match:
            header_match:
              - name: <header-name>
                exact_match: <value>
            query_match:
              - name: <param-name>
                exact_match: <value>
          limit:
            fill_interval:
              seconds: <int>
            quota: <int>

Configuration example

The following example applies rate limiting to an ingress gateway. Two virtual hosts receive different limits: www.example1.com at 10 requests per second, and www.example2.com at 100 requests per second.

Expand to view the YAML content

apiVersion: istio.alibabacloud.com/v1beta1
kind: ASMLocalRateLimiter
metadata:
  name: for-api-test
  namespace: default
spec:
  workloadSelector:
    labels:
      app: istio-ingressgateway
  isGateway: true
  configs:
    - match:
        vhost:
          name: "www.example1.com" # If multiple vhosts are configured on the gateway, enter the name of the last vhost.
          port: 80
          route:
            name_match: "test1" # The name of the route that is configured for the virtual service. If the virtual service does not have the specified route, the rate limiting does not take effect.
      limit:
         fill_interval:
            seconds: 1
         quota: 10
    - match:
        vhost:
          name: "www.example2.com"
          port: 80
          route:
            name_match: "test1"
      limit:
         fill_interval:
            seconds: 1
         quota: 100

Supported apiVersion values

ASM versionapiVersion value
1.15.3.105 or lateristio.alibabacloud.com/v1
Earlier than 1.15.3.105istio.alibabacloud.com/v1beta1

If you previously set the apiVersion to istio.alibabacloud.com/v1beta1 for ASMCircuitBreaker in a Container Service for Kubernetes (ACK) cluster, change the value to istio.alibabacloud.com/v1 and redeploy the cluster.

spec

For more information, see Configure local rate limiting on an ingress gateway.

FieldTypeRequiredDescription
workloadSelectormap<string, string>YesLabels that select the pods where rate limiting takes effect. Matching is scoped to the namespace of the resource. For more information, see Workload Selector.
isGatewayboolNoSet to true if the rule targets a gateway. Default: false.
configsLocalRateLimiterConfig[]YesRate limiting rules.

LocalRateLimiterConfig

FieldTypeRequiredDescription
namestringYesName of the rate limiting rule.
matchRatelimitMatchYesCriteria that determine which requests this rule applies to.
limitLimitConfigYesToken bucket settings that define the rate limit.
limit_overridesRateLimitOverrideConfig[]NoOverrides that apply different rate limits to specific requests. Requires ASM V1.19.0 or later.

RatelimitMatch

FieldTypeRequiredDescription
vhostVirtualHostMatchNoCriteria for matching a virtual host.

LimitConfig

FieldTypeRequiredDescription
statusintNoHTTP status code returned when a request is rate-limited. Default: 429. Must be 400 or greater. Requires ASM V1.24.6.64 or later.
fill_intervalDurationNoHow often tokens are added to the bucket. Specify seconds (integer) or nanos (nanoseconds). For example, seconds: 1 replenishes the bucket every second. Together with quota, this defines the allowed request rate.
quotaintNoThe number of tokens. The value must be an integer. For example, quota: 100 with seconds: 1 allows 100 requests per second per Envoy instance.
per_downstream_connectionboolNoScope of the token bucket. false (default): one bucket shared across all worker threads per Envoy process. true: one bucket per downstream connection. Requires ASM V1.13.4 or later.
custom_response_bodystringNoResponse body returned when a request is rate-limited. Requires ASM V1.13.4 or later.
response_header_to_addmap[string]stringNoResponse headers added when a request is rate-limited. Requires ASM V1.13.4 or later.

RateLimitOverrideConfig

Use overrides to apply a different rate limit to requests that match specific headers or query parameters, while keeping the base rate limit for all other traffic.

FieldTypeRequiredDescription
request_matchRequestMatcherYesCriteria that identify requests receiving the override.
limitLimitConfigYesRate limit for matched requests. Only fill_interval and quota take effect. The values of per_downstream_connection, custom_response_body, and response_header_to_add are inherited from the parent LocalRateLimiterConfig.limit.

VirtualHostMatch

FieldTypeRequiredDescription
namestringYesName of the virtual host to match.
portintNoPort to match.
routeRouteMatchNoRoute to match within the virtual host.

RouteMatch

FieldTypeRequiredDescription
name_matchstringNoName of a specific route defined in a virtual service.
header_matchHeaderMatcher[]NoDeprecated in ASM V1.19.0 and later. Use RateLimitOverrideConfig instead.

RequestMatcher

When both header_match and query_match are specified, a request must satisfy all conditions to be matched.

FieldTypeRequiredDescription
header_matchHeaderMatcher[]NoHeader-based match criteria.
query_matchQueryParameterMatcher[]NoQuery parameter-based match criteria.

HeaderMatcher

Specify exactly one match mode field (regex_match, exact_match, prefix_match, suffix_match, or present_match) per matcher.

FieldTypeRequiredDescription
namestringNoHeader name.
regex_matchstringNoMatch the header value against a regular expression.
exact_matchstringNoMatch the header value exactly.
prefix_matchstringNoMatch the beginning of the header value.
suffix_matchstringNoMatch the end of the header value.
present_matchboolNotrue: match if the header exists, regardless of value. false: match if the header does not exist.
invert_matchboolNoInvert the match result. Default: false. When true, a request that would normally match is treated as not matching, and vice versa.

QueryParameterMatcher

Specify exactly one match mode field (exact_match, prefix_match, suffix_match, regex_match, contains_match, or present_match) per matcher.

FieldTypeRequiredDescription
namestringYesQuery parameter name.
exact_matchstringNoMatch the parameter value exactly.
prefix_matchstringNoMatch the beginning of the parameter value.
suffix_matchstringNoMatch the end of the parameter value.
regex_matchstringNoMatch the parameter value against a regular expression.
contains_matchstringNoMatch if the parameter value contains the specified string.
present_matchboolNotrue: match if the parameter exists, regardless of value. false is not valid and is equivalent to omitting this field.
ignore_caseboolNoIgnore case when comparing values.