SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
  • OSI Model
  • IP Address
  • TCP vs UDP
  • HTTP / HTTPS
  • DNS
  • Proxy vs Reverse Proxy
  • Checksums
  • HTTP/1.1 vs HTTP/2 vs HTTP/3
  • Cookies and CORS
  • Subnets, CIDR and NAT
  • Firewalls and VPN
  • Ports and Sockets
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
Part 5: Architecture
Part 6: Distributed Systems
Part 7: Advanced Data Topics
Part 8: Operations and Security
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Foundations/Networking

HTTP/1.1 vs HTTP/2 vs HTTP/3

How HTTP got faster: reusing connections, multiplexing, and QUIC over UDP.

โฑ 14 min readIntermediateInterview FavouriteHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

HTTP has changed three times to get faster. All versions let a browser ask a server for pages and files, but they differ in how they carry many requests over the network.

  • HTTP/1.1: one request at a time per connection. Browsers open several connections to go faster.
  • HTTP/2: many requests share one connection at the same time (multiplexing), with smaller headers.
  • HTTP/3: the same ideas, but over QUIC on UDP, so one lost packet no longer stops every request.

02Concept: What is it?

The meaning of HTTP stays the same in all versions: methods such as GET and POST, URLs, status codes and headers. What changes is the way the messages travel between the browser and the server.

A modern web page needs dozens of files: HTML, CSS, scripts, images, fonts. If each file needs its own slow trip across the network, pages feel slow. Each new HTTP version tries to cut the number of trips and the time wasted waiting.

Same page, three ways to fetch it
HTTP/1.1
๐Ÿ”ŒConn 1file, then file
๐Ÿ”ŒConn 2file, then file
Parallel workneeds many connections
HTTP/2
๐Ÿงต1 TCP connectionmany streams at once
Parallel workone lost packet stalls all
HTTP/3
๐Ÿš€1 QUIC connectionindependent streams
Parallel workloss hurts one stream only
Bars show how files are carried. The idea is simplified.
๐Ÿง What is the same, and what is not
Same: methods, URLs, status codes, headers, cookies. Different: how requests are packed, how many can share a connection, and whether the connection runs on TCP or on QUIC over UDP. Your application code usually does not change.

03Real-Life Example

๐ŸตOrdering Food From a Kitchen
With HTTP/1.1 you phone the kitchen, ask for one dish, and wait on the line until it arrives, then ask for the next. To go faster you call from six phones at once. With HTTP/2 you use one phone, and the kitchen takes the whole order and sends dishes back as they are ready, mixed together on one delivery van. But if the van gets a flat tyre, every dish is stuck. With HTTP/3 the dishes travel in separate small vans. A flat tyre delays only one dish.
Kitchen
HTTP
One phone call per dish, in order
HTTP/1.1: one request at a time per connection
Six phones at once
Browser opens about 6 connections
One phone, the whole order
HTTP/2 multiplexing
One van carries every dish
One TCP connection for all streams
A flat tyre stops the van
TCP head-of-line blocking after a lost packet
Separate small vans
HTTP/3 independent QUIC streams
Moving to a new phone mid-call
QUIC connection migration (Wi-Fi to mobile)
Where the time goes
๐ŸคTCP handshake1 round trip
โ†’โ†“
๐Ÿ”TLS handshake1 more with TLS 1.3
โ†’โ†“
๐Ÿ“„Request + reply1 round trip
Fewer round trips before the first byte means a faster start.

04Why Do We Need It?

โšกFaster pages
Fewer round trips and shared connections mean pages are ready sooner, especially on slow or distant links.
๐Ÿ“ฑMobile networks
Phones change networks and lose packets often. QUIC copes better with both.
๐ŸงฐFewer hacks
HTTP/1.1 needed tricks such as sprite sheets and many domains to get speed. HTTP/2 and 3 reduce that need.
๐Ÿ—œ๏ธSmaller headers
Headers such as cookies repeat on every request. Header compression saves a lot of bytes.
๐Ÿ”’Encryption by default
In practice browsers use HTTP/2 and HTTP/3 only over TLS. QUIC has TLS 1.3 built in.
๐Ÿง Better interviews
Knowing why each version exists shows you understand head-of-line blocking and the TCP versus UDP trade-off.
Each version removes the main waiting problem of the one before it: HTTP/2 fixes the per-connection queue, HTTP/3 fixes the shared-connection stall.

05Where Do We Use It?

๐ŸŒWebsites and CDNs
Browsers, CDNs and big sites negotiate the best version automatically.
๐Ÿ”ŒgRPC
gRPC is built on HTTP/2, using its streams and header compression.
๐ŸšชReverse proxies and load balancers
Nginx, HAProxy and cloud load balancers often speak HTTP/2 or HTTP/3 to clients, and HTTP/1.1 to backends.
๐Ÿ“ฑMobile apps
Network libraries in apps use HTTP/2 and HTTP/3 to save time on unreliable links.
๐Ÿ”—API clients
Many API clients reuse connections with HTTP/2 to cut the cost of repeated calls.
๐Ÿ› ๏ธDebugging
Browser developer tools show which version each request used, in the network tab.

06Types / Parts / How It Works

The three versions side by side

HTTP/1.1HTTP/2HTTP/3
Runs onTCPTCPQUIC, over UDP
FormatPlain textBinary framesBinary frames
Requests per connection at onceOne (in practice)Many (multiplexed streams)Many (independent streams)
Header compressionNoYes (HPACK)Yes (QPACK)
Connection set-upTCP, then TLS if HTTPSTCP, then TLSOne combined QUIC and TLS 1.3 handshake
Effect of one lost packetStalls one connection (the others carry on)Stalls every stream on the connectionStalls only the stream it belongs to
Changing networksNew connection neededNew connection neededConnection can migrate
EncryptionOptionalUsed with TLS in browsersAlways (TLS 1.3 built in)

The head-of-line blocking problem

Head-of-line blocking at two levels
HTTP level (1.1)
๐Ÿ“ฆBig filetakes long
๐Ÿ“„Smallwaits
๐Ÿ“„Smallwaits

On one connection, requests are answered in order.

TCP level (HTTP/2)
โŒLost packetTCP must resend
โธ๏ธAll streamswait for it

TCP delivers bytes in order, so it holds everything behind the gap.

Fixed in HTTP/3
โŒLost packetone stream
โ–ถ๏ธOther streamskeep going

QUIC orders each stream on its own.

HTTP/1.1 HTTP/2 HTTP/3
One slow or lost item holds up everything queued behind it.
๐Ÿ“How the browser picks a version
With HTTPS, the client and server agree on a version during the TLS handshake (ALPN). For HTTP/3, a server usually advertises it (for example with an Alt-Svc header), and the browser tries QUIC next and falls back to HTTP/2 if UDP is blocked.
VisualizerLoad a page with 20 files over three HTTP versionsStart with no packet loss, then raise it. HTTP/2 can become slower than HTTP/1.1 on a bad link, while HTTP/3 holds up. Change the number of files and the round-trip time too.
When every file has arrived (shorter is better)
HTTP/1.1571 ms
HTTP/2384 ms
HTTP/3243 ms
Average time for one file to arrive
HTTP/1.1427 ms
HTTP/2384 ms
HTTP/3243 ms
Show the waterfall for

One TCP connection carries all requests at once (multiplexing). But a lost TCP packet stalls every stream on that connection.

Waterfall for HTTP/2 (first 12 of 20 files). Amber = connect, purple = HTML page, cyan = file, red = stall from packet loss.
Connect
HTML
File 1
File 2
File 3
File 4
File 5
File 6
File 7
File 8
File 9
File 10
File 11
File 12
0 ms285 ms571 ms
HTTP/1.1
571 ms
2 setup trips
HTTP/2
384 ms
2 setup trips
HTTP/3
243 ms
1 setup trip
Expected lost packets
0.8
4 packets per file
HTTP/3 finishes first at about 243 ms. Raise the packet loss to see HTTP/2 suffer, because one lost TCP packet blocks every stream sharing the connection.

A simplified, illustrative model, not a benchmark. Every request costs one round trip, a new connection costs 2 round trips for TCP plus TLS 1.3 and 1 for QUIC, and a lost packet stalls everything that shares its connection or stream for about one round trip. Real pages also depend on file sizes, congestion control, caching and server time.

07How to Use It / Steps / Implementation

Using the newer versions well

  1. 1
    Turn on HTTP/2 at the edge
    Enable it on your CDN, load balancer or web server. It needs HTTPS in browsers. Most setups need only a setting, not code changes.
  2. 2
    Add HTTP/3 where it is supported
    Enable it on a CDN or a modern proxy, open UDP port 443, and keep HTTP/2 as a fallback.
  3. 3
    Keep HTTP/1.1 for backends if simple
    Inside a data centre, delay is small, so HTTP/1.1 between a proxy and the app is often fine.
  4. 4
    Reuse connections
    Keep connections open and reuse them. Opening a new one costs round trips on every version.
  5. 5
    Stop old HTTP/1.1 tricks
    Domain sharding and giant bundles can hurt under HTTP/2, because they split or hide a single shared connection. Test before removing.
  6. 6
    Test on bad networks
    Use throttling and packet loss in your tools. The differences show up on slow, lossy links, not on a fast office network.
  7. 7
    Measure real users
    Compare load times by protocol version in your analytics or monitoring, instead of trusting a lab test alone.
  8. 8
    Watch for blocked UDP
    Some networks block or throttle UDP. Make sure the fallback to TCP works.
๐Ÿ’กYour code rarely changes
Because the meaning of HTTP stays the same, enabling a new version is mostly an infrastructure change. Frameworks and browsers handle the details.
โš ๏ธServer push is not the answer
HTTP/2 had a feature called server push, but it was hard to use well, and browsers have moved away from it. Use preload hints and good caching instead.

08Key Terms to Know

TermMeaning in easy words
MultiplexingSending many requests and replies at the same time over one connection
StreamOne request and reply pair inside a multiplexed connection
Head-of-line blockingWhen one slow or lost item holds up everything queued behind it
Keep-aliveReusing a connection for several requests instead of opening a new one
HPACK / QPACKHeader compression used by HTTP/2 and HTTP/3
QUICA transport protocol over UDP with built-in encryption and independent streams
ALPNA part of the TLS handshake where client and server agree on the HTTP version
Alt-SvcA header where a server says it is also reachable over another protocol, such as HTTP/3
Round trip (RTT)The time for a message to go to the server and the answer to come back
Connection migrationKeeping a QUIC connection alive when the client's network address changes
Binary framingSending HTTP data as compact binary frames instead of plain text

09Pros, Cons and Trade-offs

โœ… Pros
  • HTTP/2: many requests share one connection, with smaller headers
  • HTTP/3: a lost packet stalls only one stream
  • HTTP/3: faster handshake and connection migration
  • Mostly an infrastructure setting, with few code changes
  • Better experience on slow and mobile networks
โš ๏ธ Cons
  • HTTP/2 still suffers TCP head-of-line blocking on lossy links
  • HTTP/3 uses UDP, which some networks block or throttle
  • QUIC can use more CPU, and tooling is younger
  • Old tricks for HTTP/1.1 can hurt on newer versions
  • Binary protocols are harder to read by hand than plain text

Trade-offs

ChoiceWe gainWe lose
HTTP/1.1 onlySimple, works everywhere, easy to debugSlower pages, many connections
HTTP/2Multiplexing, header compression, one connectionShared TCP connection suffers on lossy networks
HTTP/3Independent streams, faster start, migrationUDP may be blocked, more CPU, newer tooling
Many parallel connectionsWorks around HTTP/1.1 limitsMore handshakes and server load
One shared connectionFewer handshakes and less server loadOne bad moment hits every request on it
Fallback to older versionsAlways reachableMore configuration to test

10Common Problems and Mistakes

Common mistakes

  1. Thinking a newer version always wins. The gain depends on files, distance and loss. On a fast, clean network the differences are small.
  2. Keeping HTTP/1.1 tricks. Domain sharding and sprite sheets can work against HTTP/2.
  3. Forgetting the fallback. If UDP is blocked and HTTP/3 has no fallback, some users cannot connect.
  4. Blocking UDP 443 on a firewall. HTTP/3 then silently never works, and nobody notices.
  5. Testing only on a fast office network. The benefits show up on slow and lossy links.
  6. Mixing up HTTP/2 and HTTP/3 causes. HTTP/2 stalls come from TCP. HTTP/3 stalls are per stream.
  7. Expecting server push to help. It is rarely used now.

Things to watch

๐Ÿ›ก๏ธFirewalls and proxies
Some middle boxes block UDP or do not understand QUIC. Always keep a TCP path.
๐Ÿ”Debugging
Binary traffic needs tools (browser dev tools, protocol-aware proxies) instead of reading text.
๐ŸงฎServer limits
HTTP/2 servers limit the number of concurrent streams per connection. Check the setting.
๐Ÿ”Certificates
HTTP/2 in browsers and HTTP/3 need valid TLS certificates. Expired ones break everything.

11Real-World Examples

๐ŸŒBrowsers
Modern browsers support all three versions and pick the best one that the server offers.
๐Ÿ“ฆCDNs
Major CDNs terminate HTTP/2 and HTTP/3 at the edge, then talk to your origin over whatever it supports.
๐Ÿ”ŒgRPC services
Built on HTTP/2, so they use its streams for long-lived, two-way calls.
๐Ÿ“ฑMobile apps
Benefit from QUIC when moving between Wi-Fi and mobile data, because the connection can survive the change.
๐ŸŽฅVideo and media
Large sites test HTTP/3 to reduce stalls and start-up time on unreliable links.
๐ŸขInternal services
Often HTTP/2 (especially gRPC) between services, or plain HTTP/1.1 where it is simple enough.
๐Ÿ“Note
Support and defaults vary by product and version. Check the documentation of your server, proxy and CDN.
Mini case: a typical modern setup
๐Ÿ“ฑBrowserHTTP/3 or HTTP/2
โ†’โ†“HTTPS
๐ŸŒCDN / edgeterminates QUIC and TLS
โ†’โ†“HTTP/2
๐ŸšชLoad balancer
โ†’โ†“HTTP/1.1
๐Ÿ–ฅ๏ธApp servers
Clients use the newest version they can. The inside of the data centre can stay simple.

12Related Topics to Read Next

HTTP / HTTPSโ†’

The basics of requests, responses and TLS that all versions share.

TCP vs UDPโ†’

HTTP/3 moves from TCP to UDP, and this page shows why.

SSL/TLSโ†’

TLS 1.3 is built into QUIC, and sets the handshake cost.

CDNโ†’

Where most sites turn on HTTP/2 and HTTP/3.

REST, GraphQL, gRPCโ†’

gRPC runs on HTTP/2.

Latency vs Throughput vs Bandwidthโ†’

Round trips and latency drive the differences between versions.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • โœ”1.1: one request at a time per connection, so browsers open about 6.
  • โœ”2: one TCP connection, many streams, header compression. A lost packet stalls all.
  • โœ”3: QUIC over UDP, independent streams, faster handshake, connection migration.
  • โœ”Same: methods, URLs, status codes, headers. Only the transport changes.
  • โœ”Pick: the version is agreed during the TLS handshake (ALPN), with fallback.
  • โœ”Do: enable HTTP/2 and HTTP/3 at the edge, keep the fallback, open UDP 443.
  • โœ”Do not: keep HTTP/1.1 tricks blindly, or test only on a fast network.
  • โœ”One line: โ€œEach version removes the waiting problem of the one before it.โ€
โ† Previous
Checksums
Next โ†’
Cookies and CORS