HTTP/2 is here!
And why the web needs it
Nilesh Naik
Tata Consultancy Services
• How we got there
• Limitations of HTTP/1.1
• What’s new in HTTP/2
• Best practices of today are anti-patterns in
HTTP/2
• Impact on developer community
• Current implementations
• What’s next
What’s in here -
The web has changed significantly since then
1991
HTTP/0.9
1996
HTTP/1.0
1999
HTTP/1.1
2015
HTTP/2
HTTP Timeline
2009
SPDY
HTTP 0.9 (1991)
GET /index.htm
<html>
<head>
….
</head>
<body>
…
</body>
</html>
HTTP 1.0 (1996)
GET /index.htm HTTP/1.0
User-Agent: mozilla
Accept: text/html
HTTP/1.0 200 OK
<html>
<head>
….
</head>
<body>
…
</body>
</html>
HTTP 1.1 (1999)
GET /index.htm HTTP/1.0
User-Agent: mozilla
Accept: text/html
Connection: keep-alive
HTTP/1.0 200 OK
<html>
<head>
….
</head>
<body>
…
</body>
</html>
First Web Page
Early 90’s – McDonald’s
Single Request – Response model
Not much interaction
MSN
Early 90’s
 Most of the content was sent in response to single
request
 Minimal or no JS
Modern Web page - Amazon
- 308 requests, 8.1 MB data
Modern Web page
 External resources requested
 Multiple requests, Multiple response
Modern Web page - Ads
Much of the site isnt about content, its about Ads.
HTTP abused!
And yes, every TCP connection is closed with a 3-way
connection too!
Open connection: 3-way handshake
SYN
x= rand()
SYN ACK
X+1 y= rand()
ACK
x+1 y+1
Application
Data
0 ms
28 ms
56 ms
84 ms
 More resource intensive than ever before
 HTTP 1.1 was not built to handle that kind of load
 HTTP 1.1 does not use TCP optimally
800K
Transfer size
2300K
Transfer size
80 Objects
100 Objects
In the last 4 years..
HTTP requests are expensive!
Workarounds
SpritingSpriting
Spriting
Text
To get just one flag…
Browser must download
and encode the whole
image
Spriting
Spriting - Contd.
 Makes development harder
 Impacts caching
 Every change would require a fresh download
 Larger files takes longer to download and display on browser
Inlining Resources
Inlining – Contd.
 data: urls instead of sprites
 Resources can’t be cached independently
 Development isn't easy
Concatenation
Merge multiple JavaScript/CSS files into one BIG file
Larger files to download
and parse
Larger files to download
and parse
Whole bundle is invalidated
if a single file changes
Concatenation – contd.
 Too much data when only a little is needed
 Too much to reload when a change is needed
 Annoyance for developers
 Impacts caching
Domain sharding
Browsers use 6-8 connections per host
Domain sharding – contd.
Sites use many host names to allow more connection
Domain sharding on Single Server
domain.com/index.html
images.domain.com/image.png
styles.domain.com/styles.css
Domain sharding – bbc.co.uk
www.bbc.co.uk
static.bbc.co.uk
nav.files.bbci.co.uk
homepage.files.bbci.co.uk
 Still suffers from head of blocking
 Every new connection takes up resources
 Every new host needs a name lookup
*http://yslow.org/
 Useful, but are really just Band-aids
 Annoying for the developers
 Adds a layer of tools
 Hampers caching
 Downloads too much
Hacks
Ideal Protocol Interaction
 Send minimal data to the server
 Download minimal data needed
 Extra data -> more time to transfer, adds latency (especially on mobile networks)
HTTP/1.1
 HTTP/1.x is “chatty”
 Several round-trips, adds latency
Latency vs Bandwidth
Announced in 2009
Target 50% reduction in PLT
Initial tests - 55% faster
On track to de facto standard
Enter HTTP/2 - RFC 7540
 Built on top of
SPDY
 One TCP
Connection
 Improved end-user
perceived latency
 Binary framing
layer
Enter HTTP/2
Connection
Stream
DATA HEADER
Request message
Response message
HEADER HEADERDATA
Stream
PRIORITY HEADER
Request message
Response message
HEADER DATA
…
An HTTP 1.x connection
Response
<HTML>
<HEAD>
--
</HEAD>
<BODY>
--
</BODY>
</HEAD>
Request
GET /index.html HTTP 1.1
User-Agent: mozilla
Accept: text/html
TCP Connection
An HTTP/2 connection
Response
0000100011
0110000100
0000100101
Request
000100010
100100100
001001000
TCP Connection
Demo
• https://http2.akamai.com/demo
Multiplexing
Head of
Line
Blocking
No Queuing
One connection
Many requests
Out of order
interleaved
HTTP/1.1 HTTP/2
Still serialized
Long download/long
think time can block
other requests
Multiplexing – contd.
Multiplexing – network graph
Header Compression
 Unnecessary metadata (headers) add up
quickly
 100+ requests, with few KB of headers ->
hundreds of KB’s!
 Bytes are slow and expensive to transfer
Header Duplication
Header Duplication – contd.
Header Duplication – contd.
Header Duplication – contd.
Header Duplication – contd.
 Four requests
 2,596 bytes total
 1,797 redundant bytes
HPACK – Header Compression - RFC 7541
Compresses Headers
Avoids sending duplicated/repeated headers
Server push
 Similar to Inlining
 Resources pushed directly to client’s cache
 Opportunity for servers to become smarter
– Don’t push on every request
– Push based upon observed traffic pattern
Browser can
reject push
Implementations
 H2O
 mod_h2 (Apache)
Server push – Cache Digest
Process
request
Digest of
/main.js &
/main.css
<html>
<script src="/main.js">
<link rel="stylesheet" href="/main.css">
<link rel=STYLESHEET href="/foo.css">
<body>
… generated response …
Priortization – HTTP/1.x
Priortization – HTTP/1.x
In HTTP/1, Prioritization is a browser heuristic
• CSS and images first, followed by images
Priortization – HTTP/2
Priortization – HTTP/2
In HTTP/2, it’s hinted by the client, determined by the
server
Stream Priority
Stream Weight: <int> 1..256
• Lower the number, higher the priority
Stream Dependency
Stream
Root
Weight: 15
Dependency: {Stream id}
• Streams aren't isolated, they can be dependent on others
• If no dependency then id set to zero.
Dependency Tree
5
5
7
4
HTTP/2 User Impact
Faster page loads
More response loading
More HTTPS
Impact on developers
Does not modify the semantics
Uses binary format instead of text
Debugging can be a problem
No more telnet
Why?
TLS Overhead
• World is moving towards https
already
• ALPN makes impact minimal
• Cost of certificates and
administrative overhead
Browser support
Hosting .NET Apps
IIS 10 on Windows 10
Windows Server 2016
Nginx
Hosting Java Apps
Apache HTTP 2.4.17+
Jetty 9.3+
Tomcat 8.5
Hosting Node Apps
node-http2
node-spdy
ExpressJS 5.0
HTTP/2 on JVM
JDK 8 and upwards required
Include ALPN extensions in class path
Included in JDK 9
Implementations
https://github.com/http2/http2-spec/wiki/Implementations
HTTP/1.x workaround will hurt HTTP/2 perf
Inlining
Spriting
Concatenating
Sharding
Case study
What's next?
QUIC
Runs on top of UDP
Goodness of SPDY and HTTP/2
No head of line blocking in QUIC!
QUIC TCP + TLS
New connection 100 ms
Repeat connnection 0 ms RTT
New connection 300 ms
Repeat connection 200 ms RTT
Thank you!
@NileshRaviNaik

Http2 is here! And why the web needs it