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

Per Request compression #2271

Open
mronstro opened this issue Mar 7, 2025 · 2 comments
Open

Per Request compression #2271

mronstro opened this issue Mar 7, 2025 · 2 comments
Labels
good first issue Good for newcomers

Comments

@mronstro
Copy link

mronstro commented Mar 7, 2025

We are using Drogon to build a REST Server to deliver database data.
In one instance we store data stored in Avro format. When configuring Drogon to use
compression this becomes extremely costly, costs 5-10x more CPU per request and
compression is likely very little since the Avro format is a compression format.

Most other data is fine with normal compression.

So the conclusion is that it would be great with a possibility to set compression per request.
This should be simple using a new method on HttpResponsePtr. setCompressed (was thought to
exist by ChatGPT :) ). Even better would if this method could even set the compression level
on a per request level.

Describe the solution you'd like
A new method on HttpResponsePtr that is used to set the compression level for the response.

Describe alternatives you've considered
Obviously it is possible to use Drogon configuration and also the client can control it.
These are good things to use, but the client doesn't necessarily know all the details about
which compression is most desirable and one setting per server is not flexible enough.

@an-tao an-tao added the good first issue Good for newcomers label Mar 8, 2025
@mronstro
Copy link
Author

mronstro commented Mar 8, 2025

On further check it seems that one way of accomplishing this behaviour is by setting the ContentType to something that is already compressed like CT_APPLICATION_OCTET_STREAM

@vaddikeshavareddy
Copy link

Implement a middleware function that checks the response content-type or a custom header, and dynamically sets HttpResponsePtr::setCompression(CompressionLevel) before sending the response, allowing per-request control.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants