Yoel-qin opened a new pull request, #14225: URL: https://github.com/apache/apisix/pull/14225
### Description Adds a `zstd` plugin that compresses HTTP responses with `Content-Encoding: zstd` ([RFC 9659](https://datatracker.ietf.org/doc/html/rfc9659)) when the client sends `Accept-Encoding: zstd`, following the structure of the brotli plugin: - q-value-aware `Accept-Encoding` parsing, skip when the upstream already set `Content-Encoding` / `Content-Length < min_length` / type not matched, weak ETag downgrade - chunk-wise streaming via libzstd `ZSTD_compressStream2` (`ZSTD_e_flush` per chunk, `ZSTD_e_end` at eof) - `comp_level` capped at 19 so the decoder window stays within the 8 MB guaranteed by RFC 9659 - priority 994 (brotli 996, gzip 995) The libzstd FFI binding is vendored beside the plugin (`apisix/plugins/zstd/binding.lua`) since the existing Lua zstd bindings are unmaintained (`luajit-zstd` last released 2019, `lua-zstd` ~2020). Only the system `libzstd` is required. Moving it to a standalone rock later is a one-line rockspec change. Measured with a standalone instance on apisix-runtime 1.4.2, 776,770-byte JSON payload (this repo's `admin-api.json` + `control-api.json`), sequential curl, 30 requests: | encoding | config | bytes | ratio | avg/p50 | |---|---|---|---|---| | identity | - | 776,770 | 1.0x | 2.7/2.6 ms | | gzip | level 6 | 62,510 | 12.4x | 10.0/9.8 ms | | brotli | level 6 | 46,696 | 16.6x | 19.0/18.8 ms | | zstd | level 3 (default) | 61,583 | 12.6x | 7.1/6.5 ms | | zstd | level 9 | 47,517 | 16.3x | 28.6/21.5 ms | | zstd | level 19 | 41,044 | 18.9x | 289.9/270.3 ms | Round-trip (sha256 identical to the original) verified for every row; requests without `Accept-Encoding` stay identity. `t/plugin/zstd.t` passes locally (91 assertions) against apisix-runtime 1.4.2. #### Which issue(s) this PR fixes: Fixes #13927 ### Checklist - [x] I have explained the need for this PR and the problem it solves - [x] I have explained the changes or the new features added to this PR - [x] I have added tests corresponding to this change - [x] I have updated the documentation to reflect this change - [x] I have verified that this change is backward compatible (If not, please discuss on the [APISIX mailing list](https://github.com/apache/apisix/tree/master#community) first) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
