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

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

Transcript of 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

Why a new version of HTTP protocol?

v2

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

The number of requests per page increases

HTTP ArchiveTop 100 sites

data for 15.11.2010 - 1.04.2015

HTTP 1.1 has issues

Optional parts, like HTTP Pipelining

It is very latency sensitive

The specification is huge

HTTP 1.1 issues

and more...

First page load is latency bound

Latency is the constraining factor for today’s applications

Latency vs bandwidth

Ilya GrigorikDeveloper Advocate, Google

What could be the solution?

HTTP pipelining?

WikipediA

The free Encyclopedia

HTTP pipelining

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

In most browsers HTTP pipelining is disabled

Or not implemented at all

Browsers achieve multiplexing by opening multiple connections to servers

As a result...

Developer workarounds

Image sprites1

Sharding2

Resource inlining3

Developers invented workarounds

Concatenating files4

Combo services5

Preloading resources6

Developers invented workarounds

Reducing cookie size7

Using cookie-free domains8

Using <link> instead of @import9

Developers invented workarounds

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

10

Developers invented workarounds

A whole industry has been created to deal with

web site performance

Welcome to HTTP/2

HTTP/2 in a nutshell

Wednesday, 18 February 2015

Status: Done

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

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>

HTTPS

How browser switches to HTTP/2

ALPN

Using Application Layer

Protocol Negotiation extension

HTTP/2 features

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

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

HTTP/2 Features

Frames

Frame format

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

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

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

Streams

Stream

Logical, bi-directional sequence of frames.

Streams

One single connection - multiple open streams.

Priorities and dependencies

Stream priority

Each stream has priority

Specified by the client (browser)

Priority can be changed runtime

Stream dependencies

A stream can depend on another one.

A

B C

D

Stream dependencies

A

B C

D

A stream can depend on another one.

Headers

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

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)

Header compression

HPACK has been invented because of attacks like CRIME and BREACH

Server push(we did that for years)

Server push

Server pre-emptively sends resources to a client,

in association with a previous client-initiated request

Server push

The client explicitly must allow it

A client cannot push

HTTP/2 implementations

Server implementations

Plenty of, grab one and start experimenting!

On the server

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

QUIC protocol

QUIC Features

Natural extension of SPDY and HTTP/2 research

Multiplexing transport protocol

Runs on top of UDP

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

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

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

Has all the benefits of SPDY and HTTP/2

QUIC Features

but...

QUIC Features

No head-of-line blocking in QUIC!

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

QUIC Features

No head-of-line blocking in QUIC!

QUIC Features

100 ms

0 ms RTT Repeat connection

New connection

QUIC TCP + TLS

300 ms

200 ms RTT Repeat connection

New connection

QUIC Encryption

Comparable to TLS, with more efficient handshake

Replay attack and IP Spoofing protection

QUIC Forward error correction

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

Optimizing the Web stack for HTTP/2 era

Optimize the content being served to the browser

Minimizing JavaScript, CSS and HTML files1

Removing redundant data from images2

Optimize Critical Path CSS3

Optimize the content sent to the brower

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

Optimize the server and TCP stack

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

Consider to remove some "optimizations"

Joining files1

Domain sharding2

Resource inlining3

Remove some "optimizations"

Image sprites4

Combo services5

Cookie free domains6

Thank you!

ipeychev