HTTP/1.1 vs HTTP/2 vs HTTP/3
IntermediateEach HTTP version tackles the bottlenecks of its predecessor: HTTP/2 multiplexes requests over one TCP connection; HTTP/3 eliminates TCP head-of-line blocking by running over QUIC (UDP).
Overview
HTTP is the foundation of data exchange on the web. HTTP/1.1 (1997) uses one request per TCP connection by default — browsers work around this by opening 6 parallel connections per origin, wasting handshakes and memory. HTTP/2 (2015) introduces multiplexing: many requests share one TCP connection as independent streams, eliminating the per-request connection overhead and solving HTTP-level head-of-line blocking. However, one dropped TCP packet still blocks all HTTP/2 streams — TCP-level head-of-line blocking. HTTP/3 (2022) solves this by replacing TCP with QUIC (built on UDP): each stream is independent at the transport layer, so a lost packet only affects its own stream. HTTP/3 also delivers 0-RTT connection establishment for repeat connections. As a backend engineer, HTTP/2 is relevant to gRPC (which requires HTTP/2), API performance tuning, and Spring WebFlux; HTTP/3 is relevant to CDN and edge performance.
HTTP/1.1 — Limitations
HTTP/1.1 introduced persistent connections (keep-alive) and pipelining, but pipelining suffers from head-of-line blocking — responses must be delivered in order, so a slow response stalls all subsequent ones. Browsers compensate by opening multiple parallel connections.
// HTTP/1.1 — one outstanding request per connection
// Connection: keep-alive reuses TCP connection but requests are serial:
//
// Connection 1: GET /index.html → wait → response
// GET /style.css → wait → response (serial, HOL blocking)
//
// Browser workaround: open 6 connections per origin
// 6 connections × TLS handshake overhead = 6 × ~2 RTT = expensive
// HTTP/1.1 request format:
// GET /api/users HTTP/1.1
// Host: api.example.com
// Accept: application/json
// Connection: keep-alive
//
// Headers are plain text — verbose, repetitive across requests
// No header compression → ~500B overhead per request minimum
// Java HttpURLConnection (HTTP/1.1):
URL url = new URL("https://api.example.com/users");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/json");
int status = conn.getResponseCode(); // blocks until response arrivesHTTP/2 — Multiplexing & Header Compression
HTTP/2 is a binary protocol. A single TCP connection carries multiple streams simultaneously — each stream is an independent request/response. HPACK compresses headers, eliminating repeated header bytes. Server push allows the server to proactively send resources the client will need.
// HTTP/2 key features:
// 1. Binary framing — requests/responses are split into frames
// 2. Multiplexing — many streams over ONE TCP connection
// 3. HPACK header compression — headers sent once, referenced later
// 4. Stream prioritisation — client hints which responses matter most
// 5. Server push — server sends /style.css before client asks
// Multiplexing visualised:
// Single TCP connection:
// ├── Stream 1: GET /api/users (concurrent)
// ├── Stream 2: GET /api/products (concurrent)
// └── Stream 3: GET /api/orders (concurrent)
// All three in-flight simultaneously — no 6-connection workaround needed
// Java HttpClient (HTTP/2 by default in Java 11+):
HttpClient client = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_2)
.build();
HttpResponse<String> response = client.send(
HttpRequest.newBuilder(URI.create("https://api.example.com/users"))
.header("Accept", "application/json")
.build(),
HttpResponse.BodyHandlers.ofString()
);
System.out.println("Protocol: " + response.version()); // HTTP_2
// gRPC requires HTTP/2 — uses multiplexed streams for bidirectional streamingHTTP/3 — QUIC & 0-RTT
HTTP/3 replaces TCP with QUIC (UDP-based). Each QUIC stream is independently reliable — a lost packet in stream 1 does not affect stream 2. QUIC also integrates TLS 1.3, enabling 1-RTT and 0-RTT connection establishment for repeat visitors.
// HTTP/3 = HTTP/2 semantics over QUIC (UDP)
//
// TCP head-of-line blocking problem:
// Stream 1 packet lost → TCP retransmits → ALL streams stall waiting
//
// QUIC solution:
// Each stream is independently reliable
// Stream 1 packet lost → only stream 1 retransmits → streams 2, 3 continue
//
// Connection establishment comparison:
// HTTP/1.1 + TLS 1.2: TCP(1 RTT) + TLS(2 RTT) = 3 RTT before data
// HTTP/2 + TLS 1.3: TCP(1 RTT) + TLS(1 RTT) = 2 RTT before data
// HTTP/3 + QUIC: QUIC+TLS combined = 1 RTT (or 0-RTT for repeat)
//
// 0-RTT: client stores session ticket from previous visit
// next visit: sends HTTP request + session ticket in first packet
// server decrypts and responds without waiting for handshake
//
// Who uses HTTP/3?
// Cloudflare, Google, Facebook, YouTube — majority of their traffic
// Spring Boot: experimental via Netty QUIC / Vert.x
//
// Detect HTTP/3 support:
// Server sends Alt-Svc header: Alt-Svc: h3=":443"; ma=86400
// Browser upgrades to HTTP/3 on next requestKey Points to Remember
- 1HTTP/1.1: text-based, one request per connection (serial), 6 parallel connections as workaround.
- 2HTTP/2: binary, multiplexed streams over one TCP connection, HPACK header compression.
- 3HTTP/2 still has TCP-level HOL blocking — one lost packet stalls all streams.
- 4HTTP/3: runs over QUIC (UDP), per-stream reliability, eliminates TCP HOL blocking.
- 5HTTP/3 + QUIC enables 1-RTT handshake and 0-RTT for repeat connections.
- 6gRPC requires HTTP/2; most CDNs now support HTTP/3.
Interview Questions
Sign in to ask AriaWhat problem does HTTP/2 multiplexing solve over HTTP/1.1?
What is head-of-line blocking and how does HTTP/3 solve it?
Why does gRPC require HTTP/2?
What is 0-RTT in HTTP/3 and what are its security implications?
Compare the number of RTTs needed to establish a connection in HTTP/1.1+TLS vs HTTP/3.
Ask Aria about HTTP/1.1 vs HTTP/2 vs HTTP/3
Your personal AI tutor — ask anything about this concept
Revision Status
Personal Notes
Sign in to save personal notes for this topic.
Discussion
Sign in to join the discussion.