16.03.2017 Views

Learning HTTP/2

akamai-learning-http2-preview-edition

akamai-learning-http2-preview-edition

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

It is then critical to ensure that this resolution process be as fast as possible, by applying<br />

the following best practices:<br />

1. Limit the number of unique domains/hostnames. Of course this is not always in<br />

your control, however as we’ll see in the sharding section, the relative performance<br />

impact of the number of unique hostnames will only grow when moving<br />

to <strong>HTTP</strong>/2<br />

2. Ensure low resolution latencies. Understand the topology of your DNS serving<br />

infrastructure and perform regular resolution time measurements from all the<br />

locations where your end users are (you can achieve this by using synthetic/real<br />

user monitoring). If you decide to rely on a third party provider, select one best<br />

suited to your needs, as they can offer wide differences of service quality.<br />

3. Leverage DNS prefetch from your initial html or response. This will start DNS<br />

resolution of all the hostnames on the page while the initial html is being downloaded<br />

and processed. For instance, see below the effect of DNS prefetching a<br />

google api hostname in a webpagetest waterfall. Note the dark blue piece representing<br />

the DNS resolution happening before the actual request is initiated:<br />

Figure 4.2 - DNS prefetch<br />

Figure 4.3 - Timeline object<br />

Optimize TCP connections<br />

Opening a TCP connection between a client and a serving origin is an expensive process.<br />

At the minimum, a non-secure (<strong>HTTP</strong>) connection involves a request-response<br />

round trip and some dedicated resource (memory + CPU) at both ends. A secure<br />

connection (<strong>HTTP</strong>S) generally incurs additional latency caused by 2 more round<br />

trips between the client and the origin server. If the client and servers are on opposite<br />

ends of the US, a total of 3 round-trips will take place before the connection is established,<br />

taking up to 250 ms, so you ought to carefully manage your connections. Recommended<br />

mitigations include:<br />

1. Leverage Preconnect, as it will remove connection times from the waterfall critical<br />

path<br />

2. Use a CDN. CDNs will terminate the http/s connection at the edge, located close<br />

to the requesting client, and therefore can greatly minimize the round trip latencies<br />

incurred by establishing a new connection.<br />

3. Implement the latest TLS best practices. (<strong>HTTP</strong>S only)<br />

Best Practices for Web Performance | 15

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!