gateway icon indicating copy to clipboard operation
gateway copied to clipboard

Support Compression

Open arkodg opened this issue 1 year ago • 19 comments

Description: Support Payload Compression

[optional Relevant Links:]

Any extra documentation required to understand the issue.

Envoy - https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/compression/compression.html#compression

Upstream Issue - https://github.com/kubernetes-sigs/gateway-api/issues/1799

Relates to https://envoyproxy.slack.com/archives/C03E6NHLESV/p1705084783438099

arkodg avatar Jan 16 '24 19:01 arkodg

BackendTrafficPolicy seems like a good home for compression , and Envoy does have support for per route compression filters

arkodg avatar Jan 16 '24 19:01 arkodg

For refs here is a working patch for HTTPS, (warning the path to patch is different for HTTP "/default_filter_chain/filters/0/typed_config/http_filters/0")

apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyPatchPolicy
metadata:
  name: compressor-patch-policy
  namespace: envoy-gateway-system
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: Gateway
    name: eg
    namespace: envoy-gateway-system
  type: JSONPatch
  jsonPatches:
    - type: "type.googleapis.com/envoy.config.listener.v3.Listener"
      name: envoy-gateway-system/eg/https
      operation:
        op: add
        path: "/filter_chains/0/filters/0/typed_config/http_filters/0"
        value:
          name: "envoy.filters.http.compressor"
          typed_config:
            "@type": "type.googleapis.com/envoy.extensions.filters.http.compressor.v3.Compressor"
            compressor_library:
              name: text_optimized
              typed_config:
                "@type": "type.googleapis.com/envoy.extensions.compression.gzip.compressor.v3.Gzip"
                compression_level: BEST_SPEED
                compression_strategy: DEFAULT_STRATEGY
                memory_level: 8
                window_bits: 15
                chunk_size: 4096
            response_direction_config:
              remove_accept_encoding_header: true
              common_config:
                enabled:
                  default_value: true
                  runtime_key: response_direction_config_enabled
                content_type:
                  - "application/javascript"
                  - "application/json"
                  - "application/x-web-app-manifest+json"
                  - "application/xhtml+xml"
                  - "application/xml"
                  - "font/opentype"
                  - "image/svg+xml"
                  - "image/x-icon"
                  - "text/css"
                  - "text/html"
                  - "text/plain"
                  - "text/xml"
                min_content_length: 60
            request_direction_config:
              common_config:
                enabled:
                  default_value: false
                  runtime_key: request_direction_config_enabled

you should see a response with an content-encoding: gzip header for an HTTP/1.1 request with a Accept-Encoding: deflate, gzip header.

akhenakh avatar Jan 16 '24 21:01 akhenakh

@arkodg @akhenakh are you going to work on it? I'm willing to help on it, thanks!

soulxu avatar Jan 17 '24 02:01 soulxu

go for it @soulxu ! recommend starting with the API PR before implementing the logic :)

arkodg avatar Jan 17 '24 02:01 arkodg

@arkodg got it, thanks!

soulxu avatar Jan 17 '24 02:01 soulxu

Interesting discussion here on compression performance and buffer sizing. Should we make per_connection_buffer_limit_bytes configurable as part of this issue?

I can also think of future use cases that include buffering filters (ext-auth with body, WAF, ext-proc, lua, buffer) that should be part of the Envoy Gateway scope and require buffer size tuning.

guydc avatar Feb 11 '24 15:02 guydc

This issue has been automatically marked as stale because it has not had activity in the last 30 days.

github-actions[bot] avatar Mar 12 '24 16:03 github-actions[bot]

Would it be hard to add brotli compression with a fallback to gzip if the HTTP client only supports gzip?

robd003 avatar Apr 08 '24 23:04 robd003

This issue has been automatically marked as stale because it has not had activity in the last 30 days.

github-actions[bot] avatar May 09 '24 00:05 github-actions[bot]

@soulxu still working on this one ?, the API is in, but the implementation is still left

arkodg avatar May 29 '24 22:05 arkodg

Hi, we are also interested in compression support in CRDs.

Envoy supporting Brotli natively was one of the reasons we chose it as our API Gateway over Kong (which has since added Brotli support)

jindrichpilar-kosik avatar May 30 '24 09:05 jindrichpilar-kosik

@soulxu still working on this one ?, the API is in, but the implementation is still left

@arkodg I will give a try this two weeks.

soulxu avatar Jun 03 '24 02:06 soulxu

thanks for the update @soulxu ! , lets keep this in the v1.1 milestone for now

arkodg avatar Jun 03 '24 18:06 arkodg

This issue has been automatically marked as stale because it has not had activity in the last 30 days.

github-actions[bot] avatar Jul 25 '24 20:07 github-actions[bot]

+1

paulo-worry avatar Jul 30 '24 01:07 paulo-worry

Any updates on this @soulxu ?

robd003 avatar Jul 30 '24 19:07 robd003

hey @soulxu are you still planning on working on this one ? would be great if you can, completely okay if not, will unassign so someone from the community can take this forward

arkodg avatar Aug 16 '24 00:08 arkodg

@arkodg sorry, I failed on get a chance working on it, please free feel to assign anyone interesting it.

soulxu avatar Aug 20 '24 01:08 soulxu

np thanks for the update @soulxu, unassgning

arkodg avatar Aug 20 '24 14:08 arkodg