All Products
Search
Document Center

Alibaba Cloud Service Mesh:ASMCompressor field reference

Last Updated:Mar 11, 2026

ASMCompressor is a custom resource definition (CRD) that configures HTTP compression for service-to-service communication and gateway traffic in Service Mesh (ASM). It supports both Gzip and Brotli algorithms.

How compression works

When you apply an ASMCompressor resource, ASM injects a compressor filter into the Envoy sidecar proxy of the selected workloads. The filter inspects request and response headers to determine whether to compress the content.

Compression is applied when all of the following conditions are met:

  • The content type matches one of the configured MIME types.

  • The content length meets the minimum threshold.

  • No existing Content-Encoding header is present.

Response compression is enabled by default. Request compression is disabled by default and must be explicitly configured through request_direction_config.

Example

The following ASMCompressor resource enables Gzip compression on responses for workloads labeled app: httpbin, on service port 8080:

apiVersion: istio.alibabacloud.com/v1
kind: ASMCompressor
metadata:
  name: httpbin-compressor
  namespace: default
spec:
  workloadSelector:
    app: httpbin
  portNumber: 8080
  compressor_library:
    gzip:
      compression_level: DEFAULT
      window_bits: 12
      memory_level: 5
  response_direction_config:
    common_config:
      min_content_length: 256
      content_type:
        - application/json
        - text/html
        - text/plain
    disable_on_etag_header: true

ASMCompressor fields

FieldTypeRequiredDescriptionDefault
workloadSelectormap\YesLabels that select the pods where compression is applied. The label scope is restricted to the namespace of the ASMCompressor resource. For more information, see WorkloadSelector.--
isGatewayboolNoSet to true to apply this configuration to a gateway instead of sidecar proxies.false
portNumberintYesThe service port on which compression is applied. For gateways, this is the gateway service port.--
compressor_libraryCompressorLibraryNoCompression algorithm settings for Gzip or Brotli.--
request_direction_configRequestDirectionConfigNoCompression behavior for requests.--
response_direction_configResponseDirectionConfigNoCompression behavior for responses.--
per_route_configsASMCompressorPerRouteConfigNoRoute-level compression overrides. Supported since ASM V1.21.--

CompressorLibrary fields

FieldTypeRequiredDescriptionDefault
gzipGzipCompressorNoGzip compression settings.--
brotliBrotliCompressorNoBrotli compression settings.--

GzipCompressor fields

FieldTypeRequiredDescriptionDefault
window_bitsintNoWindow size for the compression buffer. Valid values: 9 to 15. Larger values improve the compression ratio but increase memory usage.12
compression_levelstringNoTrade-off between compression ratio and speed. Valid values: BEST (highest ratio, slowest), SPEED (lowest ratio, fastest), DEFAULT (balanced).DEFAULT
memory_levelintNoMemory allocated to the internal compression state. Valid values: 1 to 9. Larger values speed up compression and improve output quality but increase memory usage.5
compression_strategystringNoThe zlib compression strategy. Choose based on the characteristics of the data being compressed. For more information, see Compression strategies.DEFAULT_STRATEGY

Compression strategies

ValueDescription
DEFAULT_STRATEGYAutomatically selected by zlib based on input data characteristics. Suitable for most use cases.
FILTEREDOptimized for data that has been pre-processed by a filter. Typically used for multi-pass compression to increase the compression ratio.
HUFFMAN_ONLYUses only Huffman coding without the LZ77 algorithm. Fastest strategy with the lowest compression ratio.
RLERun-length encoding. Best suited for data with long sequences of repeated bytes.
FIXEDUses a fixed, predefined compression dictionary. Useful when the data follows known, predictable patterns.

BrotliCompressor fields

FieldTypeRequiredDescriptionDefault
window_bitsintNoWindow size for the compression buffer. Valid values: 10 to 24. Larger values improve the compression ratio but increase memory usage.18
qualityintNoCompression quality level. Valid values: 0 to 11. Higher values produce smaller output but take longer to compress.3

RequestDirectionConfig fields

FieldTypeRequiredDescriptionDefault
common_configCommonConfigNoFilter behavior for request compression.--

ResponseDirectionConfig fields

FieldTypeRequiredDescriptionDefault
common_configCommonConfigNoFilter behavior for response compression.--
disable_on_etag_headerboolNoIf true, skip compression when the response includes an ETag header. This preserves the ETag for caching purposes.false
remove_accept_encoding_headerboolNoIf true, strip the Accept-Encoding header from the request before forwarding to the upstream service. This prevents the upstream from compressing the response, so that the Envoy filter handles compression instead.false

CommonConfig fields

FieldTypeRequiredDescriptionDefault
min_content_lengthintNoMinimum response body size in bytes to trigger compression. Very small responses may not benefit from compression. For Gzip, higher CPU cost comes with better compression ratios, so test different thresholds to balance performance and bandwidth.--
content_typestring[]NoMIME types eligible for compression. Only responses whose Content-Type matches an entry in this list are compressed.See below

Default content_type values:

application/javascript, application/json, application/xhtml+xml, image/svg+xml, text/css, text/html, text/plain, text/xml

ASMCompressorPerRouteConfig fields

Per-route configuration overrides the global compression settings for specific routes. For example, you can disable compression on a health-check route while keeping it enabled for all other traffic.

FieldTypeRequiredDescriptionDefault
route_matchRouteConfigurationMatchYesSelects the route to which this override applies.--
disabledboolYesSet to true to disable compression on the matched route.false

RouteConfigurationMatch fields

FieldTypeRequiredDescriptionDefault
portNumberuint32NoMatch a specific service port, or a specific server port in the Gateway. If omitted, all ports are matched.--
portNamestringNoMatch by the portName of a server in the Gateway. Only applies when the compression policy targets a gateway.--
gatewaystringNoThe Gateway to match, in namespace/name format. Only applies when the compression policy targets a gateway. Use with portName and portNumber to select a specific server within the Gateway.--
vhostCommonVirtualHostMatchNoMatch a specific virtual host.--
namestringNoName of the Envoy route configuration to match. Requires familiarity with the underlying Envoy configuration.--

CommonVirtualHostMatch fields

FieldTypeRequiredDescriptionDefault
namestringNoThe virtual host name generated by the control plane, in host:port format. The host value corresponds to the host field of the associated VirtualService or the service fully qualified domain name (FQDN) in the cluster.--
routeCommonRouteMatchNoMatch a specific route within the virtual host.--

CommonRouteMatch fields

FieldTypeRequiredDescriptionDefault
namestringNoRoute name to match. Default-generated routes are named default. If a VirtualService is configured, use the name of the HTTP route defined in the VirtualService.--
actionstringNoMatch routes by action type. Valid values: ROUTE, REDIRECT, DIRECT_RESPONSE, ANY.ANY

Related topics