SlideShare uma empresa Scribd logo
1 de 50
Baixar para ler offline
HTTP/2 
What’s inside and why 
@adrianfcole
introduction 
http as we know it 
http performance 
hello http/2! 
firefox 
wrapping up
introduction 
http as we know it 
http performance 
hello http/2! 
firefox 
wrapping up
@adrianfcole 
• staff engineer at Twitter 
• founded apache jclouds 
• focus on cloud computing
introduction 
http as we know it 
http performance 
hello http/2! 
firefox 
wrapping up
http/1.1 
• rfc2616 - June 1999 
• text-based framing 
• defined semantics of the web 
http://www.w3.org/Protocols/rfc2616/rfc2616.html
FYI: RFC 2616 is dead! 
• RFC 7230-5 replaces RFC 2616. 
• Checkout details on www.mnot.net/blog
Latency is a product 
concern 
How you minimize 
latency is an IT concern 
@jpinner
Latency of http/1.1 
368! 
keepalive
Ask Ilya why! 
• TCP connections need 3- 
way handshake. 
• TLS requires up to 2 
more round-trips. 
• Read High Performance 
Browser Networking 
http://chimera.labs.oreilly.com/books/1230000000545
HTTP nowadays 
• Web pages are often >1 MB and >100 
requests. 
• Http headers can be larger than its data. 
• More people on mobile, and latency adds up.
introduction 
http as we know it 
http performance 
hello http/2! 
firefox 
wrapping up
Performance strategies 
• Increasing connections 
• Reducing requests
Increasing connections 
• Requests and responses are ordered on a 
connection. 
• To render the page quicker, multiple 
connections can be used, usually 6. 
• some shard sites to get more than that! 
• Browsers handle scheduling and priority of 
these connections.
reducing requests 
• Caching - RFC 7234 change headers 
• Hacks - change content
Content hacks 
• Spriting - many images into a sheet, chop 
with css. 
• Data uris - encode images in the img tag 
• Concatenation - bundle javascript or css 
into the same file
Spriting 
• #prev { 
• left: 63px; 
• width: 43px; 
• background: url('img_navsprites.gif') -47px 0; 
• } 
• #next { 
• left: 129px; 
• width: 43px; 
• background: url('img_navsprites.gif') -91px 0; 
• } 
http://www.w3schools.com/css/css_image_sprites.asp
Data Uri 
• <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA 
• AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/ 
w38GIAXDIBKE0DHxgljNBAAO 
• 9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" /> 
http://en.wikipedia.org/wiki/Data_URI_scheme
introduction 
http as we know it 
http performance 
hello http/2! 
firefox 
wrapping up
spdy/3.1 
• google - Sep 2013 
• binary framing 
• retains http/1.1 semantics 
• concurrent multiplexed streams 
http://www.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3-1
http/2 
• ietf draft 16 - June 2014 
• binary framing 
• retains http/1.1 semantics 
• concurrent multiplexed streams 
https://github.com/http2/http2-spec
HTTP/2 Delivers 
• Avoids head-of-line blocking by framing 
multiplexed http over a single connection. 
• Identifies request streams allowing 
prioritization, flow control and cancelation. 
• Reduces impact of headers by compressing 
them.
multiplexing 
priority 
flow control 
header compression 
server push 
http/2 headline features
multiplexing 
priority 
flow control 
header compression 
server push 
http/2 headline features
Looking at the whole 
message 
Request: request line, headers, and body 
Response: status line, headers, and body
http/1.1 round-trip 
Content-Length: 318 
Cache-Control: private, max-age=60, s-maxage= 
0 
Vary: SecurityToken 
Date: Sun, 02 Feb 2014 20:30:38 GMT 
Content-Type: application/json 
Content-Encoding: gzip 
GZIPPED DATA 
GET /things HTTP/1.1 
Host: apihost 
SecurityToken: b08c85073c1a2d02 
Accept: application/json 
Accept-encoding: gzip, deflate 
HTTP/1.1 200 OK
http/2 round-trip 
:status: 200 
content-length: 318 
cache-control: private, max-age=60, s-maxage= 
0 
vary: SecurityToken 
date: Sun, 02 Feb 2014 20:30:38 GMT 
content-type: application/json 
GZIPPED DATA 
HEADERS 
Stream: 3 
Flags: END_HEADERS, END_STREAM 
:method: GET 
:authority: apihost 
:path: /things 
securitytoken: b08c85073c1a2d02 
accept: application/json 
HEADERS 
Stream: 3 
Flags: END_HEADERS 
DATA 
Stream: 3 
Flags: END_STREAM
interleaving 
HEADERS 
Stream: 5 
Flags: END_HEADERS, END_STREAM 
HEADERS 
Stream: 3 
Flags: END_HEADERS 
DATA 
Stream: 5 
Flags: 
DATA 
Stream: 5 
Flags: END_STREAM 
HEADERS 
Stream: 3 
Flags: END_HEADERS, END_STREAM 
HEADERS 
Stream: 5 
Flags: END_HEADERS 
DATA 
Stream: 3 
Flags: END_STREAM
Canceling a Stream 
HEADERS 
Stream: 5 
Flags: END_HEADERS, END_STREAM 
HEADERS 
Stream: 3 
Flags: END_HEADERS 
DATA 
Stream: 5 
Flags: 
HEADERS 
Stream: 3 
Flags: END_HEADERS, END_STREAM 
HEADERS 
Stream: 5 
Flags: END_HEADERS 
DATA 
Stream: 3 
Flags: END_STREAM 
RST_STREAM 
Stream: 5 
ErrorCode: CANCEL
control frames 
HEADERS 
Stream: 5 
HEADERS 
Stream: 3 
DATA 
Stream: 5 
DATA 
Stream: 3 
HEADERS 
Stream: 3 
HEADERS 
Stream: 5 
SETTINGS 
Stream: 0 
SETTINGS 
Stream: 0 
DATA 
Stream: 5
multiplexing 
priority 
flow control 
header compression 
server push 
http/2 headline features
priority 
HEADERS 
Stream: 3 
Flags: END_HEADERS, END_STREAM 
Exclusive: 0; Stream Dependency: 1, Weight: 10 
HEADERS 
Stream: 5 
Flags: END_HEADERS, END_STREAM 
Exclusive: 0; Stream Dependency: 1, Weight: 20 
HEADERS 
Stream: 3 
Flags: END_HEADERS 
HEADERS 
Stream: 5 
Flags: END_HEADERS 
DATA 
Stream: 5 
Flags: 
DATA 
Stream: 5 
Flags: END_STREAM 
DATA 
Stream: 3 
Flags: END_STREAM 
• Both streams shouldn’t 
progress before their parent. 
Weight is relative. 
data might be sent earlier
multiplexing 
priority 
flow control 
header compression 
server push 
http/2 headline features
flow control 
HEADERS 
Stream: 3 
Flags: END_HEADERS 
DATA 
Stream: 3 
Flags: 
WINDOW_UPDATE 
Stream: 3 
you can send 8k more data Increment: 8192 
DATA 
Stream: 3 
Flags: END_STREAM 
HEADERS 
Stream: 3 
Flags: END_HEADERS 
• flow control: send up to the 
lesser of stream window and 
connection window (stream 0)
multiplexing 
priority 
flow control 
header compression 
server push 
http/2 headline features
http/1.1 headers 
168! 
Content-Length: 318 
Cache-Control: private, max-age=60, s-maxage= 
0 
Vary: SecurityToken 
Date: Sun, 02 Feb 2014 20:30:38 GMT 
Content-Type: application/json 
Content-Encoding: gzip 
GZIPPED DATA 
GET /things HTTP/1.1 
Host: apihost 
SecurityToken: b08c85073c1a2d02 
Accept: application/json 
Accept-encoding: gzip, deflate 
HTTP/1.1 200 OK 
195! 
318 
• You can gzip 
data, but not 
headers!
header compression 
8 bytes 
52 bytes compressed 
:status: 200 
content-length: 318 
cache-control: private, max-age=60, s-maxage=0 
vary: SecurityToken 
date: Sun, 02 Feb 2014 20:30:38 GMT 
content-type: application/json 
content-encoding: gzip 
GZIPPED DATA 
HEADERS 
Stream: 3 
Flags: END_HEADERS, END_STREAM 
:method: GET 
:authority: apihost 
:path: /things 
securitytoken: b08c85073c1a2d02 
accept: application/json 
accept-encoding: gzip, deflate 
HEADERS 
Stream: 3 
Flags: END_HEADERS 
DATA 
Stream: 3 
Flags: END_STREAM 
8 bytes 
85 bytes compressed 
• 161 byte overhead 
instead of 363 8 bytes
indexed headers! 
8 bytes 
28 bytes compressed 
:status: 200 
content-length: 318 
cache-control: private, max-age=60, s-maxage=0 
vary: SecurityToken 
date: Sun, 02 Feb 2014 20:30:39 GMT 
content-type: application/json 
content-encoding: gzip 
GZIPPED DATA 
HEADERS 
Stream: 3 
Flags: END_HEADERS, END_STREAM 
:method: GET 
:authority: apihost 
:path: /things 
securitytoken: b08c85073c1a2d02 
accept: application/json 
accept-encoding: gzip, deflate 
HEADERS 
Stream: 3 
Flags: END_HEADERS 
DATA 
Stream: 3 
Flags: END_STREAM 
8 bytes 
30 bytes compressed 
• 82 byte overhead 
instead of 363 8 bytes
hpack 
• ietf draft 10 - Dec 2014 
• static and dynamic table 
• huffman encoding 
http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-10
multiplexing 
priority 
flow control 
header compression 
server push 
http/2 headline features
push promise 
HEADERS 
Stream: 3 
:method: GET 
:path: /things 
... 
HEADERS 
Stream: 3 
PUSH_PROMISE 
Stream: 3 
Promised-Stream: 4 
:method: GET 
:path: /users/0 
... 
HEADERS 
Stream: 4 
DATA 
Stream: 4 
push 
response 
goes into 
cache 
DATA 
Stream: 3 
Server guesses a 
future request or 
indicates a cache 
invalidation
Opportunities 
Better utilize TCP 
Better long-tail latency 
Avoid content hacks 
Less buffer bloat
Challenges 
Higher impact of TCP Slow start 
Fairness on the network 
Server and browser support 
debugging a binary protocol 
Writing for tomorrow, with today’s TLS
introduction 
http as we know it 
http performance 
hello http/2! 
firefox 
wrapping up
Firefox 
• Supports latest drafts 
• source/netwerk/protocol/http 
• http/2 lead: Patrick McManus 
https://wiki.mozilla.org/Networking/http2
Try out http2 with Firefox! 
enable http2 in about:config 
hit https://h2duo.cloudapp.net/ with Network Tools on
Push promise in Firefox 
Push promises are sent into a per-session 
memory cache. 
When the client requests the pushed resources, 
they are committed to the disk cache. 
Allows a cap and easy discard of unused pushes. 
http://bitsup.blogspot.com/2014/12/ 
firefox-gecko-api-for-http2-push.html
introduction 
http as we know it 
http performance 
hello http/2! 
firefox 
wrapping up
Engage! 
• Get your web sites running http/2 or spdy! 
• Spread the word and get involved in http/2. 
• Provide feedback to httpbis! 
https://github.com/http2/http2-spec/wiki/Implementations 
https://github.com/http2/http2-spec
Thank you! 
yes, twitter is hiring! 
yes, twitter runs http/2! 
github http2/http2-spec 
@adrianfcole

Mais conteúdo relacionado

Mais procurados

Http/2 - What's it all about?
Http/2  - What's it all about?Http/2  - What's it all about?
Http/2 - What's it all about?
Andy Davies
 

Mais procurados (20)

Http2 right now
Http2 right nowHttp2 right now
Http2 right now
 
HTTP2 is Here!
HTTP2 is Here!HTTP2 is Here!
HTTP2 is Here!
 
HTTP/2: What no one is telling you
HTTP/2: What no one is telling youHTTP/2: What no one is telling you
HTTP/2: What no one is telling you
 
HTTP2:新的机遇与挑战
HTTP2:新的机遇与挑战HTTP2:新的机遇与挑战
HTTP2:新的机遇与挑战
 
Efficient HTTP Apis
Efficient HTTP ApisEfficient HTTP Apis
Efficient HTTP Apis
 
Introducing HTTP/2
Introducing HTTP/2Introducing HTTP/2
Introducing HTTP/2
 
Introduction to HTTP/2
Introduction to HTTP/2Introduction to HTTP/2
Introduction to HTTP/2
 
Http/2 - What's it all about?
Http/2  - What's it all about?Http/2  - What's it all about?
Http/2 - What's it all about?
 
HTTP/2 - for TCP/IP Geeks Stockholm
HTTP/2 - for TCP/IP Geeks StockholmHTTP/2 - for TCP/IP Geeks Stockholm
HTTP/2 - for TCP/IP Geeks Stockholm
 
HTTP 2.0 Why, How and When
HTTP 2.0 Why, How and WhenHTTP 2.0 Why, How and When
HTTP 2.0 Why, How and When
 
HTTP2 & HPACK #pyfes 2013-11-30
HTTP2 & HPACK #pyfes 2013-11-30HTTP2 & HPACK #pyfes 2013-11-30
HTTP2 & HPACK #pyfes 2013-11-30
 
So that was HTTP/2, what's next?
So that was HTTP/2, what's next?So that was HTTP/2, what's next?
So that was HTTP/2, what's next?
 
HTTP 2.0 – What do I need to know?
HTTP 2.0 – What do I need to know? HTTP 2.0 – What do I need to know?
HTTP 2.0 – What do I need to know?
 
HTTP/2 standard for video streaming
HTTP/2 standard for video streamingHTTP/2 standard for video streaming
HTTP/2 standard for video streaming
 
O'Reilly Fluent Conference: HTTP/1.1 vs. HTTP/2
O'Reilly Fluent Conference: HTTP/1.1 vs. HTTP/2O'Reilly Fluent Conference: HTTP/1.1 vs. HTTP/2
O'Reilly Fluent Conference: HTTP/1.1 vs. HTTP/2
 
SPDY and HTTP/2
SPDY and HTTP/2SPDY and HTTP/2
SPDY and HTTP/2
 
Http2 kotlin
Http2   kotlinHttp2   kotlin
Http2 kotlin
 
SPDY - or maybe HTTP2.0
SPDY - or maybe HTTP2.0SPDY - or maybe HTTP2.0
SPDY - or maybe HTTP2.0
 
HTTP/2 Changes Everything
HTTP/2 Changes EverythingHTTP/2 Changes Everything
HTTP/2 Changes Everything
 
Altitude San Francisco 2018: Programming the Edge
Altitude San Francisco 2018: Programming the EdgeAltitude San Francisco 2018: Programming the Edge
Altitude San Francisco 2018: Programming the Edge
 

Semelhante a HTTP/2 What's inside and Why

CSU33012-I-microservices.pdf
CSU33012-I-microservices.pdfCSU33012-I-microservices.pdf
CSU33012-I-microservices.pdf
Ricky Garg
 

Semelhante a HTTP/2 What's inside and Why (20)

Introduction to HTTP/2
Introduction to HTTP/2Introduction to HTTP/2
Introduction to HTTP/2
 
Revisiting HTTP/2
Revisiting HTTP/2Revisiting HTTP/2
Revisiting HTTP/2
 
20190516 web security-basic
20190516 web security-basic20190516 web security-basic
20190516 web security-basic
 
Enabling Googley microservices with HTTP/2 and gRPC.
Enabling Googley microservices with HTTP/2 and gRPC.Enabling Googley microservices with HTTP/2 and gRPC.
Enabling Googley microservices with HTTP/2 and gRPC.
 
SPDY & HTTP2.0 & QUIC - #bpstudy 2013-08-28
SPDY & HTTP2.0 & QUIC - #bpstudy 2013-08-28SPDY & HTTP2.0 & QUIC - #bpstudy 2013-08-28
SPDY & HTTP2.0 & QUIC - #bpstudy 2013-08-28
 
6 app-tcp
6 app-tcp6 app-tcp
6 app-tcp
 
SPDY - http reloaded - WebTechConference 2012
SPDY - http reloaded - WebTechConference 2012SPDY - http reloaded - WebTechConference 2012
SPDY - http reloaded - WebTechConference 2012
 
Going on an HTTP Diet: Front-End Web Performance
Going on an HTTP Diet: Front-End Web PerformanceGoing on an HTTP Diet: Front-End Web Performance
Going on an HTTP Diet: Front-End Web Performance
 
Deep Dive on Accelerating Content, APIs, and Applications with Amazon CloudFr...
Deep Dive on Accelerating Content, APIs, and Applications with Amazon CloudFr...Deep Dive on Accelerating Content, APIs, and Applications with Amazon CloudFr...
Deep Dive on Accelerating Content, APIs, and Applications with Amazon CloudFr...
 
Revisiting HTTP/2
Revisiting HTTP/2Revisiting HTTP/2
Revisiting HTTP/2
 
Http2 Security Perspective
Http2 Security PerspectiveHttp2 Security Perspective
Http2 Security Perspective
 
HTTP/3 for everyone
HTTP/3 for everyoneHTTP/3 for everyone
HTTP/3 for everyone
 
HTTP/3 over QUIC. All is new but still the same!
HTTP/3 over QUIC. All is new but still the same!HTTP/3 over QUIC. All is new but still the same!
HTTP/3 over QUIC. All is new but still the same!
 
CSU33012-I-microservices.pdf
CSU33012-I-microservices.pdfCSU33012-I-microservices.pdf
CSU33012-I-microservices.pdf
 
The case for HTTP/2
The case for HTTP/2The case for HTTP/2
The case for HTTP/2
 
The Case for HTTP/2 - GreeceJS - June 2016
The Case for HTTP/2 -  GreeceJS - June 2016The Case for HTTP/2 -  GreeceJS - June 2016
The Case for HTTP/2 - GreeceJS - June 2016
 
Demystifying REST
Demystifying RESTDemystifying REST
Demystifying REST
 
HTTP/3 in curl
HTTP/3 in curlHTTP/3 in curl
HTTP/3 in curl
 
5 steps to faster web sites & HTML5 games - updated for DDDscot
5 steps to faster web sites & HTML5 games - updated for DDDscot5 steps to faster web sites & HTML5 games - updated for DDDscot
5 steps to faster web sites & HTML5 games - updated for DDDscot
 
Web-01-HTTP.pptx
Web-01-HTTP.pptxWeb-01-HTTP.pptx
Web-01-HTTP.pptx
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

HTTP/2 What's inside and Why

  • 1. HTTP/2 What’s inside and why @adrianfcole
  • 2. introduction http as we know it http performance hello http/2! firefox wrapping up
  • 3. introduction http as we know it http performance hello http/2! firefox wrapping up
  • 4. @adrianfcole • staff engineer at Twitter • founded apache jclouds • focus on cloud computing
  • 5. introduction http as we know it http performance hello http/2! firefox wrapping up
  • 6. http/1.1 • rfc2616 - June 1999 • text-based framing • defined semantics of the web http://www.w3.org/Protocols/rfc2616/rfc2616.html
  • 7. FYI: RFC 2616 is dead! • RFC 7230-5 replaces RFC 2616. • Checkout details on www.mnot.net/blog
  • 8. Latency is a product concern How you minimize latency is an IT concern @jpinner
  • 9. Latency of http/1.1 368! keepalive
  • 10. Ask Ilya why! • TCP connections need 3- way handshake. • TLS requires up to 2 more round-trips. • Read High Performance Browser Networking http://chimera.labs.oreilly.com/books/1230000000545
  • 11. HTTP nowadays • Web pages are often >1 MB and >100 requests. • Http headers can be larger than its data. • More people on mobile, and latency adds up.
  • 12. introduction http as we know it http performance hello http/2! firefox wrapping up
  • 13. Performance strategies • Increasing connections • Reducing requests
  • 14. Increasing connections • Requests and responses are ordered on a connection. • To render the page quicker, multiple connections can be used, usually 6. • some shard sites to get more than that! • Browsers handle scheduling and priority of these connections.
  • 15. reducing requests • Caching - RFC 7234 change headers • Hacks - change content
  • 16. Content hacks • Spriting - many images into a sheet, chop with css. • Data uris - encode images in the img tag • Concatenation - bundle javascript or css into the same file
  • 17. Spriting • #prev { • left: 63px; • width: 43px; • background: url('img_navsprites.gif') -47px 0; • } • #next { • left: 129px; • width: 43px; • background: url('img_navsprites.gif') -91px 0; • } http://www.w3schools.com/css/css_image_sprites.asp
  • 18. Data Uri • <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA • AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/ w38GIAXDIBKE0DHxgljNBAAO • 9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" /> http://en.wikipedia.org/wiki/Data_URI_scheme
  • 19. introduction http as we know it http performance hello http/2! firefox wrapping up
  • 20. spdy/3.1 • google - Sep 2013 • binary framing • retains http/1.1 semantics • concurrent multiplexed streams http://www.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3-1
  • 21. http/2 • ietf draft 16 - June 2014 • binary framing • retains http/1.1 semantics • concurrent multiplexed streams https://github.com/http2/http2-spec
  • 22. HTTP/2 Delivers • Avoids head-of-line blocking by framing multiplexed http over a single connection. • Identifies request streams allowing prioritization, flow control and cancelation. • Reduces impact of headers by compressing them.
  • 23. multiplexing priority flow control header compression server push http/2 headline features
  • 24. multiplexing priority flow control header compression server push http/2 headline features
  • 25. Looking at the whole message Request: request line, headers, and body Response: status line, headers, and body
  • 26. http/1.1 round-trip Content-Length: 318 Cache-Control: private, max-age=60, s-maxage= 0 Vary: SecurityToken Date: Sun, 02 Feb 2014 20:30:38 GMT Content-Type: application/json Content-Encoding: gzip GZIPPED DATA GET /things HTTP/1.1 Host: apihost SecurityToken: b08c85073c1a2d02 Accept: application/json Accept-encoding: gzip, deflate HTTP/1.1 200 OK
  • 27. http/2 round-trip :status: 200 content-length: 318 cache-control: private, max-age=60, s-maxage= 0 vary: SecurityToken date: Sun, 02 Feb 2014 20:30:38 GMT content-type: application/json GZIPPED DATA HEADERS Stream: 3 Flags: END_HEADERS, END_STREAM :method: GET :authority: apihost :path: /things securitytoken: b08c85073c1a2d02 accept: application/json HEADERS Stream: 3 Flags: END_HEADERS DATA Stream: 3 Flags: END_STREAM
  • 28. interleaving HEADERS Stream: 5 Flags: END_HEADERS, END_STREAM HEADERS Stream: 3 Flags: END_HEADERS DATA Stream: 5 Flags: DATA Stream: 5 Flags: END_STREAM HEADERS Stream: 3 Flags: END_HEADERS, END_STREAM HEADERS Stream: 5 Flags: END_HEADERS DATA Stream: 3 Flags: END_STREAM
  • 29. Canceling a Stream HEADERS Stream: 5 Flags: END_HEADERS, END_STREAM HEADERS Stream: 3 Flags: END_HEADERS DATA Stream: 5 Flags: HEADERS Stream: 3 Flags: END_HEADERS, END_STREAM HEADERS Stream: 5 Flags: END_HEADERS DATA Stream: 3 Flags: END_STREAM RST_STREAM Stream: 5 ErrorCode: CANCEL
  • 30. control frames HEADERS Stream: 5 HEADERS Stream: 3 DATA Stream: 5 DATA Stream: 3 HEADERS Stream: 3 HEADERS Stream: 5 SETTINGS Stream: 0 SETTINGS Stream: 0 DATA Stream: 5
  • 31. multiplexing priority flow control header compression server push http/2 headline features
  • 32. priority HEADERS Stream: 3 Flags: END_HEADERS, END_STREAM Exclusive: 0; Stream Dependency: 1, Weight: 10 HEADERS Stream: 5 Flags: END_HEADERS, END_STREAM Exclusive: 0; Stream Dependency: 1, Weight: 20 HEADERS Stream: 3 Flags: END_HEADERS HEADERS Stream: 5 Flags: END_HEADERS DATA Stream: 5 Flags: DATA Stream: 5 Flags: END_STREAM DATA Stream: 3 Flags: END_STREAM • Both streams shouldn’t progress before their parent. Weight is relative. data might be sent earlier
  • 33. multiplexing priority flow control header compression server push http/2 headline features
  • 34. flow control HEADERS Stream: 3 Flags: END_HEADERS DATA Stream: 3 Flags: WINDOW_UPDATE Stream: 3 you can send 8k more data Increment: 8192 DATA Stream: 3 Flags: END_STREAM HEADERS Stream: 3 Flags: END_HEADERS • flow control: send up to the lesser of stream window and connection window (stream 0)
  • 35. multiplexing priority flow control header compression server push http/2 headline features
  • 36. http/1.1 headers 168! Content-Length: 318 Cache-Control: private, max-age=60, s-maxage= 0 Vary: SecurityToken Date: Sun, 02 Feb 2014 20:30:38 GMT Content-Type: application/json Content-Encoding: gzip GZIPPED DATA GET /things HTTP/1.1 Host: apihost SecurityToken: b08c85073c1a2d02 Accept: application/json Accept-encoding: gzip, deflate HTTP/1.1 200 OK 195! 318 • You can gzip data, but not headers!
  • 37. header compression 8 bytes 52 bytes compressed :status: 200 content-length: 318 cache-control: private, max-age=60, s-maxage=0 vary: SecurityToken date: Sun, 02 Feb 2014 20:30:38 GMT content-type: application/json content-encoding: gzip GZIPPED DATA HEADERS Stream: 3 Flags: END_HEADERS, END_STREAM :method: GET :authority: apihost :path: /things securitytoken: b08c85073c1a2d02 accept: application/json accept-encoding: gzip, deflate HEADERS Stream: 3 Flags: END_HEADERS DATA Stream: 3 Flags: END_STREAM 8 bytes 85 bytes compressed • 161 byte overhead instead of 363 8 bytes
  • 38. indexed headers! 8 bytes 28 bytes compressed :status: 200 content-length: 318 cache-control: private, max-age=60, s-maxage=0 vary: SecurityToken date: Sun, 02 Feb 2014 20:30:39 GMT content-type: application/json content-encoding: gzip GZIPPED DATA HEADERS Stream: 3 Flags: END_HEADERS, END_STREAM :method: GET :authority: apihost :path: /things securitytoken: b08c85073c1a2d02 accept: application/json accept-encoding: gzip, deflate HEADERS Stream: 3 Flags: END_HEADERS DATA Stream: 3 Flags: END_STREAM 8 bytes 30 bytes compressed • 82 byte overhead instead of 363 8 bytes
  • 39. hpack • ietf draft 10 - Dec 2014 • static and dynamic table • huffman encoding http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-10
  • 40. multiplexing priority flow control header compression server push http/2 headline features
  • 41. push promise HEADERS Stream: 3 :method: GET :path: /things ... HEADERS Stream: 3 PUSH_PROMISE Stream: 3 Promised-Stream: 4 :method: GET :path: /users/0 ... HEADERS Stream: 4 DATA Stream: 4 push response goes into cache DATA Stream: 3 Server guesses a future request or indicates a cache invalidation
  • 42. Opportunities Better utilize TCP Better long-tail latency Avoid content hacks Less buffer bloat
  • 43. Challenges Higher impact of TCP Slow start Fairness on the network Server and browser support debugging a binary protocol Writing for tomorrow, with today’s TLS
  • 44. introduction http as we know it http performance hello http/2! firefox wrapping up
  • 45. Firefox • Supports latest drafts • source/netwerk/protocol/http • http/2 lead: Patrick McManus https://wiki.mozilla.org/Networking/http2
  • 46. Try out http2 with Firefox! enable http2 in about:config hit https://h2duo.cloudapp.net/ with Network Tools on
  • 47. Push promise in Firefox Push promises are sent into a per-session memory cache. When the client requests the pushed resources, they are committed to the disk cache. Allows a cap and easy discard of unused pushes. http://bitsup.blogspot.com/2014/12/ firefox-gecko-api-for-http2-push.html
  • 48. introduction http as we know it http performance hello http/2! firefox wrapping up
  • 49. Engage! • Get your web sites running http/2 or spdy! • Spread the word and get involved in http/2. • Provide feedback to httpbis! https://github.com/http2/http2-spec/wiki/Implementations https://github.com/http2/http2-spec
  • 50. Thank you! yes, twitter is hiring! yes, twitter runs http/2! github http2/http2-spec @adrianfcole