-
Notifications
You must be signed in to change notification settings - Fork 342
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
Set Content-Length header in Traffic Router #4074
Conversation
to leave the response uncommitted
Can one of the admins verify this patch? |
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.
Docs look fine and I glanced over the Java and everything looks alright, but somebody more familiar with TR should take a look.
maybe @rawlinp or @ajschmidt can look at it. |
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! The code changes look good -- I just want to do some more testing against it before merging.
Can you rebase to fix conflicts? Idk if @rawlinp ever got around to that testing, but it can't be merged in any case while it has conflicts. |
ea22aff
to
05da19c
Compare
@ocket8888 Okay, I have rebased it. Merge conflicts are resolved. |
add to whitelist (this is just to tell the asf-ci bot that your PRs are ok to run through CI) |
Refer to this link for build results (access rights to CI server needed): |
bd2cd43
to
d328946
Compare
d328946
to
666ec1b
Compare
Rebased to fix merge conflicts from #6008. As of f8dcdf2320, Traffic Router closes the connection once the response is sent, so if a user does Undrafted, #4074 is ready for review. |
// sending it sometimes means we must always send it. From RFC 2616: | ||
// > HTTP/1.1 applications that do not support persistent connections MUST | ||
// > include the "close" connection option in every message. | ||
response.addHeader(HttpHeaders.CONNECTION, "close"); |
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.
This worries me, because we might be fixing the performance of invalid requests (e.g. curl -X HEAD
), at the expense of valid requests. Keeping client connections alive where possible can be a good thing.
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.
It can be, but some CDNs seem to prefer Connection: close
for redirects:
-
[zrhoffman@computer ~]$ curl -I https://apple.com/ HTTP/1.1 301 Redirect Date: Wed, 02 Nov 2022 15:18:11 GMT Connection: close Via: http/1.1 xxxx.ts.apple.com (acdn/000.00000) Cache-Control: no-store Location: https://www.apple.com/ Content-Type: text/html Content-Language: en X-Cache: none CDNUUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-xxxxxxxxxx Content-Length: 304
-
[zrhoffman@computer ~]$ curl -I http://fastly.com/ HTTP/1.1 301 Moved Permanently Connection: close Content-Length: 0 Retry-After: 0 Accept-Ranges: bytes Date: Wed, 02 Nov 2022 15:18:50 GMT X-Served-By: cache-xxx0000-XXX X-Cache: HIT X-Cache-Hits: 0 Cache-Control: max-age=0, private, must-revalidate Server: Artisanal bits Location: https://fastly.com/
-
Looks like cloudfront.com is trying to close the connection but mistyped it as
Cneonction
:
[zrhoffman@computer ~]$ curl -I http://cloudfront.com/
HTTP/1.1 302 Found
Date: Wed, 02 Nov 2022 15:19:19 GMT
Server: Server
Location: http://aws.amazon.com/cloudfront
Cneonction: close
Content-Type: text/html; charset=iso-8859-1
```
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.
Does TR support HTTP/2? The spec for HTTP/2 says that clients must treat any message containing a connection-specific header as malformed. So we definitely shouldn't send that on requests for that protocol.
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.
close
is the default behavior for HTTP/1.0, so really you just want to add this header if the request is HTTP/1.1. You can check that with the request's getProtocol
method, I think.
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.
Does TR support HTTP/2?
No, and curl -X HEAD
doesn't hang for HTTP/2 anyway.
As an alternative to Connection: close
, we could just reduce Connector.connectionTimeout
from 10 seconds to something shorter, like 3 or 5 seconds:
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.
Ideally @rawlinp would chime in to say whether or not that's acceptable
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.
Connection: close
still kind of worries me, especially because there may be clients out there relying on high connection rates to TR, whether that is really the right approach or not, reusing connections could actually be helping TR performance. Maybe I don't fully understand the need for it here? Are HEAD
requests broken without it?
Changing connectionTimeout
in server.xml seems like it would be more fine-tuned via the CDN operator's ansible playbooks (or equivalent) if the CDN had issues with slow clients. I think Tomcat ships with a 20s default, and 10s seems reasonable for a TR default.
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.
Looks like cloudfront.com is trying to close the connection but mistyped it as
Cneonction
:
As @rob05c pointed out to me, Cneonction
is just a hack to get around Connection header differences between the origin and caches.
Maybe I don't fully understand the need for it here? Are
HEAD
requests broken without it?
Nope we don't need it, it would only be to appease invalid requests like curl -X HEAD
. But curl -X HEAD
doesn't cause a timeout anyway in HTTP/2, so there isn't a long-term reason to do it, especially with the benefits from reusing the connection like you mentioned.
Even if we did want to change any connection behavior, that belongs in a separate PR, #4074 should just be to resolve disparities between HEAD
and GET
.
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.
Forgot to mention: Reverted closing the connection in 97d38f2234
|
d78501b
to
2df2416
Compare
Rebased to fix merge conflicts from #6390 |
2df2416
to
b246498
Compare
.../test/java/org/apache/traffic_control/traffic_router/core/external/BufferedResponseTest.java
Outdated
Show resolved
Hide resolved
.../test/java/org/apache/traffic_control/traffic_router/core/external/BufferedResponseTest.java
Outdated
Show resolved
Hide resolved
.../test/java/org/apache/traffic_control/traffic_router/core/external/BufferedResponseTest.java
Outdated
Show resolved
Hide resolved
.../test/java/org/apache/traffic_control/traffic_router/core/external/BufferedResponseTest.java
Outdated
Show resolved
Hide resolved
.../test/java/org/apache/traffic_control/traffic_router/core/external/BufferedResponseTest.java
Outdated
Show resolved
Hide resolved
.../test/java/org/apache/traffic_control/traffic_router/core/external/BufferedResponseTest.java
Outdated
Show resolved
Hide resolved
.../test/java/org/apache/traffic_control/traffic_router/core/external/BufferedResponseTest.java
Outdated
Show resolved
Hide resolved
.../test/java/org/apache/traffic_control/traffic_router/core/external/BufferedResponseTest.java
Outdated
Show resolved
Hide resolved
...ore/src/test/java/org/apache/traffic_control/traffic_router/core/external/LocationsTest.java
Show resolved
Hide resolved
This reverts commit b24649869407d902301ce6997c629e367285b44f.
a72b382
to
20a37e9
Compare
Rebased to fix a changelog merge conflict |
20a37e9
to
88e2490
Compare
Rebased onto master so tests will pass now that #7175 is merged |
What does this PR (Pull Request) do?
Content-Length
header with every responseContent-Type
andContent-Length
as GET requestsWhich Traffic Control components are affected by this PR?
What is the best way to verify this PR?
Run the following external tests:
If this is a bug fix, what versions of Traffic Control are affected?
The following criteria are ALL met by this PR