Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[💡 FEATURE REQUEST]: Add zstd support #2080

Open
maximal opened this issue Dec 4, 2024 · 6 comments
Open

[💡 FEATURE REQUEST]: Add zstd support #2080

maximal opened this issue Dec 4, 2024 · 6 comments
Assignees
Labels
C-feature-accepted Category: Feature discussed and accepted help-heeded-medium Call for participation: Experience needed to fix: Medium / intermediate

Comments

@maximal
Copy link
Contributor

maximal commented Dec 4, 2024

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 maximal added the C-feature-request Category: feature requested, but need to be discussed label Dec 4, 2024
@rauanmayemir
Copy link

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

@maximal
Copy link
Contributor Author

maximal commented Dec 4, 2024

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

@rustatian
Copy link
Member

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 rustatian added C-feature-accepted Category: Feature discussed and accepted and removed C-feature-request Category: feature requested, but need to be discussed labels Dec 4, 2024
@rustatian rustatian moved this to 📋 Backlog in Jira 😄 Dec 4, 2024
@rustatian rustatian moved this from 📋 Backlog to 🔖 Ready in Jira 😄 Dec 4, 2024
@rustatian rustatian added the help-heeded-medium Call for participation: Experience needed to fix: Medium / intermediate label Dec 4, 2024
@maximal
Copy link
Contributor Author

maximal commented Dec 4, 2024

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

@sicet7
Copy link

sicet7 commented Dec 13, 2024

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

@rustatian
Copy link
Member

@sicet7 👋🏻
Yeah, you may just copy-paste our gzip plugin and replace everything in it with zstd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-accepted Category: Feature discussed and accepted help-heeded-medium Call for participation: Experience needed to fix: Medium / intermediate
Projects
Status: 🔖 Ready
Development

No branches or pull requests

4 participants