Mark Nottingham
img[0-3].etsystatic.com
- 25 images
Cookie
s, Referer
sTheme: reduce the overhead of HTTP requests
You can use the same HTTP APIs, headers, methods, and status codes, but to get the most out of the protocol, there are a few things to tweak, tune and consider.
All major browsers require encrypted connections for HTTP/2.
Practically speaking, this means https://
Recommendation: Start transitioning to HTTPS now.
Spreading traffic to multiple hosts hurts perf and HTTP/2.
image-cdn.example.com
Why? Increased chance of congestion events, worse header compression.
You can use connection coalescing if DNS and cert agree.
Recommendation: There Can Be Only One (hostname).
Spriting, inlining and concatenation are all techniques to reduce the number of HTTP requests.
In HTTP/2, they can hurt your performance:
Recommendation: Think about a strategy to de-optimise.
In HTTP/1, browsers are responsible for deciding request priority and ordering - and sometimes they get it wrong.
In HTTP/2 it's up to the server (thanks to multiplexing).
Decisions like:
"first-paint times [with #http2] are reduced by about 30% when compared to HTTP/1.1 or SPDY/3.1." http://t.co/yOC4PKve7p
— Daniel Stenberg (@bagder) June 16, 2015
Recommendation: Look for APIs, data and studies.
In principle, push can save you a round trip - putting something in cache before the browser knows it needs it.
In practice, no one is quite sure how to think about push yet.
Recommendation: Experiment and gather data
HPACK is coarse-grained; it works on an an entire header.
Cookie
? No compression for you.X-request-ID
? No compression for you.Default SETTINGS_HEADER_TABLE_SIZE
is 4k.
Recommendation: Reduce header variability.
HTTP/2 Requirements:
HTTP/2 doesn't support client certificates, because no renegotiation.
HTTP_1_1_REQUIRED
error code to force downgrade.SETTINGS
CONTINUATION
Recommendation: ask your vendor/project for h2 support!
For HTTP/1 74% of our active connections carry just a single transaction - persistent connections just aren't as helpful as we all want. But in HTTP/2 that number plummets to 25%.
HTTP/2 thrives with long-lived connections.
Recommendation: Architect and configure for long-lived connections.
HTTP/1 DNS load balancing leverages short connections.
GOAWAY
allows you to tear the the conn gracefully, so you get a new DNS lookup.ALTSVC
will give a better way to balance traffic.
CNAME
inside HTTPhost:port
, and when it's authenticated and ready, treat it as this origin."HTTP/2 removes application-layer issues, but TCP congestion control brings its own.
net.ipv4.tcp_slow_start_after_idle = 0
Do you: