What is the role of HTTP/2 in gRPC and why does it matter?
Understand how HTTP/2 powers gRPC with multiplexing, binary framing, header compression, and streaming, and why it beats HTTP/1.1 for performance.
Expected Interview Answer
gRPC runs on top of HTTP/2, which provides multiplexed streams over a single connection, binary framing, header compression, and full-duplex communication — the exact features that make gRPC fast, efficient, and capable of streaming.
HTTP/2 lets many concurrent RPCs share one TCP connection without application-layer head-of-line blocking, so gRPC avoids the connection-per-request overhead of HTTP/1.1. Its bidirectional streams enable client, server, and bidirectional streaming RPCs, while HPACK header compression and binary framing cut latency and bandwidth compared to text-based HTTP/1.1.
- Multiplexes many RPCs over one connection
- Enables real bidirectional streaming
- Binary framing is compact and fast to parse
- HPACK header compression reduces overhead
- Lower latency and fewer TCP connections
AI Mentor Explanation
HTTP/2 is like a single pitch where many overs from both ends are bowled in an interleaved, well-managed sequence instead of building a brand-new stadium for every over. gRPC uses that shared, efficient ground so dozens of deliveries flow at once without waiting for the previous one to finish.
Step-by-Step Explanation
Step 1
One persistent connection
gRPC opens a long-lived HTTP/2 connection instead of a new one per request as in HTTP/1.1.
Step 2
Multiplexed streams
Each RPC becomes an independent HTTP/2 stream, so many run concurrently without head-of-line blocking at the app layer.
Step 3
Binary framing
HTTP/2 splits messages into compact binary frames that are fast to encode and decode.
Step 4
Header compression
HPACK compresses repeated headers, reducing per-call overhead across many RPCs.
Step 5
Full-duplex streaming
Bidirectional streams let client and server send messages independently, enabling gRPC's streaming modes.
What Interviewer Expects
- Naming multiplexing as HTTP/2's key benefit for gRPC
- Explaining why HTTP/1.1 is insufficient for streaming
- Understanding binary framing versus text protocols
- Awareness of HPACK header compression
- Connecting HTTP/2 features to gRPC streaming modes
Common Mistakes
- Saying gRPC uses HTTP/1.1
- Confusing HTTP/2 multiplexing with parallel TCP connections
- Ignoring that streaming RPCs depend on HTTP/2 full-duplex
- Assuming HTTP/2 alone eliminates head-of-line blocking at the TCP layer
Best Answer (HR Friendly)
“gRPC is built on HTTP/2, a faster version of the web protocol that lets many requests share a single connection at the same time. This makes gRPC quicker and more efficient, and it is what allows gRPC to support live, two-way streaming of data.”
Code Example
HTTP/1.1: one request per connection (or serialized)
[conn A] --> request 1 --> response 1
[conn B] --> request 2 --> response 2
HTTP/2 (gRPC): many streams over ONE connection
[conn A]
stream 1 --> RPC 1 (interleaved frames)
stream 3 --> RPC 2 (interleaved frames)
stream 5 <-> RPC 3 (bidirectional stream)Follow-up Questions
- How does HTTP/2 multiplexing differ from opening multiple TCP connections?
- What is head-of-line blocking and where can it still occur with HTTP/2?
- How does HPACK header compression work?
- Why can't gRPC streaming run efficiently over HTTP/1.1?
- What does HTTP/3 (QUIC) change for gRPC?
MCQ Practice
1. Which HTTP/2 feature most directly enables gRPC's bidirectional streaming?
Full-duplex, multiplexed streams let client and server send messages independently and concurrently over one connection.
2. How does HTTP/2 handle many concurrent RPCs?
HTTP/2 multiplexes independent streams over a single connection, avoiding the connection-per-request cost of HTTP/1.1.
3. What does HPACK provide in HTTP/2?
HPACK compresses HTTP/2 headers, reducing repeated overhead across many RPC calls.
Flash Cards
What protocol does gRPC use? — HTTP/2, for multiplexing, binary framing, header compression, and full-duplex streaming.
Why is multiplexing important? — Many RPCs share one connection concurrently, avoiding connection-per-request overhead.
What enables gRPC streaming? — HTTP/2's full-duplex bidirectional streams.
What is HPACK? — HTTP/2's header-compression scheme that cuts per-request overhead.