All Products
Search
Document Center

Alibaba Cloud Service Mesh:Description of ASMGlobalRateLimiter CRD

Last Updated:Mar 11, 2026

The ASMGlobalRateLimiter Custom Resource Definition (CRD) configures global rate limiting in Service Mesh (ASM). Each ASMGlobalRateLimiter resource specifies which workloads to target, which external rate limit service to query, and the rate limiting rules to enforce. At request time, the sidecar or waypoint proxy queries the rate limit service and either allows or rejects the request based on the configured thresholds.

Configuration examples

All examples use the istio.alibabacloud.com/v1 API version and require an ASM instance of version 1.25.6.74 or later.

Limit inbound requests to a service (server-side)

This configuration limits the httpbin application to 1 request per minute across all clients. Because applyToTraffic is set to sidecar_inbound, the rate limit is enforced at the server side regardless of which client sends the request.

apiVersion: istio.alibabacloud.com/v1
kind: ASMGlobalRateLimiter
metadata:
  name: global-test
spec:
  configs:
  - limit:
      quota: 1
      unit: MINUTE
    target_services:
    - name: httpbin
      port: 8000
    name: default
  applyToTraffic: sidecar_inbound
  rateLimitService:
    host: ratelimit.default.svc.cluster.local # Queries this service to determine whether the current request needs to be throttled.
    port: 8081
    timeout:
      seconds: 5
  workloadSelector:
    labels:
      app: httpbin

Limit outbound requests from a client (client-side)

This configuration limits the sleep application to 1 request per minute when calling the httpbin service. Because applyToTraffic is set to sidecar_outbound, only this specific client is rate-limited. Other clients that call httpbin are not affected.

apiVersion: istio.alibabacloud.com/v1
kind: ASMGlobalRateLimiter
metadata:
  name: global-test
spec:
  configs:
  - limit:
      quota: 1
      unit: MINUTE
    target_services:
    - name: httpbin
      port: 8000
    name: default
  applyToTraffic: sidecar_outbound
  rateLimitService:
    host: ratelimit.default.svc.cluster.local # Queries this service to determine whether the current request needs to be throttled.
    port: 8081
    timeout:
      seconds: 5
  workloadSelector:
    labels:
      app: sleep

Rate limit by request header on a waypoint (Ambient mode)

This example applies only to Ambient mode and requires an ASM instance of version 1.25.6.74 or later.

This configuration attaches a rate limiting rule to the default waypoint. Requests that include the x-user header get a per-user bucket limited to 1 request per minute (distinct: true). Requests without the header share a common bucket limited to 20 requests per minute.

apiVersion: istio.alibabacloud.com/v1
kind: ASMGlobalRateLimiter
metadata:
  name: global-test
spec:
  configs:
  - limit_overrides:
    - limit:
        quota: 1
        unit: MINUTE
      request_match:
        header_match:
        - distinct: true
          name: x-user
    limit:
      quota: 20
      unit: MINUTE
    target_services:
    - name: httpbin
      port: 8000
    name: default
  applyToTraffic: waypoint
  rateLimitService:
    host: ratelimit.default.svc.cluster.local # Queries this service to determine whether the current request needs to be throttled.
    port: 8081
    timeout:
      seconds: 5
  workloadSelector:
    labels:
      gateway.networking.k8s.io/gateway-name: default

spec

The top-level spec object defines the target workloads, rate limit service connection, and rules:

spec:
  workloadSelector:
    labels: { ... }
  isGateway: false
  applyToTraffic: sidecar_inbound
  rateLimitService: { ... }
  configs:
  - { ... }
FieldTypeRequiredDescription
workloadSelectormap\YesLabels that select the workloads where rate limiting rules take effect. The label scope is restricted to the namespace where the resource is defined. For more information, see Workload Selector.
isGatewayboolNoWhether the rule targets a gateway. Default: false.
rateLimitServiceRateLimitServiceConfigYesConnection settings for the external rate limit service.
configsGlobalRateLimiterConfig[]YesOne or more rate limiting rules.
applyToTrafficstringNoTraffic direction the rules apply to. Default: sidecar_inbound. See applyToTraffic values. Supported in ASM 1.25 and later.

applyToTraffic values

ValueTraffic directionUse case
sidecar_inboundInbound traffic received by a sidecar-attached application (server side)Protect a service from excessive requests
sidecar_outboundOutbound traffic sent by a sidecar-attached application (client side)Limit how often a specific client calls a service
waypointTraffic processed by a waypoint proxy in Ambient modeRate limit at the waypoint layer without sidecars
gatewayTraffic passing through an ingress gatewayProtect backend services from external traffic

RateLimitServiceConfig

Connection settings for the gRPC rate limit service that the mesh proxy queries at request time:

rateLimitService:
  host: ratelimit.default.svc.cluster.local
  port: 8081
  timeout:
    seconds: 5
FieldTypeRequiredDescription
hoststringYesIn-cluster domain name of the rate limit service.
portintYesgRPC port of the rate limit service.
timeoutDurationNoTimeout for the mesh proxy to connect to the rate limit service. Specify as seconds: <n> or nanos: <n> (nanoseconds).

GlobalRateLimiterConfig

Each entry in the configs array defines a rate limiting rule:

configs:
- name: default
  match: { ... }
  limit:
    quota: 10
    unit: MINUTE
  limit_overrides:
  - { ... }
  target_services:
  - { ... }
FieldTypeRequiredDescription
namestringYesName of the rate limiting rule.
matchRatelimitMatchYesCriteria that requests must match for this rule to apply.
limitGlobalServiceLimitConfigYesDefault rate limit threshold.
limit_overridesGlobalRateLimitOverrideConfig[]NoOverride the default threshold for requests that match specific criteria. Supported in ASM V1.19.0 and later.
target_servicesTargetServiceRef[]NoServices to which this rule applies. Supported in ASM 1.25 and later.

GlobalServiceLimitConfig

Defines the rate limit threshold as a quota within a time window:

FieldTypeRequiredDescription
unitstringYesTime window unit. Valid values: SECOND, MINUTE.
quotaintYesMaximum number of requests allowed per time window.

GlobalRateLimitOverrideConfig

Overrides the default rate limit threshold for requests that match specific criteria. When a request matches an override, the override threshold applies instead of the rule-level limit.

Supported in ASM V1.19.0 and later.
FieldTypeRequiredDescription
request_matchRequestMatcherYesCriteria that a request must match for this override to apply.
limitGlobalServiceLimitConfigYesRate limit threshold for matching requests.

TargetServiceRef

Specifies the service to which a rate limiting rule applies.

Supported in ASM 1.25 and later.
target_services:
- kind: Service
  namespace: default
  name: httpbin
  port: 8000
FieldTypeRequiredDescription
kindstringNoResource type of the target service. Valid values: Service, ServiceEntry, VirtualService. Default: Service.
namestringYesName of the target service resource.
namespacestringNoNamespace of the target service. Default: the namespace where the rate limiting policy is defined.
portint32NoPort of the target service.
section_namestringNoRoute name within a VirtualService. Only valid when kind is VirtualService.

TargetServiceRef examples

Target a Service

Apply the rule to port 8000 of the httpbin Service in the default namespace:

target_services:
- kind: Service
  namespace: default
  name: httpbin
  port: 8000

Target a ServiceEntry

If your mesh includes the following ServiceEntry for an external service:

apiVersion: networking.istio.io/v1
kind: ServiceEntry
metadata:
  name: se-httpbin-external
spec:
  hosts:
  - httpbin.test.com
  location: MESH_EXTERNAL
  ports:
  - name: http
    number: 80
    protocol: HTTP
  - name: https
    number: 443
    protocol: HTTPS
  resolution: DNS

Apply the rule to port 80:

target_services:
- kind: ServiceEntry
  namespace: default
  name: se-httpbin-external
  port: 80

Target a VirtualService route

If your mesh includes the following VirtualService:

apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
  name: vs-httpbin
spec:
  hosts:
  - httpbin.test.com
  http:
  - name: default
    route:
    - destination:
        host: httpbin
        port:
          number: 8000

Apply the rule to the route named default:

target_services:
- kind: VirtualService
  namespace: default
  name: vs-httpbin
  section_name: default

RatelimitMatch

Defines the virtual host matching criteria for a rate limiting rule:

FieldTypeRequiredDescription
vhostVirtualHostMatchYesVirtual host to match.

VirtualHostMatch

FieldTypeRequiredDescription
namestringYesName of the virtual host.
portintNoRequest port to match.
routeRouteMatchNoRoute within the virtual host to match.

RouteMatch

FieldTypeRequiredDescription
name_matchstringNoName of a specific route in a virtual service.
header_matchHeaderMatcher[]NoHeaders to match. Deprecated in ASM V1.19.0 and later. Use GlobalRateLimitOverrideConfig instead.

RequestMatcher

Defines criteria for matching requests in override configurations. When multiple fields are specified, a request must match all of them (AND logic).

FieldTypeRequiredDescription
header_matchHeaderMatcher[]NoMatch by request headers.
remote_addressRemoteAddressMatcherNoMatch by source IP address.
query_matchQueryParameterMatcher[]NoMatch by query parameters.

RemoteAddressMatcher

Matches requests by source IP address or CIDR range. To match a range, specify the base address in address and the prefix length in v4_prefix_mask_len or v6_prefix_mask_len.

FieldTypeRequiredDescription
addressstringYesSource IP address or base address of a CIDR range.
v4_prefix_mask_lenuint32NoIPv4 subnet mask length. Combined with address, matches the calculated CIDR range.
v6_prefix_mask_lenuint32NoIPv6 subnet mask length. Combined with address, matches the calculated CIDR range.

HeaderMatcher

Matches requests by HTTP header values. Specify exactly one match type (regex_match, exact_match, prefix_match, or suffix_match) per matcher entry.

FieldTypeRequiredDescription
namestringNoHeader name.
regex_matchstringNoRegular expression to match the header value.
exact_matchstringNoExact string to match the header value.
prefix_matchstringNoPrefix to match the header value.
suffix_matchstringNoSuffix to match the header value.
present_matchboolNoIf true, matches when the header is present (value is ignored). If false, matches when the header is absent.
invert_matchboolNoIf true, inverts the match result. Default: false.

QueryParameterMatcher

Matches requests by URL query parameter values. Specify exactly one match type (exact_match, prefix_match, suffix_match, regex_match, or contains_match) per matcher entry.

FieldTypeRequiredDescription
namestringYesQuery parameter name.
exact_matchstringNoExact string to match the query parameter value.
prefix_matchstringNoPrefix to match the query parameter value.
suffix_matchstringNoSuffix to match the query parameter value.
regex_matchstringNoRegular expression to match the query parameter value.
contains_matchstringNoSubstring that the query parameter value must contain.
present_matchboolNoIf true, matches when the query parameter is present (value is ignored). Cannot be set to false; use other match types instead.
ignore_caseboolNoWhether to ignore case when matching the query parameter value.

References