-
Notifications
You must be signed in to change notification settings - Fork 121
Add support for request and response compression #765
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
base: main
Are you sure you want to change the base?
Conversation
d4338a5 to
8e3975d
Compare
gateway-ha/src/main/java/io/trino/gateway/proxyserver/ProxyRequestHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/proxyserver/ProxyRequestHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/proxyserver/TestProxyRequestHandler.java
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/proxyserver/ProxyRequestHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/proxyserver/TestProxyRequestHandler.java
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/proxyserver/TestProxyRequestHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/proxyserver/TestProxyRequestHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/proxyserver/TestProxyRequestHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/proxyserver/TestProxyRequestHandler.java
Outdated
Show resolved
Hide resolved
8e3975d to
3a7f15f
Compare
gateway-ha/src/main/java/io/trino/gateway/proxyserver/ProxyRequestHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/proxyserver/ProxyRequestHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/proxyserver/TestProxyRequestHandler.java
Show resolved
Hide resolved
3a7f15f to
15c12e9
Compare
gateway-ha/src/main/java/io/trino/gateway/proxyserver/ProxyRequestHandler.java
Outdated
Show resolved
Hide resolved
15c12e9 to
fb2dc46
Compare
gateway-ha/src/main/java/io/trino/gateway/proxyserver/ProxyResponseHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/proxyserver/ProxyResponseHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/proxyserver/ProxyResponseHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/proxyserver/ProxyResponseHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/proxyserver/ProxyResponseHandler.java
Outdated
Show resolved
Hide resolved
fb2dc46 to
0f0a82d
Compare
|
Looks like Airlift disabled Jetty's |
0f0a82d to
96d2ab9
Compare
vishalya
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! We should consider supporting encodings and compression methods that help optimize network bandwidth during communication. Have we evaluated the potential impact of this change on CPU performance? May be you can have some tests for it.
| // Check if the response is gzip-compressed | ||
| String contentEncoding = headers.get(HeaderName.of("Content-Encoding")).stream().findFirst().orElse(null); | ||
|
|
||
| if ("gzip".equalsIgnoreCase(contentEncoding)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the only encoding trino clients request? Then we should only allow that encoding here.
You can also test with Accept-Encoding: gzip, deflate
The spooling protocol offers additional encodings.
| } | ||
|
|
||
| // Not compressed, convert bytes to string | ||
| return new String(body, UTF_8); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be great if we could deal with just bytes, but it could have some other side effects.
| // OkHttp automatically adds "Accept-Encoding: gzip" when none is specified | ||
| assertThat(response.body().string()).isEqualTo("gzip"); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also add a test which breaks current gateway max limit and make sure it work with your change?
| { | ||
| // Test that Accept-Encoding header is properly forwarded to backends | ||
| String url = "http://localhost:" + routerPort + healthCheckEndpoint + "?test-compression"; | ||
| String expectedAcceptEncoding = "gzip, deflate, br"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a test with just String expectedAcceptEncoding = "deflate, br";
Is there a good way to test/measure the impact? |
|
I would just run a few local JFR recordings to see how it compares. |
96d2ab9 to
ebf075d
Compare
Description
Accept-Encodingis removed when making POST request so response does not include compression.Since client(trino-gateway) requests without It compression, trino server would return without compression (Content-Encoding).
It may depend on result, but when it seems compression is done about 51%(722->351), so approx 51% of network/memory could be saved.
Additional context and related issues
local test
before (add request/response header logging from main branch)
after
Release notes
(x) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required, with the following suggested text:
* Fix some things.