My personal notes for How HTTP/2 Works

A talk by Aman Alam I attended at DeveloperWeek 2019

Three Main Problems With HTTP/1.1

  • Performance: Doesn't use full bandwidth
  • Complexity: Web applications have to optimize with multiple connections due to HTTP/1.1's lack of paralyzation.
  • Efficiency: Optimizations create device and server resource consumption

Main Benefits of HTTP/2

  • Speed: Improvements in actual and perceived latency.
  • Security: TLS is required by almost all browsers.

Features of HTTP/2

  • Request multiplexing: Uses a single connection to do multiple requests simultaneously.
  • The client can indicate priorities of requests and resources, and the servers can provide those faster.
  • The TCP connection is maintained for multiple seconds after the last request before it's closed, so additional requests are fast.
  • All data is binary. This means HTTP/2 is not backwards compatible.
  • Headers are optimized. Headers between requests are diffed so they're not repeated.
  • Servers can push objects without an explicit request. The client then caches those objects.
  • HTTP/2 keeps the semantics of HTTP/1.1.
  • The browses will take care of the optimizations for you with HTTP/2.

Major Problems With HTTP/2

  • TCP is slow.
  • If packet loss rises above 2%, all HTTP/2 benefits are lost.
  • HTTP/3 will solve these problems.

HTTP/2 on Backend Servers

Use the latest backend server and it'll likely be available. All major servers currently support HTTP/2.

ALPN: Application Level protocol Negotiation. This is a way for the client and server to agree on a protocol.

Side note: Protocol buffers are a GRPC construct that transmits data in a binary format that's an alternative to JSON. Most of the performance benefits come from this.