Top Banner
HTTP/2 and QUIC protocols @ipeychev Optimizing the Web stack for HTTP/2 era
73
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

HTTP/2 and QUIC protocols

@ipeychev

Optimizing the Web stack for HTTP/2 era

Page 2: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Why a new version of HTTP protocol?

v2

Page 3: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

HTTP has been in use by the World-Wide Web global information initiative since 1990

Browser sends request to the server

Server responds

GET /index.html HTTP/1.1

HTTP/1.1 200 OK

Page 4: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

The number of requests per page increases

HTTP ArchiveTop 100 sites

data for 15.11.2010 - 1.04.2015

Page 5: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

HTTP 1.1 has issues

Page 6: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Optional parts, like HTTP Pipelining

It is very latency sensitive

The specification is huge

HTTP 1.1 issues

and more...

Page 7: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

First page load is latency bound

Page 8: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Latency is the constraining factor for today’s applications

Page 9: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Latency vs bandwidth

Ilya GrigorikDeveloper Advocate, Google

Page 10: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

What could be the solution?

Page 11: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

HTTP pipelining?

WikipediA

The free Encyclopedia

Page 12: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

HTTP pipelining

Page 13: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Why not HTTP Pipelining?

The server must send its responses in the same order that requests were received

So the entire connection remains first-in-first-out (FIFO) and Head-of-line (HOL) blocking can occur

and more, like buggy proxy servers

Page 14: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

In most browsers HTTP pipelining is disabled

Or not implemented at all

Browsers achieve multiplexing by opening multiple connections to servers

As a result...

Page 15: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Developer workarounds

Page 16: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Image sprites1

Sharding2

Resource inlining3

Developers invented workarounds

Page 17: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Concatenating files4

Combo services5

Preloading resources6

Developers invented workarounds

Page 18: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Reducing cookie size7

Using cookie-free domains8

Using <link> instead of @import9

Developers invented workarounds

Page 19: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Pack components into a multipart document (like email with attachments)

10

Developers invented workarounds

Page 20: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

A whole industry has been created to deal with

web site performance

Page 21: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era
Page 22: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Welcome to HTTP/2

Page 23: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

HTTP/2 in a nutshell

Page 24: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Wednesday, 18 February 2015

Status: Done

Page 25: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

HTTP/2 fixes issues in HTTP 1.1 without breaking the web

Page 26: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Using HTTP Upgrade

mechanismHTTP

How browser switches to HTTP/2

GET / HTTP/1.1 Host: server.example.com Connection: Upgrade, HTTP2-Settings Upgrade: h2c HTTP2-Settings: <base64url encoding of HTTP/2 SETTINGS payload>

Page 27: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

HTTPS

How browser switches to HTTP/2

ALPN

Using Application Layer

Protocol Negotiation extension

Page 28: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

HTTP/2 features

Page 29: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

HTTP/2 Features

It is a binary protocol, not text one

Browser and server exchange frames

Each frame belongs to stream

Streams are multiplexed, with priorities

Server push

Page 30: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

ONE connection to the server should be enough(not six connections per domain as most browsers do now)

HTTP/2 Features

Page 31: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Frames

Page 32: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Frame format

+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +=+=============================================================+ | Frame Payload (0...) ... +---------------------------------------------------------------+

Page 33: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Frame types

DATA Convey arbitrary data associated with a stream

HEADERS Used to open a stream and carries name-value pairs

PRIORITY Specifies the sender-advised priority of a stream

RST_STREAM Allows abnormal termination of a stream

SETTINGSConveys configuration parameters that affect how endpoints

communicate

Page 34: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Frame types

PUSH_PROMISEUsed to notify the peer endpoint in advance of streams the sender

intends to initiate

PINGMeasuring a minimal round-trip time from the sender; checks if a

connection is still alive

GOAWAY Informs the remote peer to stop creating streams on this connection

WINDOW_UPDATEUsed to implement flow control on each individual stream or on the

entire connection.

CONTNUATION Used to continue a sequence of header block fragments

Page 35: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Streams

Page 36: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Stream

Logical, bi-directional sequence of frames.

Page 37: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Streams

One single connection - multiple open streams.

Page 38: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Priorities and dependencies

Page 39: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Stream priority

Each stream has priority

Specified by the client (browser)

Priority can be changed runtime

Page 40: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Stream dependencies

A stream can depend on another one.

A

B C

D

Page 41: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Stream dependencies

A

B C

D

A stream can depend on another one.

Page 42: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Headers

Page 43: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Header compression

HTTP/2 is stateless protocol too

The client still has to send data to the server

The headers in HTTP/2 are compressed

Page 44: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Header compression

StatefulOne compression context and one

decompression context is used for the entire connection

The algorithm is called HPACK (Header Compression for HTTP/2)

Page 45: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Header compression

HPACK has been invented because of attacks like CRIME and BREACH

Page 46: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Server push(we did that for years)

Page 47: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Server push

Server pre-emptively sends resources to a client,

in association with a previous client-initiated request

Page 48: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Server push

The client explicitly must allow it

A client cannot push

Page 49: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

HTTP/2 implementations

Page 50: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Server implementations

Plenty of, grab one and start experimenting!

Page 51: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

On the server

Page 52: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Browser implementations

Internet Explorer supports HTTP/2 from IE 11 on Windows 10 beta

Firefox has enabled HTTP/2 by default in version 34

Chrome supports HTTP/2, enabled by default. Chrome Canary supports identifying servers using the latest draft (h2-17)

Opera supports HTTP/2 by default

(does someone know anything about Safari?)

Currently only HTTP/2 over TLS is implemented in all browsers

Page 53: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

QUIC protocol

Page 54: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

QUIC Features

Natural extension of SPDY and HTTP/2 research

Multiplexing transport protocol

Runs on top of UDP

Page 55: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Why not SCTP over DTLS?

After all, SCTP provides (among other things) stream multiplexing

And DTLS provides SSL quality encryption and authentication over a UDP stream

Page 56: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Why not SCTP over DTLS?

Mainly because roughly 4 round trips are needed to establish an SCTP over DTLS connection

In contrast, the goal of QUIC is to perform a connection establishment with zero RTT overhead

Page 57: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Goal: 0-RTT (round-trip time) connectivity overhead

Has all the benefits of SPDY and HTTP/2

QUIC Features

but...

Page 58: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

QUIC Features

No head-of-line blocking in QUIC!

Page 59: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

QUIC Features

Delay of only one packet causes the entire set of SPDY (aka HTTP/2) streams to pause.

(Since TCP only provides a single serialized stream interface)

In QUIC, when a single packet is lost, only one stream is being delayed

Page 60: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

QUIC Features

No head-of-line blocking in QUIC!

Page 61: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

QUIC Features

100 ms

0 ms RTT Repeat connection

New connection

QUIC TCP + TLS

300 ms

200 ms RTT Repeat connection

New connection

Page 62: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

QUIC Encryption

Comparable to TLS, with more efficient handshake

Replay attack and IP Spoofing protection

Page 63: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

QUIC Forward error correction

Page 64: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

QUIC Internet connections persistence

Communication channels are not defined by IP+Port but by an ID

You leave a WiFi zone and entering a mobile one but the connection continues

Page 65: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Optimizing the Web stack for HTTP/2 era

Page 66: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Optimize the content being served to the browser

Page 67: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Minimizing JavaScript, CSS and HTML files1

Removing redundant data from images2

Optimize Critical Path CSS3

Optimize the content sent to the brower

Page 68: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Removing the CSS which is not needed on the page4

Specifying ETag and setting far future expires headers5

Using HTML 5 offline to store already downloaded files6

Optimize the content sent to the brower

Page 69: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Optimize the server and TCP stack

Page 70: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Set the value of TCP’s initial cwnd to 10 segments (IW10)1

Disable Slow-Start Restart after idle2

Check and enable if needed Window Scaling3

Optimize the content sent to the browser

Consider to use TCP Fast Open (TFO)4

Page 71: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Consider to remove some "optimizations"

Page 72: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Joining files1

Domain sharding2

Resource inlining3

Remove some "optimizations"

Image sprites4

Combo services5

Cookie free domains6

Page 73: HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era

Thank you!

ipeychev