We've all heard about HTTP/2, but what's in it for us? Is it really that much better? How can we start using it? During this talk, we will explore HTTP/2's new features while creating our own web server, demonstrating new features like server push, multiplexing and header compression. At then end, we can proof how HTTP/2 benefits not only the end user, but developers and operations as well!.
Tata AIG General Insurance Company - Insurer Innovation Award 2024
HTTP2 in action - Piet Van Dongen - Codemotion Amsterdam 2017
1. AMSTERDAM 16 – 17 MAY 2017
HTTP/2 in action
Piet van Dongen
2. @pietvandongen
About me
Piet van Dongen…
…is a Senior Software Engineer at Luminis Arnhem.
…is a full stack engineer (Java and frontend stuff).
…thinks: people > technology.
…could have just as easily been a teacher.
…should start running again.
3. What are we gonna do till lunch?
What we say we do What it is we do
Introduce the talk
Try to sneak in
Check Twitter / Facebook
Dive into HTTP/2 theory
Try to sneak out again
Sneak siesta
Look at HTTP/2 in practice
Pay attention for a moment
Go back to Tweeting
Create a HTTP/2 server (live!)
Laugh at Piet fumbling
Pray to the demo gods
Answer questions
Sneak out for lunch
Dodge difficult questions
7. 1941
• Jorge Luis Borges' The Garden of Forking Paths
• Hypertekst-fictie
8. • Vannevar Bush's As We May Think
• Essay on the memex (memory + index)
• Proto hypertext system
• Collective memory
• Information explosion
• Knowledge explosion
1945
9. Douglas Engelbart
• 1962: Creates NLS (oN-Line System)
• 1968: The Mother of All Demos
Ted Nelson & Andries van Dam
• 1963: Nelson coins hypertext en
hypermedia
• 1967: With Van Dam: Hypertext
Editing System
• 1976: FRESS (File Retrieval and Editing
System)
1962 – 1976
10. • Aspen Movie Map (funded by (D)ARPA)
• First hypermedia system
1978
11. • Sir Tim Berners Lee bedenkt ENQUIRE (wiki)
• Peter J. Brown bedenkt Guide
• Roberto Busa bedenkt Index Thomisticus
1980
12. • Ben Shneiderman developes TIES (The Interactive
Encyclopedia System)
• First electronic book: Hypertext Hands-On!
1983
14. • Sir Tim Berners Lee (CERN): WorldWideWeb
• HyperText
• Network
• Browsers
1989
15. • 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
26. 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
27. 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
31. 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… change of congestions
• A lot of overhead, especially headers
• Hacks needed: image sprites, data inlining, domain sharding, …
32. 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
34. 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
35. 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
36. 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
37. 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
39. 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
40. 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 asume (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/)