-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
audit: multiple, costly round trips to any origin 🚙 (preconnect) #3106
Comments
If not mistaken everything that is not covered by the preload audit we will ask to preconnect here? Should we consider all domains where we do a minimum of x requests? |
Preload is awesome if you know the exact URL. One approach is that we recommend you preconnect to all origins that are CRC depth >= 2. (depth == 1 excluded because IMO the preloadscanner should kick off those at about the same time). I tried out this recommendation: I found some cases where this would include 20 origins.. I traced it to see if opening a crapton of sockets adds extra overhead and slows down the rest of the pageload. But the results are inconclusive. @igrigorik do you think that one needs to be conservative or might as well go wild and preconnect ALLLL the things? |
My take was that for something like 20 domains, there may be value in the
messaging being ~preconnect to the subset of domains responsible for the
most important content on the page but take care in excessively doing so. I
don't believe the current implementation throttles preconnect in any way
otherwise.
@yoavweiss may also have some thoughts here.
…On Sep 29, 2017 1:44 PM, "Paul Irish" ***@***.***> wrote:
*Preload* is awesome if you know the exact URL.
*Preconnect* is useful if you don't know the exact URL but know the
origin. That applies to a decent amount of 3rd party situations.
One approach is that we recommend you preconnect to all origins that are
CRC depth >= 2. (depth == 1 excluded because IMO the preloadscanner should
kick off those at about the same time).
*I tried out this recommendation:* I found some cases where this would
include 20 origins.. I traced it to see if opening a crapton of sockets
adds extra overhead and slows down the rest of the pageload. But the
results are inconclusive. @igrigorik <https://github.com/igrigorik> do
you think that one needs to be conservative or might as well go wild and
preconnect ALLLL the things?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3106 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGxaenOLwQHLkQA4_kTTCYgzYorc1mCks5snVa_gaJpZM4PArga>
.
|
One issue with the "preconnect all the things!!" approach: Chrome can only send 6 DNS requests at the same time. Preconnecting to unneeded hosts can then stall other DNS requests. Another side effect of that is that if you preconnect, you want to preconnect to all critical hosts in order (or just the first 6 ones). I think a more conservative approach of recommending preconnecting to hosts serving critical or important content makes more sense, at least at first. |
@yoavweiss thanks for weighing in! Appreciate it. |
+1 for Yoav's points. I think we should recommend that you preconnect to a small (N<5) external origins. A large number of origins in critical path is its own anti-pattern, and something we could flag as separate warning -- you're dependent on a lot of origins, consider reducing this number. (As an aside: do we have blocking / SPOF audits? Each additional blocking origin in CRP is an invitation for a SPOF). In addition to the above, an important and overlooked property of preconnect:
So, preconnect to hosts that you will use soon. |
There were reports of preconnect contending on the I/O thread with other more critical activity, such as the Service Worker start. I also got reports of preconnect related delays which were hard to reproduce and seemed related to the extension-based WebPageTest agent, and failed to reproduce in the newer agents. So I don't know of current delays related to over-preconnecting, but it's probably safer to be conservative. |
Sounds good guys. Thanks very much. I summarized this and shared it with loading-dev (https://groups.google.com/a/chromium.org/d/topic/loading-dev/-n6b7byxqGA/discussion) in case there are any more insights we want to incorporate, but I'm already pretty happy with what we have here. We can limit to hosts connected in the first 10s and some sort of sense of priority.
No we don't yet. I'll file a ticket for this. EDIT: filed Audit: SPOF detection · Issue #3463 · GoogleChrome/lighthouse |
This sounds pretty reasonable. Thanks for sharing your input, @igrigorik and @yoavweiss! What I'm hearing (pending further input on the loading-dev thread) is:
Hmmm...I wonder if we should also be flagging over-preconnecting (e.g if a page is trying to preconnect to more than 5 hosts). |
I might create another audit or just add some kind of marking to the table that lists already preconnected domains which are over budget (>10s) and if we go over 5 hosts. |
@paulirish @addyosmani @patrickhulce Not much input was given on the loading-dev thread. So to start on this would this be a good approach. Capture all domains until TTI or below 10s from mainResource and list them as preconnects. (but only the first 5 hosts) |
Hmm, after coming back to this post-preload audit, I'm having trouble seeing the win with a separate preconnect audit. Just to make sure I'm understanding right; we're looking for requests that are..
Perhaps I'm missing something, but it seems like the only requests different from preload will be all the 3+ levels deep critical request chain URLs that we just decided in review to explicitly filter out. If our main concern is third party requests that you don't know the URL ahead of time, this already applies to the URLs we'd be surfacing over in preload and what if we just said "preload if you know the URL, preconnect to the domain if you don't" instead? @addyosmani @paulirish WDYT? |
critical requests 3 levels deep are hardly tagged as critical in our audits as they are hardly have a high priority. Wouldn't it be best to just scan all records before TTI or < 10s? |
From a goals perspective, for third-parties specifically I use preconnect when I want to reduce the connection setup time for an origin but don't want to prioritize fetching (preloading) actual resources from it above other content in the critical path. I know it's really hard coming up with a criteria for capturing the difference here compared to preload otherwise... Hmm. Another option here is doing some sort of special highlighting for third-party domains in the list of preload opportunities where we suggest those be preconnected to if they're not important enough to be preloaded. (effectively, agree with @patrickhulce if we can't define a different set of criteria here that perhaps this comes down to messaging) Any further thoughts @paulirish? |
@addyosmani To return to the Why not just include both i.e. |
This is certainly something we could consider. dns-prefetch has pretty decent cross-browser support: https://caniuse.com/#feat=link-rel-dns-prefetch |
I like this a lot. Let's do this. We have a plan for preconnect, but I think it was just under-documented.
with that done, we can land #4362 |
lets get cracking 😄 |
I generally recommend to preconnect to 3rd party resources which delay the onload event. This helps to save time in dns resolution + ssl connect. The idea of limiting this to 5 sound like a good idea. What's the latest on this? |
@addyosmani @paulirish I think this one is done. Right? |
Fixed by #4362 |
I have Chrome "Version 70.0.3538.110 (Official Build) (64-bit)" , and I am still getting |
@cihati can you file a separate issue with repro steps and the URL for us to take a look? |
FYI, if you're from the future and you're reading this. Some of this info is out of date. The 6 request limit has been updated to 64 (in chromium) unless I'm poorly mistaken.
|
Description: Avoid multiple, costly round trips to any origin
Failure description: Page made 12 round-trips to 3 origins.
Help text: Consider using
<link rel=preconnect>
to set up early connections before an HTTP request is actually sent to the server. This will reduce multiple, costly round trips to any origin.We had previously discussed suggesting
<link rel=dns-prefetch>
to pre-resolve DNS of a specific domain, but per @igrigorik if we're recommending preconnect, dns-prefetch is a no-op and we don't need to recommend both.previously: #873
The text was updated successfully, but these errors were encountered: