System design2 min

HTTP/1.1 vs HTTP/2 vs HTTP/3

HTTP (Hypertext Transfer Protocol) is the foundation of data communication on the World Wide Web. Understanding how it has evolved helps you optimize the performance of your APIs and web applications.

HTTP/1.1: The Standard

Released in 1997, HTTP/1.1 is still widely used today. It introduced "Keep-Alive" connections, meaning a TCP connection could stay open to send multiple requests instead of closing after every single response.

The Problem: Head-of-Line (HOL) Blocking. In HTTP/1.1, requests on a single connection must be processed sequentially. If a server takes a long time to respond to Request 1, Request 2 is blocked and must wait, even if it's a tiny file. Browsers bypass this by opening multiple parallel TCP connections (usually capped at 6 per domain), but this is resource-intensive.

HTTP/2: Multiplexing

Released in 2015, HTTP/2 solved the HOL blocking problem at the HTTP layer while keeping the same semantics (methods, status codes, headers).

Key Features:

  • Multiplexing: Multiple requests and responses can be sent over a single TCP connection simultaneously. They are broken into tiny "frames" and reassembled on the other side.
  • Binary Protocol: HTTP/2 is binary instead of plain text, making it faster to parse and less prone to errors.
  • Header Compression (HPACK): Headers are compressed, significantly reducing overhead for repeated requests.
  • Server Push: The server can proactively send resources (like CSS/JS) to the client before the client even asks for them.

The Problem: TCP Head-of-Line Blocking. While HTTP/2 fixed HOL blocking at the application layer, it still relies on TCP. If a single packet is lost during transmission, the TCP protocol halts all multiplexed streams on that connection until the lost packet is retransmitted. In poor network conditions, HTTP/2 can actually perform worse than HTTP/1.1!

HTTP/3: The QUIC Revolution

Released in 2022, HTTP/3 fundamentally changes the underlying transport protocol. Instead of using TCP, it uses QUIC (Quick UDP Internet Connections)—a protocol built on top of UDP.

Key Features:

  • No TCP HOL Blocking: Because QUIC uses UDP, streams are completely independent. If a packet for Stream A is lost, only Stream A pauses; Stream B continues unaffected.
  • Faster Connection Setup: Traditional HTTPS requires a TCP handshake plus a TLS handshake (multiple round trips). QUIC combines them, allowing 1-RTT (Round Trip Time) or even 0-RTT connection setups.
  • Connection Migration: If your mobile phone switches from Wi-Fi to Cellular, your IP address changes. In TCP, the connection drops. QUIC identifies connections by a unique ID, so your download continues seamlessly even as your network changes.

Summary

When designing systems, enabling HTTP/2 or HTTP/3 on your Load Balancer or CDN is often a "free" performance upgrade for client-facing applications.