SPDY and HTTP/2
-
Upload
fabian-frank -
Category
Technology
-
view
577 -
download
0
Transcript of SPDY and HTTP/2
![Page 1: SPDY and HTTP/2](https://reader031.fdocuments.us/reader031/viewer/2022020218/55a793a61a28ab46138b456c/html5/thumbnails/1.jpg)
SPDY and HTTP/2and NPN and ALPN
![Page 2: SPDY and HTTP/2](https://reader031.fdocuments.us/reader031/viewer/2022020218/55a793a61a28ab46138b456c/html5/thumbnails/2.jpg)
HTTP/1.1• One request per connection, sequentially
• First in, first out without cancellation
• Has to open multiple TCP connections
• TCP handshake takes round trips
• increasing the TCP window takes round trips
• SSL handshake takes even more…
![Page 3: SPDY and HTTP/2](https://reader031.fdocuments.us/reader031/viewer/2022020218/55a793a61a28ab46138b456c/html5/thumbnails/3.jpg)
HTTP/1.1
• Human readable, hard to parse
• Keep-Alive dilemma
• waste resources keeping connections open, or reopening them?
• Tricks: inlining, JS/CSS concatenation, sprites, domain sharding
![Page 4: SPDY and HTTP/2](https://reader031.fdocuments.us/reader031/viewer/2022020218/55a793a61a28ab46138b456c/html5/thumbnails/4.jpg)
SPDY• Google “proprietary”, but widely supported
• Android 4.1+, iOS 8, Chrome, Firefox, Safari, but not IE
• nginx, Jetty, ATS…
• Only on top of SSL
• Used widely in production (Google, Twitter, Yahoo…)
![Page 5: SPDY and HTTP/2](https://reader031.fdocuments.us/reader031/viewer/2022020218/55a793a61a28ab46138b456c/html5/thumbnails/5.jpg)
HTTP/2• SPDY being standardized by the IETF
• Not widely supported
• Chrome Canary, Firefox Nightly
• Jetty, twitter.com, google.com
• Specified with and without SSL, but browsers will not support plain text (but IE will)
![Page 6: SPDY and HTTP/2](https://reader031.fdocuments.us/reader031/viewer/2022020218/55a793a61a28ab46138b456c/html5/thumbnails/6.jpg)
Negotiating transport• Two TLS extensions to negotiate application layer
transport
• NPN, came with SPDY
• ALPN, came with HTTP/2
• You will have to support both
• Then: End to end encryption
• Intermediaries don’t know and can’t care about transport
![Page 7: SPDY and HTTP/2](https://reader031.fdocuments.us/reader031/viewer/2022020218/55a793a61a28ab46138b456c/html5/thumbnails/7.jpg)
NPN
• C: ClientHello (NPN)
• S: ServerHello (NPN, list of protocols), Keys, Certificates
• C: Keys, Certificates
• Client picks its preferred protocol from the list provided by the server
![Page 8: SPDY and HTTP/2](https://reader031.fdocuments.us/reader031/viewer/2022020218/55a793a61a28ab46138b456c/html5/thumbnails/8.jpg)
ALPN
• C: ClientHello (ALPN, list of protocols)
• S: ServerHello (ALPN, selected protocol), Keys, Certificates
• C: Keys, Certificates
• Server controls which protocol will be used
![Page 9: SPDY and HTTP/2](https://reader031.fdocuments.us/reader031/viewer/2022020218/55a793a61a28ab46138b456c/html5/thumbnails/9.jpg)
![Page 10: SPDY and HTTP/2](https://reader031.fdocuments.us/reader031/viewer/2022020218/55a793a61a28ab46138b456c/html5/thumbnails/10.jpg)
![Page 11: SPDY and HTTP/2](https://reader031.fdocuments.us/reader031/viewer/2022020218/55a793a61a28ab46138b456c/html5/thumbnails/11.jpg)
HTTP/2 and SPDY
• Preserve HTTP/1.1 paradigms
• There are still GET, POST and so on requests
• URLs stay the same, requesting a path
• All headers are still there, cookies, etc.
![Page 12: SPDY and HTTP/2](https://reader031.fdocuments.us/reader031/viewer/2022020218/55a793a61a28ab46138b456c/html5/thumbnails/12.jpg)
HTTP/2 and SPDY• Easy to parse binary, length prefixed…
• but not human readable (without tools)
• 100+ requests (streams) in one connection
• concurrently, with dynamic priority, “all mixed up”
• cancellation
• Cheaper requests
• header compression
![Page 13: SPDY and HTTP/2](https://reader031.fdocuments.us/reader031/viewer/2022020218/55a793a61a28ab46138b456c/html5/thumbnails/13.jpg)
Multiplexing• Stream consists of a series of frames
• Type, Stream ID, payload
• Order of frames in the TCP connection does not matter
• Order of frames in a stream matters
• Client can reset (cancel) any stream at any time
![Page 14: SPDY and HTTP/2](https://reader031.fdocuments.us/reader031/viewer/2022020218/55a793a61a28ab46138b456c/html5/thumbnails/14.jpg)
Deployment• Popular reverse proxies (nginx) support SPDY, easy
to enable in config
• SPDY is transparent to your web app
• You want everything on one - or a low number of - host(s)
• Reverse proxy can terminate SPDY, talk HTTP/1.1 to application server
• Then measure real users, not the Bay Area
![Page 15: SPDY and HTTP/2](https://reader031.fdocuments.us/reader031/viewer/2022020218/55a793a61a28ab46138b456c/html5/thumbnails/15.jpg)
HTTP/2 risks• One lost packet stalls the TCP stream
• meaning, all 100+ HTTP/2 streams inside it
• “head of line blocking”
• Intermediary throttles per TCP stream
• Can’t bypass that with only 1 TCP connection
• Next Idea: Userland “TCP” over UDP, QUIC
![Page 16: SPDY and HTTP/2](https://reader031.fdocuments.us/reader031/viewer/2022020218/55a793a61a28ab46138b456c/html5/thumbnails/16.jpg)
Demo