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

server: compress large response payloads if client supports it #5310

Closed
anderseknert opened this issue Oct 26, 2022 · 24 comments · Fixed by #5696
Closed

server: compress large response payloads if client supports it #5310

anderseknert opened this issue Oct 26, 2022 · 24 comments · Fixed by #5696

Comments

@anderseknert
Copy link
Member

For certain types of payloads, or just exploratory browsing of /data, the main time spent for these queries is not inside of OPA, but waiting for data in transit. If the client supports content encoding like gzip, compressing the data may provide quite a dramatic reduction of payload size and hence total response time.

  1. If an integrating HTTP client sends an Accept-Encoding header including gzip...
  2. ...and the payload is larger than some arbitrary number, like 1 kB...
  3. Respond with a Content-Encoding: gzip header and a gzip compressed payload.
@srenatus
Copy link
Contributor

https://pkg.go.dev/github.com/gorilla/handlers#CompressHandler we should perhaps just use something like that. 💭

@sanjeev98kumar
Copy link

Could you please assign this issue to me? I am looking for my first PR.
Also wanted to know how much time will it require for me to set up opa on my local?

@anderseknert
Copy link
Member Author

Of course, @sanjeev98kumar 👍

I would not expect much time to be spent setting anything up — just clone the repo and get hacking :)
But do see https://www.openpolicyagent.org/docs/latest/contrib-code/ and https://www.openpolicyagent.org/docs/latest/contrib-development/ for some useful information on contributing. And feel free to ask any questions whenever you want.

@margelatu
Copy link

+1 for supporting compression, we're also in need of this feature.

@anderseknert
Copy link
Member Author

@sanjeev98kumar any progress to report on this issue? 🙂

@burnerlee
Copy link
Contributor

@anderseknert @srenatus can I pick this issue up if it's okay?

@srenatus
Copy link
Contributor

srenatus commented Dec 2, 2022

@burnerlee since there's no response from @sanjeev98kumar for a while, I guess that's OK 👍

@burnerlee
Copy link
Contributor

cool, I'll start working on the issue

@srenatus srenatus assigned burnerlee and unassigned sanjeev98kumar Dec 2, 2022
@burnerlee
Copy link
Contributor

@srenatus can you help by giving me some insight into the issue? Like in which section of the project we're making this change and what do we exactly want to do?

@burnerlee
Copy link
Contributor

I've opened a draft PR from what I could understand from the issue description. Do we need to add this handler somewhere else too?

@srenatus
Copy link
Contributor

srenatus commented Dec 2, 2022

Ideally, tests would tell us, I think.

@irwanshofwan
Copy link

can I pick this issue or pair for this ? @anderseknert @srenatus

@anderseknert
Copy link
Member Author

Hey @irwanshofwan! Perhaps we could get an update from @burnerlee first? He has an open PR for this here, but as far as I can see, there's a few unaddressed comments there. An unforseen event here is how the gorilla library was archived just recently, so whoever works on this issue will likely want to await this PR to be merged.

@anderseknert
Copy link
Member Author

But either way, thanks for stepping up! 😃

@burnerlee
Copy link
Contributor

hey @irwanshofwan please go ahead. I'm stuck in some other things rn and not able to contribute. Sorry for holding you guys back

@burnerlee
Copy link
Contributor

i would suggest continuing the same PR. we just need to handle the tests right now

@irwanshofwan
Copy link

sure, will try continue from existing PR

@anderseknert
Copy link
Member Author

anderseknert commented Dec 22, 2022

Whatever works best for you, but do see my note about gorilla above.

@irwanshofwan
Copy link

sure, I believe we can do it parallel for this issue and rebase after the gorilla mux solved.

@stale
Copy link

stale bot commented Jan 24, 2023

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

@stale stale bot added the inactive label Jan 24, 2023
@margelatu
Copy link

@irwanshofwan any news on this ?

Context: we use OPA heavily at Adobe and in some scenarios need gzip support on both requests and responses as they get rather large.

@stale stale bot removed the inactive label Feb 9, 2023
@anderseknert
Copy link
Member Author

@margelatu I believe this was put on hold while waiting for the router library situation to be resolved. But this is probably simple enough to pull off without having to use a helper from there, should anyone want to step up and do it :)

AdrianArnautu pushed a commit to AdrianArnautu/opa that referenced this issue Feb 21, 2023
AdrianArnautu pushed a commit to AdrianArnautu/opa that referenced this issue Feb 22, 2023
AdrianArnautu pushed a commit to AdrianArnautu/opa that referenced this issue Feb 22, 2023
AdrianArnautu pushed a commit to AdrianArnautu/opa that referenced this issue Feb 24, 2023
AdrianArnautu added a commit to AdrianArnautu/opa that referenced this issue Feb 24, 2023
AdrianArnautu pushed a commit to AdrianArnautu/opa that referenced this issue Feb 24, 2023
Signed-off-by: Adrian Arnautu <[email protected]>
AdrianArnautu pushed a commit to AdrianArnautu/opa that referenced this issue Feb 24, 2023
Signed-off-by: aarnautu <[email protected]>
AdrianArnautu pushed a commit to AdrianArnautu/opa that referenced this issue Mar 5, 2023
Signed-off-by: aarnautu <[email protected]>
AdrianArnautu pushed a commit to AdrianArnautu/opa that referenced this issue Mar 5, 2023
Signed-off-by: aarnautu <[email protected]>
AdrianArnautu pushed a commit to AdrianArnautu/opa that referenced this issue Mar 6, 2023
Signed-off-by: aarnautu <[email protected]>
AdrianArnautu pushed a commit to AdrianArnautu/opa that referenced this issue Mar 6, 2023
Signed-off-by: aarnautu <[email protected]>
AdrianArnautu pushed a commit to AdrianArnautu/opa that referenced this issue Mar 6, 2023
Signed-off-by: aarnautu <[email protected]>
AdrianArnautu pushed a commit to AdrianArnautu/opa that referenced this issue Mar 7, 2023
Signed-off-by: aarnautu <[email protected]>
AdrianArnautu pushed a commit to AdrianArnautu/opa that referenced this issue Mar 7, 2023
Signed-off-by: aarnautu <[email protected]>
AdrianArnautu pushed a commit to AdrianArnautu/opa that referenced this issue Mar 8, 2023
Signed-off-by: aarnautu <[email protected]>
AdrianArnautu pushed a commit to AdrianArnautu/opa that referenced this issue Mar 8, 2023
Signed-off-by: aarnautu <[email protected]>
AdrianArnautu pushed a commit to AdrianArnautu/opa that referenced this issue Mar 9, 2023
…ed response and request body.

It is available for the following REST API endpoints:
- GET & POST HTTP methods on /v0/data & /v1/data endpoints
- POST HTTP method on /v1/compile endpoint

HTTP clients can optionally:
- send 'Accept-Encoding: gzip' header and expect a gzip compressed body and a Content-Encoding: gzip response header. The server will send the content encoded as gzip only after a threshold defined by server.encoding.gzip.min_length (default value is 1024). If the size is below the threshold, the body is not compressed
- send 'Content-Encoding: gzip' header and a gzip compressed body and expect the server to correctly interpret the request

Fixes open-policy-agent#5310

Signed-off-by: aarnautu <[email protected]>
anderseknert pushed a commit to AdrianArnautu/opa that referenced this issue Mar 9, 2023
…ed response and request body.

It is available for the following REST API endpoints:
- GET & POST HTTP methods on /v0/data & /v1/data endpoints
- POST HTTP method on /v1/compile endpoint

HTTP clients can optionally:
- send 'Accept-Encoding: gzip' header and expect a gzip compressed body and a Content-Encoding: gzip response header. The server will send the content encoded as gzip only after a threshold defined by server.encoding.gzip.min_length (default value is 1024). If the size is below the threshold, the body is not compressed
- send 'Content-Encoding: gzip' header and a gzip compressed body and expect the server to correctly interpret the request

Fixes open-policy-agent#5310

Signed-off-by: aarnautu <[email protected]>
anderseknert pushed a commit that referenced this issue Mar 9, 2023
…ed response and request body. (#5696)

It is available for the following REST API endpoints:
- GET & POST HTTP methods on /v0/data & /v1/data endpoints
- POST HTTP method on /v1/compile endpoint

HTTP clients can optionally:
- send 'Accept-Encoding: gzip' header and expect a gzip compressed body and a Content-Encoding: gzip response header. The server will send the content encoded as gzip only after a threshold defined by server.encoding.gzip.min_length (default value is 1024). If the size is below the threshold, the body is not compressed
- send 'Content-Encoding: gzip' header and a gzip compressed body and expect the server to correctly interpret the request

Fixes #5310

Signed-off-by: aarnautu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment