Networking & Protocols (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
What are the differences between HTTP/1.1, HTTP/2, and HTTP/3?
senior LevelCode ExampleSystem DesignHTTP & REST APIs
In Simple Words:
- HTTP/1.1 (1997): Textual protocol. Suffers from Head-of-Line (HoL) Blocking: only 1 request can be processed per TCP connection at a time. Browsers open 6 parallel TCP connections to mitigate this.
- HTTP/2 (2015 - Binary & Multiplexing):
- Binary framing layer (Headers + Data frames).
- Multiplexing: Hundreds of requests and responses interleaved concurrently over one single TCP connection!
- HPACK header compression and Server Push.
- Limitation: TCP packet loss still stalls all multiplexed streams at the transport layer!
- HTTP/3 (2022 - QUIC over UDP):
- Replaces TCP with QUIC (built on top of UDP)!
- Solves TCP packet loss HoL blocking: losing a packet on Stream 1 does not stall Stream 2!
- Faster connection establishment (0-RTT / 1-RTT connection migration when switching between Wi-Fi and 5G).
text
HTTP Evolution Comparison:
┌──────────┬───────────┬──────────────────────────┬─────────────────────────────┐
│ Version │ Transport │ Framing │ Key Advantage │
├──────────┼───────────┼──────────────────────────┼─────────────────────────────┤
│ HTTP/1.1 │ TCP │ Plain Text │ Simple, universal │
│ HTTP/2 │ TCP │ Binary Frames │ Multiplexing on 1 socket │
│ HTTP/3 │ UDP (QUIC)│ Multiplexed UDP Datagrams│ Zero packet loss HoL stalls │
└──────────┴───────────┴──────────────────────────┴─────────────────────────────┘