roadrunner icon indicating copy to clipboard operation
roadrunner copied to clipboard

[πŸ’‘ FEATURE REQUEST]: Add `zstd` support

Open maximal opened this issue 1 year ago β€’ 7 comments

Plugin

HTTP Middleware (any)

I have an idea!

Nowadays, zstd became very popular compression standard in web world due to the ratio/speed balance of the corresponding Zstandard compression algorithm.

https://en.wikipedia.org/wiki/Zstd

I think, it would be awesome to have it as a separate middleware to promote zstd support to RoadRunner-backed servers.

EDIT: Pure Golang package: https://pkg.go.dev/github.com/klauspost/compress/zstd#section-readme

Example Usage

HTTP client sends:

Accept-Encoding: zstd

HTTP server sends:

Content-Encoding: zstd

Then, zstd-packed content after the headers.

EDIT(rustatian): if someone wanted to contribute, I've created a repository link for that.

  1. Check the gzip plugin middleware.
  2. Copy everything from it and replace gzip with zstd.
  3. Add tests to the http plugin with that plugin OR you may include tests in the zstd repository.

maximal avatar Dec 04 '24 11:12 maximal

I digged into this before. IUUIC, zstd will make sense for static content compression rather on the fly for each request:

  1. too expensive cpu-wise
  2. browser support is still not ubiquitous https://caniuse.com/zstd

If anything, brotli might be a better candidate. https://caniuse.com/brotli

rauanmayemir avatar Dec 04 '24 13:12 rauanmayemir

@rauanmayemir, maybe we should create two separate issues for @rustatian to decide.

maximal avatar Dec 04 '24 13:12 maximal

Adding zstd is very easy. It can be added and if someone wanted to use it - they'd have their reasons. On the other hand, brotli implementation in most cases would require CGO, which won't be added (i mean, CGO) to RR for sure. I know about one pure Go implementation of that compression algorithm, but I'm not sure that it is properly supported.

rustatian avatar Dec 04 '24 13:12 rustatian

@rustatian, let’s go for the zstd then! ❀️

maximal avatar Dec 04 '24 17:12 maximal

Stumbled on to this issue, I might play around with a plugin for this, using this implementation: https://github.com/klauspost/compress/tree/master/zstd#zstd

sicet7 avatar Dec 13 '24 13:12 sicet7

@sicet7 πŸ‘‹πŸ» Yeah, you may just copy-paste our gzip plugin and replace everything in it with zstd

rustatian avatar Dec 13 '24 13:12 rustatian

Hi, is there any progress on this issue? @sicet7 @rustatian

CheesyTech avatar Apr 14 '25 08:04 CheesyTech