2 and quic protocols - meetupfiles.meetup.com/2301351/http 2.0.pdf · the number of requests per...

73
HTTP/2 and QUIC protocols @ipeychev Optimizing the Web stack for HTTP/2 era

Upload: others

Post on 24-May-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

HTTP/2 and QUIC protocols

@ipeychev

Optimizing the Web stack for HTTP/2 era

Page 2: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Why a new version of HTTP protocol?

v2

Page 3: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

The number of requests per page increases

HTTP ArchiveTop 100 sites

data for 15.11.2010 - 1.04.2015

Page 5: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

HTTP 1.1 has issues

Page 6: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Optional parts, like HTTP Pipelining

It is very latency sensitive

The specification is huge

HTTP 1.1 issues

and more...

Page 7: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

First page load is latency bound

Page 8: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Latency is the constraining factor for today’s applications

Page 9: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Latency vs bandwidth

Ilya GrigorikDeveloper Advocate, Google

Page 10: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

What could be the solution?

Page 11: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

HTTP pipelining?

WikipediA

The free Encyclopedia

Page 12: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

HTTP pipelining

Page 13: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Developer workarounds

Page 16: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Image sprites1

Sharding2

Resource inlining3

Developers invented workarounds

Page 17: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Concatenating files4

Combo services5

Preloading resources6

Developers invented workarounds

Page 18: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Reducing cookie size7

Using cookie-free domains8

Using <link> instead of @import9

Developers invented workarounds

Page 19: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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

10

Developers invented workarounds

Page 20: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

A whole industry has been created to deal with

web site performance

Page 21: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015
Page 22: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Welcome to HTTP/2

Page 23: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

HTTP/2 in a nutshell

Page 24: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Wednesday, 18 February 2015

Status: Done

Page 25: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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

Page 26: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

HTTPS

How browser switches to HTTP/2

ALPN

Using Application Layer

Protocol Negotiation extension

Page 28: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

HTTP/2 features

Page 29: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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

HTTP/2 Features

Page 31: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Frames

Page 32: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Frame format

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

Page 33: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Streams

Page 36: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Stream

Logical, bi-directional sequence of frames.

Page 37: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Streams

One single connection - multiple open streams.

Page 38: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Priorities and dependencies

Page 39: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Stream priority

Each stream has priority

Specified by the client (browser)

Priority can be changed runtime

Page 40: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Stream dependencies

A stream can depend on another one.

A

B C

D

Page 41: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Stream dependencies

A

B C

D

A stream can depend on another one.

Page 42: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Headers

Page 43: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Header compression

HPACK has been invented because of attacks like CRIME and BREACH

Page 46: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Server push(we did that for years)

Page 47: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Server push

Server pre-emptively sends resources to a client,

in association with a previous client-initiated request

Page 48: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Server push

The client explicitly must allow it

A client cannot push

Page 49: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

HTTP/2 implementations

Page 50: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Server implementations

Plenty of, grab one and start experimenting!

Page 51: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

On the server

Page 52: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

QUIC protocol

Page 54: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

QUIC Features

Natural extension of SPDY and HTTP/2 research

Multiplexing transport protocol

Runs on top of UDP

Page 55: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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

Has all the benefits of SPDY and HTTP/2

QUIC Features

but...

Page 58: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

QUIC Features

No head-of-line blocking in QUIC!

Page 59: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

QUIC Features

No head-of-line blocking in QUIC!

Page 61: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

QUIC Encryption

Comparable to TLS, with more efficient handshake

Replay attack and IP Spoofing protection

Page 63: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

QUIC Forward error correction

Page 64: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Optimizing the Web stack for HTTP/2 era

Page 66: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Optimize the content being served to the browser

Page 67: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Minimizing JavaScript, CSS and HTML files1

Removing redundant data from images2

Optimize Critical Path CSS3

Optimize the content sent to the brower

Page 68: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Optimize the server and TCP stack

Page 70: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

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: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Consider to remove some "optimizations"

Page 72: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Joining files1

Domain sharding2

Resource inlining3

Remove some "optimizations"

Image sprites4

Combo services5

Cookie free domains6

Page 73: 2 and QUIC protocols - Meetupfiles.meetup.com/2301351/http 2.0.pdf · The number of requests per page increases HTTP Archive Top 100 sites data for 15.11.2010 - 1.04.2015

Thank you!

ipeychev