HTTP is dead, long live HTTP! 20 years ago, HTTP/1.1 was born and it has served us well. But a lot has changed since the time a single request was often enough to display a web page. Nowadays, web applications need lots of external resources, forcing us into hacky territory. We can do better!
HTTP/2 is here and you can and should use it. No more domain sharding, resource bundling, convoluted hacks. Instead, you get much better performance and security with less work than before. This talk focuses on HTTP's history and its new features: multiplexing, header compression, server push and more!
About Piet van Dongen
By day, Piet is a software engineer at Luminis, where he keeps himself busy doing the whole full stack thing. By night, he sleeps. The rest of the time, he mostly entertains his kids, wife and vacuum cleaner, sometimes locking himself in the bathroom to read his Twitter feed or a book.
1. Those who stand for nothing,
fall for anything - Alexander
Hamilton
I am always doing that which I
can not do, in order that I may
learn how to do it. - Pablo PicassoPiet van Dongen
HTTP/2:
What's new?
2. @pietvandongen
About me
Piet van Dongen
- Senior Software Engineer at Luminis
- Multi-privileged
- One foot in the grave
- Buzzword(s) of the month: product thinking
- Should start running again
3.
4. What's up?
What I do What you do
Introduce the talk Check office mail
Dive into HTTP/2 theory Check Twitter / Facebook / WhatsApp
Look at HTTP/2 in practice Brief moment of attention
Create a HTTP/2 server (live!) Laugh at Piet fumbling
Answer questions Come up with shitty questions
8. 1941
• Jorge Luis Borges' El jardín de senderos que se
bifurcan (The Garden of Forking Paths)
• Hypertext fiction
9. • Vannevar Bush's As We May Think
• Essay on the memex (memory + index)
• Proto hypertext system
• Collective memory
• Information explosion
• Knowledge explosion
1945
10. Douglas Engelbart
• 1962: Creates NLS (oN-Line System)
• 1968: The Mother of All Demos
Ted Nelson & Andries van Dam
• 1963: Nelson coins hypertext and
hypermedia
• 1967: With Van Dam: Hypertext
Editing System
• 1976: FRESS (File Retrieval and Editing
System)
1962 – 1976
11. • Aspen Movie Map (funded by (D)ARPA)
• First hypermedia system
1978
12. • Sir Tim Berners Lee creates ENQUIRE (wiki / web site)
• Peter J. Brown creates Guide (hypertext system)
• Roberto Busa creates Index Thomisticus (text search)
1980
13. • Ben Shneiderman develops TIES (The Interactive
Encyclopedia System)
• First electronic book: Hypertext Hands-On!
1983
15. • Sir Tim Berners Lee (CERN): WorldWideWeb
• HyperText
• Network
• Browsers
1989
16. • HTTP V0.9
• TCP-IP connection
• Request: GET address (no http://, host or port)
• Response: byte stream of ASCII characters
• After transfer: connection close
1991
27. Terminology
• Hypertext Transfer Protocol
• Hypertext: structured text with
linked (text) nodes
• Protocol: to transfer hypertext from
server to clients
• TCP/IP: Internet Protocol Suite
• HTTP is protocol in top layer
(application)
HTTP
TCPUDP
Application
Transport
IP Internet
Ethernet Link
28. The protocol from a bird's eye view
• Client / user agent asks (request)
• Methods: GET, PUT, POST, DELETE, HEAD…
• Server answers (response)
• Status codes: 200 OK, 404 Not Found, 500 Internal Server Error…
• Resources identified by URLs
• protocol://host[:port]/path
32. What is wrong with HTTP/1.1?
• Web pages contain more resources than ever
• Efficient loading using 1 request per HTTP connection is hard
• Parallel is possible, but… chance of congestions
• A lot of overhead, especially headers
• Hacks needed: image sprites, data inlining, domain sharding, …
33. How is HTTP/2 gonna solve that?
• Binary protocol: more efficient parsing, more compact, fewer errors
• Multiplexing:
• Non ordered, interleaved if necessary
• Non blocking, but all data at once
• Just one TCP connection: less congestion, more fair on network
• Header compression with HPACK: more compact and robust
• Server push: pushing data on expected demand
• Compatible with HTTP/1.1
35. Binary protocol
• More efficient, easy to parse
• More compact on the wire
• Harder to read for humans
Application (HTTP)
Transport (TCP)
Network (IP)
Link (Ethernet)
Binary Framing
HEADERS frame
DATA frame
36. Streams, messages, frames
• Stream: bidirectional flow of bytes, contains 1 or more messages
• Message: sequence of frames, map to request of response
• Frame: smalles unit of communication, references stream
Stream 1
HEADERS
Stream 2
HEADERS
Stream 2
DATA
Stream 2
DATA
37. Multiplexing
• Everything on a single connection
• Messages in random order
• No guessing
• No congestion
Stream 5
DATA
Stream 1
DATA
Stream 3
DATA
Stream 3
DATA
Stream 2
DATA
Stream 3
HEADERS
Stream 1
DATA
Stream 2
DATA
Stream 1
DATA
38. Server push
• Multiple response for 1 request
• Serve before request
Stream 1
FRAME 2
Stream 4
FRAME 1
…Stream 1
FRAME n
Stream 4
PROMISE
Stream 2
PROMISE
40. ALPN
• Application-Layer Protocol Negotiation
• TLS extension of application layer ClientHello (ALPN extenstion + list of protocols)
ServerHello (ALPN extenstion + selected protocol)
ChangeCipherSpec
Finished
ChangeCipherSpec
Finished
41. And more…
• Inherently safe (because effectively only TLS)
• Stream prioritisation
• Flow control
*
A
12
B
4
*
D
1
C
8
*
D
1
C
8
A
12
B
4
*
D
1
E
8
A
12
B
4
C
8
50. Requirements
• Java Development Kit (8+)
• Eclipse Vert.x (reactive application toolkit for JVM)
• netty-tcnative-boringssl-static (to dynamicly link TLS-support, no
longer need in Java 9)
• Some HTML, CSS and JavaScript files
• A build / run tool (Gradle in this case)
• A browser (for testing)
52. Demo time!
• Sources can be found at:
https://github.com/pietvandongen/http2-brain-upgrade
pull requests and issues are welcome!
• The Docker container image is at:
https://hub.docker.com/r/pietvandongen/http2-demo-server/
58. Findings and recommendations
• Switch over, but use ALPN
• Try before you assume (push!)
• Start with a web project
• Don't forget the decrypter during debugging
• Read the documentation :)
60. Sources / literature
• https://http2.github.io/: HTTP/2 homepage curated by IETF HTTP
Working Group
• https://developers.google.com/web/fundamentals/performance/
http2/: Introduction to HTTP/2 by Google
• http://vertx.io/: Homepage of Eclipse Vert.x
• Stephen Ludin & Javier Garza, Learning HTTP/2: A Practical Guide for
Beginners (O'Reilly 2017)
• https://hpbn.co/http2/: Chapter 12 of High Performance Browser
Networking (Ilya Grigorik, O'Reilly 2013)
62. Any questions?
• Mail me: piet.vandongen@luminis.eu
• Tweet me: https://twitter.com/pietvandongen
• Link me: https://www.linkedin.com/in/pietvandongencom/
• Visit me at Luminis (https://www.luminis.eu/)