HTTP/2 and web development
practices
Developing for H2
HTTP
• HTTP/1.0 (RFC-1945 – May 1996)
• HTTP/1.1 (RFC-2068 – Jan 1997)
• HTTP/2 (RFC-7540 – May 2015)
https://www.ietf.org/download/rfc-index.txt
HTTP/1.x improvements
• Persistent connection (HTTP keep alive)
• HTTP pipelining
• Session state (cookies)
• HTTP over TLS
Performance Issues
• Bandwidth utilization
• Resource consumption
• High latency
• Complex web design
Head-of-line blocking
1 outstanding transaction per TCP
connection
H1 best practice
• Domain sharding
• Resource concatenation
• Spriting
• Resource inlining
CSS Inlining
Image Inlining
https://tools.ietf.org/html/draft-mbelshe-httpbis-spdy-00
H2 benefits
• Binary format
• Multiplexing
– Stream priority
– Flow control
• Header compression
• Server push
• Mandatory encryption ???
• Opportunistic encryption
Header Compression
• ~ 100 assets
• ~1 / 2 Kb each (Cookies, Referer, etc.)
• Multiple round trips to get them out
H2 benefits
• Binary format
• Multiplexing
– Stream priority
– Flow control
• Header compression
• Server push
• Mandatory encryption ???
• Opportunistic encryption
H1 client/server exchange
Server Push
Server Push
H2 benefits
• Binary format
• Multiplexing
– Stream priority
– Flow control
• Header compression
• Server push
• Mandatory encryption ???
• Opportunistic encryption
Security
Conclusion: developing for
H2
• Rethink resource concatenation
• Undo some HTTP/1.x best practices
• Keep doing
– Reduce DNS Lookups
– CDN
– Caching
– Minimize HTTP requests
– Reduce Redirects
HTTP/2 and web development practices
HTTP/2 and web development practices

HTTP/2 and web development practices

Editor's Notes

  • #3 IETF Index: https://www.ietf.org/download/rfc-index.txt HTTP2: RFC-7540, RFC-7541, RFC-8164
  • #4 HTTP pipelining: multiple serial requests over single TCP without waiting for the response
  • #6 The “head-of-line blocking” is the phenomenon where effectively only one request can be outstanding on a connection at a time It has been fixed with HTTP pipelining, but it didn’t completely address the problem (a large or slow response can still block others behind it)
  • #7 Domain Sharding – splits resources across subdomains to improve performance. Allow simultaneous resource download at any given time Concatenation – bundles several Javascript files into single minified Javascript file It Introduced numerous regressions: poor caching, unnecessary downloads, delayed execution With the concatenation we lose the caching benefit, because there is no granularity. Image Spriting - is a collection of images put into a single image
  • #8 Inlining Images - uses data URI to embed image items. Inline images saves HTTP requests over externally referenced objects. Refer link for more details
  • #11 Initial Google effort with a protocol called SPDY HTTP/2 was developed by the IETF’s HTTP Working Group, SPDY was gaining traction with implementers (like Mozilla and nginx), so it was chosen as the basis for HTTP/2 Core engineer at Google Mike Belshe and Roberto Peon, joined the H2 effort. Google deprecated the protocol and adopted H2
  • #12 HTTP/1.x semantic is mantained (HTTP verbs, request/response schema, etc), but is not backwards compatible due to the binary format Binary format: binary protocols are more efficient to parse, more compact “on the wire”, and most importantly, they are much less error-prone Multiplexing address the HOL blocking Priority: The purpose of prioritization is to allow an endpoint to express how it would prefer its peer to allocate resources when managing concurrent streams. Flow control: ensures that streams on the same connection do not destructively interfere with each other. Encryption: is not mandatory, but major browser vendors implemented H2 over TLS. Opportunistic encryption: using TLS for HTTP URLs
  • #13 Not uncommon to have multiple assets of several Kbs Conservative estimation
  • #19 Opportunistic encryption: using TLS for HTTP URLs
  • #20 To enable HTTP/2 on NginX