Http2 is here! And why the web needs it
-
Upload
indicthreads -
Category
Software
-
view
503 -
download
2
Transcript of Http2 is here! And why the web needs it
HTTP/2 is here!And why the web needs it
Nilesh NaikTata 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
1991HTTP/0.9
1996HTTP/1.0
1999HTTP/1.1
2015HTTP/2
HTTP Timeline
2009SPDY
HTTP 0.9 (1991)
GET /index.htm
<html><head> ….
</head><body>
…</body>
</html>
HTTP 1.0 (1996)
GET /index.htm HTTP/1.0User-Agent: mozillaAccept: text/html
HTTP/1.0 200 OK<html>
<head> ….
</head><body>
…</body>
</html>
HTTP 1.1 (1999)
GET /index.htm HTTP/1.0User-Agent: mozillaAccept: text/htmlConnection: keep-alive
HTTP/1.0 200 OK<html>
<head> ….
</head><body>
…</body>
</html>
First Web Page
Early 90’s – McDonald’s
Single Request – Response modelNot 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
SYNx= rand()
SYN ACKX+1 y= rand()
ACKx+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 downloadand 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 downloadand parse
Larger files to downloadand 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 shardingBrowsers use 6-8 connections per host
Domain sharding – contd.Sites use many host names to allow more connection
index.html
style.css
image.png
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.ukstatic.bbc.co.uknav.files.bbci.co.ukhomepage.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 HEADERRequest message
Response messageHEADER HEADERDATA
Stream
PRIORITY HEADERRequest message
Response messageHEADER DATA
…
An HTTP 1.x connection
Response<HTML> <HEAD> -- </HEAD> <BODY> -- </BODY></HEAD>
RequestGET /index.html HTTP 1.1User-Agent: mozillaAccept: text/html
TCP Connection
An HTTP/2 connection
Response000010001101100001000000100101
Request000100010100100100001001000
TCP Connection
Demo
• https://http2.akamai.com/demo
Multiplexing
GET /foo
200 OK
GET /bar
200 OK 200 OK
200 OK
200 OK
200 OK
GET /fooGET /bar
GET /baz
GET /saz
GET /taz
GET /taz
Head of Line Blocking
No QueuingOne connectionMany requestsOut of orderinterleaved
HTTP/1.1 HTTP/2
Still serializedLong 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 HeadersAvoids 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
GET / index.html
200 OK
GET /style.css
200 OK
GET / index.html
200 OK
200 OK
Browser can reject push
Implementations
H2O
mod_h2 (Apache)
Server push – Cache DigestGET / foo
Push /foo.css
200 OK
CACHE_DIGEST
Process requestDigest 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 ImpactFaster 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 problemNo more telnetWhy?
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 10Windows Server 2016Nginx
Hosting Java Apps
Apache HTTP 2.4.17+Jetty 9.3+Tomcat 8.5
Hosting Node Apps
node-http2node-spdyExpressJS 5.0
HTTP/2 on JVMJDK 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
InliningSpriting
ConcatenatingSharding
Case study
What's next?
QUICRuns 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